Skip to content

Instantly share code, notes, and snippets.

@kubawieczorek
Created December 30, 2019 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubawieczorek/1414568ea1acf956731a8ee33be3bae2 to your computer and use it in GitHub Desktop.
Save kubawieczorek/1414568ea1acf956731a8ee33be3bae2 to your computer and use it in GitHub Desktop.
Transaction tx = null;
try {
tx = session.beginTransaction();
// do some work
tx.commit();
}
catch (RuntimeException e) {
if (tx != null) tx.rollback();
throw e;
}
finally {
session.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment