Announcement Announcement Module
Collapse
No announcement yet.
how to get autogenerated keys from batch update opertaion using sping SimpleJdbcTempl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to get autogenerated keys from batch update opertaion using sping SimpleJdbcTempl

    Hi All,
    I am using the below code for inserting the data but i want to get the autogenerated keys can anyone please explain me how can i get the keys?
    public class TestDBExportImpl
    {
    private SimpleJdbcTemplate template;
    private SimpleJdbcInsert insertActor;

    @Autowired
    public void setDataSource(DataSource dataSource)
    {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertActor =
    new SimpleJdbcInsert(dataSource);

    }

    @Override
    @SuppressWarnings({"unchecked", "rawtypes"})


    public void importData(final HashMap map)
    {
    if(map.size()>0)
    {

    setIdentityInsert((String)map.get("TableName"),"ON ");
    try
    {
    log.info("map.size() : " + map.size() );
    int[] updateCounts = template.batchUpdate((String) map.get("Query"), (List<Object[]>)map.get("Values"), (int[])map.get("Sqltypes"));




    } catch (Exception ex)
    {

    }
    setIdentityInsert((String)map.get("TableName"),"OF F");
    }
    }
Working...
X