This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes Use of TransactionTemplate with autocommit on in Spring 2.5 (JDK 1.4) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Use of TransactionTemplate with autocommit on in Spring 2.5 (JDK 1.4)" Watch "Use of TransactionTemplate with autocommit on in Spring 2.5 (JDK 1.4)" New topic
Author

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

Jacob Tom
Greenhorn

Joined: Mar 06, 2013
Posts: 5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use of TransactionTemplate with autocommit on in Spring 2.5 (JDK 1.4)
 
Similar Threads
Understand regarding REQUIRED and REQUIRES_NEW
Dependency Injection Problem.
Transaction ManageMent in Spring with Hibernate
data source defined but not found..
Struts JDBC inserting data