Does Hibernate auto-rollback programmatic transactions when unhandled exception occurs? -


When working with programmatic transactions in Hibernate, it is necessary to make a rollback call explicitly when an exception occurs, or Will there be any uncontrollable exception to rollback calls in mind? The code below seems like a secure approach (albeit ugly code) to ensure rollback, but I'm wondering if this is another great way to coding, thoughts?

  applicationContact AC = new classpath XmlApplicationContext ("hibernate-config.xml"); Session Factory Factory = (Sassfinti) ACATABA.N. ("Sessionfactor"); Session session = factory .getCurrentSession (); Transaction txn = Faucet; Try {txn = session.beginTransaction (); // & lt; Insert transaction tasks here & gt; Txn.commit (); } Hold (exception e) {try {txn.rollback (); } Hold (exception eAny) {} throw (e); } Finally {session.close (); }  

How about using?

Runtime due to all runtime exceptions by default, but you can tune it to rollback to all exceptions.

AFAIK should be aware of something you will get, for example: You can not comment with everything @ Transactional , public ways of classes or beans only.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -