• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Use of TransactionTemplate with autocommit on in Spring 2.5 (JDK 1.4)

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please find my code components below -

1) Spring config xml contents -


2) Test Java class -




I have following 3 methods -

1) insertUsers (List, TransactionTemplate)
2) insertUsers (List)
3) deleteUsers (List)

The first "insertUsers" method encompasses the call to "jdbcTemplate.batchUpdate" within the TransactionTemplate but in
case of second "insertUsers" method, the call to the method is encompassed within the TransactionTemplate as can be seen
in the "main" method.

In case of any exception, the first "insertUsers" method rollsback all INSERTS while second "insertUsers" method
does not i.e. all INSERTS done before exception get commited.

I am using JDBCTemplate.batchUpdate(String sql, BatchPreparedStatementSetter setter) to perform a batch INSERT operation in Oracle 11g database.
I believe the connection has 'autocommit' set to true by default.

Could you please advice the reason for the 2 behaviours?

Regards,
Jacob
reply
    Bookmark Topic Watch Topic
  • New Topic