Results 1 to 2 of 2

Thread: SimpleJdbcTemplate batch insert does not return auto generated keys

  1. #1
    Join Date
    Nov 2008
    Posts
    18

    Smile SimpleJdbcTemplate batch insert does not return auto generated keys

    Hello All,

    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

    http://forum.springsource.org/showth...t=batch+insert

    Is there any work around for this problem ?
    Waiting for a favorable response.
    Thanks in advance.
    Kind Regards.
    Max

  2. #2
    Join Date
    Sep 2005
    Location
    Webster Groves, MO
    Posts
    95

    Default

    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
    Rick Herrick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •