Created
August 10, 2012 14:29
-
-
Save jdewind/3314627 to your computer and use it in GitHub Desktop.
Manual Transaction
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
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