Jun 18th, 2010, 01:35 AM
SimpleJdbcTemplate batch insert does not return auto generated keys
I have been using SimpleJdbcTemplate and wanted to do a batch insert but the returned array returns the number of rows affected. Is there a way to get the auto generated keys for the batch insert ? I found a thread related to this problem but there are no replies regarding the solution for SimpleJdbcTemplate
Is there any work around for this problem ?
Waiting for a favorable response.
Thanks in advance.
Jul 13th, 2010, 02:23 PM
This is obviously a pretty common issue! I just posted a reply to a similar thread.
Note that the SimpleJdbcInsert constructor takes either a DataSource or a JdbcTemplate, not a SimpleJdbcTemplate (and no, SimpleJdbcTemplate and JdbcTemplate are not compatible; SimpleJdbcTemplate implements SimpleJdbcOperations and that's all). You can, however, call getJdbcTemplate() directly if you're extending SimpleJdbcDaoSupport.
Last edited by rherrick; Jul 13th, 2010 at 02:27 PM.
Reason: Added note about constructing SimpleJdbcInsert