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 Transaction Management in Spring 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 "Transaction Management in Spring" Watch "Transaction Management in Spring" New topic

Transaction Management in Spring

xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Hi All,

I am using Spring along with JPA for persistence. Transaction are getting managed by Spring. I came across a situation where i need to commit the transaction. Below is the senarios

1. Method A has Updates columns of the table.
2. After update, method A calls web service (Another application) to generate reports. In web service, we pull the data from same database.
3. Still JPA/Spring has not committed the transaction. Because of this, in web service we are getting the old data not updated in method A calls.

Only one solution, i can think is to commit the transaction before calling webservice. Even if i tried Entity.flush() method also but it is also not committing the transaction.

Transaction is getting committed at the end of the method call. (Post web service call).

Please advice,


Bill Gorder

Joined: Mar 07, 2010
Posts: 1648

The transaction is not committed until the method returns. So split it out. Psedo code below

[How To Ask Questions][Read before you PM me]
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Thanks a lot. I got the answer.. Thank you very much.
It is sorta covered in the JavaRanch Style Guide.
subject: Transaction Management in Spring
Similar Threads
Spring 3 and JDO (Java Data Objects)
Transacton propagation across applications
PersistanceContext - Extended Scope
Struts 2 Actions having Transaction Management capabilities(calling 2 or more Service Layers)
CMT doesn't commit DB changes in a POJO