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

Creating a SimpleJdbcInsert from a NamedParameterJdbcTemplate [SPR-16241] #20788

Closed
spring-projects-issues opened this issue Nov 29, 2017 · 2 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 29, 2017

Hans Desmet opened SPR-16241 and commented

For the moment there is a constructor SimpleJdbcInsert(JdbcTemplate jdbcTemplate).
If you would add a constructor SimpleJdbcInsert(NamedParameterJdbcTemplate namedParameterJdbcTemplate) this would be handy if you only inject a NamedParameterJdbcTemplate bean in your repository bean, not a JdbcTemplate bean.


Affects: 5.0.2

Issue Links:

Referenced from: commits b55a263

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Since SimpleJdbcInsert is actually lower-level than NamedParameterJdbcTemplate in terms of the package layering, a dedicated constructor doesn't seem to be feasible.

That said, we can nevertheless simplify such an arrangement by giving NamedParameterJdbcTemplate a getJdbcTemplate() method (since currently it only has getJdbcOperations() at the interface level which isn't sufficient for the purposes here).

This allows for the following code to work:

new SimpleJdbcInsert(namedParameterJdbcTemplate.getJdbcTemplate())

instead of the currently needed downcast:

new SimpleJdbcInsert((JdbcTemplate) namedParameterJdbcTemplate.getJdbcOperations())

I'll schedule that part for 5.0.3. I hope that's sufficient for your purposes?

@spring-projects-issues
Copy link
Collaborator Author

Hans Desmet commented

OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants