This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
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.