Package de.xima.fc.persistence.tx
Interface IJpaTransaction
-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
JpaTransaction
public interface IJpaTransaction extends Closeable
Common interface representing a JPA transaction context, which encapsulates a single JPA entity transaction. This interface provides methods to manage the transaction lifecycle, including committing and rolling back transactions.Note: Transactions need be set to be committed on close explicitly by calling
commit(). Otherwise, the transaction will be rolled back automatically when the context is closed.This interface extends
Closeableto allow for automatic resource management, ensuring that the transaction is properly closed and resources are released.Note: This interface is designed for internal use only. Plugins should not use this interface. This interface may be moved to a different package in the future, so plugins should not depend on it.
- Since:
- 8.5.0
- Author:
- Norman Lorenz
-
-
Method Summary
All Methods Instance Methods Abstract 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.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
-
close
void close()
Closes the JPA transaction context, committing the JPA transaction if set to do so.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IllegalStateException- if the JPA EntityManager is closed or the JPA transaction is not activeRuntimeException- if the commit fails- See Also:
commit()
-
commit
void commit()
Marks the transaction to be committed when the transaction context isclosed.- See Also:
close()
-
em
javax.persistence.EntityManager em()
Returns the JPA EntityManager associated with this transaction context.- Returns:
- the EntityManager
-
isCommit
boolean isCommit()
Checks if the transaction is marked to be committed when it is closed.- Returns:
- true if the transaction is set to be committed, false otherwise
- See Also:
commit(),rollback()
-
-