Dear All, I am new to hibernate. Please help me regarding the multiple save object within single transaction. try { Transaction tx = session.beginTransaction(); session.save(emp); session.save(dept); tx.commit; } catch (Exception e) { tx.rollback; }
Above code is saving "emp" and "dept" object in single transaction. If "session.save(emp)" is executed properly but "session.save(dept)" given error, while executing "tx.commit". My question is, if "emp" and "dept" is saving within single transaction then either both has to commit or rollback, but "emp" is committed and "dept" came out with error.
Is there any way to commit or rollback both object within single transaction.
Thanks and regards.
|