Skip to content

Instantly share code, notes, and snippets.

@luksrn
Created May 3, 2012 15:40
Show Gist options
  • Save luksrn/2586621 to your computer and use it in GitHub Desktop.
Save luksrn/2586621 to your computer and use it in GitHub Desktop.
Open Session Hibernate 2
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