rocket mass heater kickstarter
The moose likes Spring and the fly likes Spring Hibernate Transaction  2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Hibernate Transaction  2" Watch "Spring Hibernate Transaction  2" New topic

Spring Hibernate Transaction 2

shakir hussain

Joined: Sep 13, 2007
Posts: 10
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

Joined: Feb 05, 2001
Posts: 17260

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.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Spring Hibernate Transaction 2