Created
May 3, 2012 15:40
-
-
Save luksrn/2586621 to your computer and use it in GitHub Desktop.
Open Session Hibernate 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Session sess = factory.openSession(); | |
Transaction tx; | |
try { | |
tx = sess.beginTransaction(); | |
sess.save( obj ); // Persiste algum objeto | |
tx.commit(); | |
} | |
catch (Exception e) { | |
if (tx!=null) tx.rollback(); | |
throw e; | |
} | |
finally { | |
sess.close(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment