Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow SimpleJdbcTemplate to create insert statements qualified with database name [SPR-8428] #13074

Closed
spring-issuemaster opened this issue Jun 9, 2011 · 2 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jun 9, 2011

Joe Kearney opened SPR-8428 and commented

It is not currently possible to execute a cross-database insert with SimpleJdbcTemplate because the TableMetaDataContext will not put the database name in the SQL string. This behaviour cannot be overridden for use in SimpleJdbcTemplate because it's a private final field.

If org.springframework.jdbc.core.metadata.TableMetaDataContext.createInsertString(String[]) prepended the database name (is this the catalog name?) before the schema.table_name then this would just work. Similarly if SimpleJdbcTemplate allowed the TableMetaDataContext to be set, we could implement this ourselves.

Workaround is to use withoutTableColumnMetaDataAccess(), specify the column names explicitly and give the table name as database_name..table_name.

Use case database server login per system component with appropriate privileges to the multiple databases in the database server. Single connection may be able to read/write from/to more than one database, but has only one default database.

(This applies to at least MS SQL Server with multiple databases in the same database server.)


Affects: 3.0.5

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 10, 2011

Joe Kearney commented

Of course, this is supposed to be SimpleJdbcInsert throughout, not template. Typo, sorry.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 22, 2015

Juergen Hoeller commented

Closing groups of outdated issues. Please reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.