Package de.xima.fc.persistence.impl.tx
Class JpaTransaction
- java.lang.Object
-
- de.xima.fc.persistence.impl.tx.JpaTransaction
-
- All Implemented Interfaces:
IJpaTransaction,Closeable,AutoCloseable
public class JpaTransaction extends Object implements IJpaTransaction
Implementation ofIJpaTransactionthat manages a JPA transaction using anEntityManager. This class ensures that the transaction is properly started, committed, or rolled back as needed.Such a transaction stands alone: nothing takes part in it, and work done in it is committed or rolled back on its own. A transaction other work can take part in is opened by the
JpaTransactionRunner.Note: This class is designed for internal use only. Plugins should not use this interface. This class may be moved to a different package in the future, so plugins should not depend on it.
- Since:
- 8.5.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the JPA transaction context, committing the JPA transaction if set to do so.voidcommit()Marks the transaction to be committed when the transaction context isclosed.javax.persistence.EntityManagerem()Returns the JPA EntityManager associated with this transaction context.static IJpaTransactionforEntityManager(javax.persistence.EntityManager em)booleanisCommit()Checks if the transaction is marked to be committed when it is closed.voidrollback()Marks the transaction to be rolled back when the transaction context isclosed.
-
-
-
Method Detail
-
forEntityManager
public static IJpaTransaction forEntityManager(javax.persistence.EntityManager em)
-
close
public void close()
Description copied from interface:IJpaTransactionCloses the JPA transaction context, committing the JPA transaction if set to do so.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceIJpaTransaction- See Also:
IJpaTransaction.commit()
-
commit
public void commit()
Description copied from interface:IJpaTransactionMarks the transaction to be committed when the transaction context isclosed.- Specified by:
commitin interfaceIJpaTransaction- See Also:
IJpaTransaction.close()
-
em
public javax.persistence.EntityManager em()
Description copied from interface:IJpaTransactionReturns the JPA EntityManager associated with this transaction context.- Specified by:
emin interfaceIJpaTransaction- Returns:
- the EntityManager
-
isCommit
public boolean isCommit()
Description copied from interface:IJpaTransactionChecks if the transaction is marked to be committed when it is closed.- Specified by:
isCommitin interfaceIJpaTransaction- Returns:
- true if the transaction is set to be committed, false otherwise
- See Also:
IJpaTransaction.commit(),IJpaTransaction.rollback()
-
rollback
public void rollback()
Description copied from interface:IJpaTransactionMarks the transaction to be rolled back when the transaction context isclosed.- Specified by:
rollbackin interfaceIJpaTransaction- See Also:
IJpaTransaction.close()
-
-