Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Management in Spring

 
xsunil kumar
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Sunil

 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The transaction is not committed until the method returns. So split it out. Psedo code below

 
xsunil kumar
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. I got the answer.. Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic