Last active
June 21, 2024 16:43
-
-
Save mcsee/30d21e449099f361010a767dcc66c571 to your computer and use it in GitHub Desktop.
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 class TransactionService { | |
private EntityManager entityManager; | |
public TransactionService(EntityManager entityManager) { | |
this.entityManager = entityManager; | |
} | |
public void saveTransaction(Transaction transaction) { | |
entityManager.getTransaction().begin(); | |
entityManager.persist(transaction); | |
entityManager.getTransaction().commit(); | |
} | |
public Transaction loadTransaction( | |
Long id, Class<? extends Transaction> transactionClass) { | |
return entityManager.find(transactionClass, id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment