Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Hibernate Transaction 2

 
shakir hussain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
Another question related to Spring-Hibernate Transaction.

In a transaction (Spring used on service layer, and Hibernate on DAO layer), 5 database tables are updated. 4 of them are application specific tables and 5th one is like for log/backup/low_priority_table.


I have two scenario to resolve:
1. If insertion or updation in 5th(log/backup) table fails for some reason but other 4 of them are successfully updated -
then, I don't want transaction to be rolled back.

Is it possible ? If yes, how ?

2. If operation on either of the 4 tables failed, need rollback of all 5 tables.

Let me know if question is not clear.

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For that 5th call, you would want to set the @Transactional propagation to REQUIRES_NEW. This will make sure that the 5th will not cause a rollback of the first 4, but if it fails in any of the 4, then the entire transaction is rolled back.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic