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:
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:public JdbcOperations getJdbcOperations() Expose the classic Spring JdbcTemplate to allow invocation of less commonly used methods.
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?Code:JdbcTemplate jdbcTemplate = (JdbcTemplate)simpleJdbcTemplate.getJdbcOperations() ;


Reply With Quote