Skip to content

Instantly share code, notes, and snippets.

@jdewind
Created August 10, 2012 14:29
Show Gist options
  • Save jdewind/3314627 to your computer and use it in GitHub Desktop.
Save jdewind/3314627 to your computer and use it in GitHub Desktop.
Manual Transaction
public void save(Object entity) {
final EntityTransaction transaction = getEntityManager().getTransaction();
transaction.begin();
try {
getEntityManager().persist(entity);
transaction.commit();
} catch (Throwable e) {
transaction.rollback();
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment