Java transaction API : to COMMIT part of transaction
Posted on 2010-08-17
I am working on spring and hibernate project. In DAO layer i am using Java transaction API. JTA :
userTransaction t = ic.lookup(java:comp/UserTransaction)
session.load(); //generates sql to retrieve row from databse
sessio.saveorupdate(); //generates sql to save object in database
My question is if there is a problem with the above transaction say for example
session.load(); is sucessful but session.saveorupdate(); fails,
the entire transaction would roll back, so in that case session.load(); would also fail (because the entire transaction is rolled back.)
My requirment is to make the sucessful part of the transaction to commit. so in this case i want
session.load(); to commit although sessio.saveorupdate(); is rolled back.
Any idea how i can modify my above code.