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-issuemaster opened this issue Nov 29, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

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:

  • #20599 Customize PreparedStatementCreatorFactory in getPreparedStatementCreator

Referenced from: commits b55a263

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 29, 2017

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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 29, 2017

Hans Desmet commented

OK

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