Announcement Announcement Module
Collapse
No announcement yet.
using SimpleJdbcTemplate.getJdbcOperations() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using SimpleJdbcTemplate.getJdbcOperations()

    I planned to inject (rather than inherit) either JdbcTemplate or SimpleJdbcTemplate because my classes are Service-DAO hybrids. SimpleJdbcTemplate does almost everything I need except it does not provide an update method that accepts a GeneratedKeyHolder in order to return the identity of inserted rows. That method is only in JdbcTemplate. SimpleJdbcTemplate does not have a getJdbcTemplate() but it has the method getJdbcOperations() which is described on the SimpleJdbcTemplate doc page as:

    Code:
    public JdbcOperations getJdbcOperations()
        Expose the classic Spring JdbcTemplate to allow invocation of less commonly used methods.
    How do you use the getJdbcOperations() in order to get access the the 'underlying' JdbcTemplate? Is it a simple matter of casting, i.e.
    Code:
    JdbcTemplate jdbcTemplate = (JdbcTemplate)simpleJdbcTemplate.getJdbcOperations() ;
    I tried this and it works. However, it seems like a sort of non-Spring way of doing things. Is this the way getJdbcOperations() was intended to be used?
Working...
X