-
Sep 21st, 2010, 11:59 PM
#1
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");
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules