public class JPAEntityTransaction extends Object implements javax.persistence.EntityTransaction
Constructor and Description |
---|
JPAEntityTransaction(org.datanucleus.ExecutionContext ec)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertActive()
Convenience method to throw an exception if the transaction is not active.
|
protected void |
assertNotActive()
Convenience method to throw an exception if the transaction is active.
|
void |
begin()
Start a resource transaction.
|
void |
commit()
Commit the current transaction, writing any unflushed changes to the database.
|
void |
deregisterEventListener(org.datanucleus.TransactionEventListener listener)
Method to deregister a listener for transaction events.
|
boolean |
getRollbackOnly()
Determine whether the current transaction has been marked for rollback.
|
boolean |
isActive()
Indicate whether a transaction is in progress.
|
void |
registerEventListener(org.datanucleus.TransactionEventListener listener)
Method to register a listener for transaction events.
|
void |
releaseSavepoint(String name)
Method to mark the current point as a savepoint with the provided name.
|
void |
rollback()
Roll back the current transaction.
|
void |
rollbackToSavepoint(String name)
Method to mark the current point as a savepoint with the provided name.
|
void |
setOption(String option,
boolean value)
Convenience accessor for setting a transaction option.
|
void |
setOption(String option,
int value)
Convenience accessor for setting a transaction option.
|
void |
setOption(String option,
String value)
Convenience accessor for setting a transaction option.
|
void |
setRollbackOnly()
Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.
|
void |
setSavepoint(String name)
Method to mark the current point as a savepoint with the provided name.
|
public JPAEntityTransaction(org.datanucleus.ExecutionContext ec)
ec
- The ExecutionContext providing the transaction.public boolean isActive()
isActive
in interface javax.persistence.EntityTransaction
javax.persistence.PersistenceException
- if an unexpected error condition is encountered.public void begin()
begin
in interface javax.persistence.EntityTransaction
IllegalStateException
- if the transaction is activepublic void commit()
commit
in interface javax.persistence.EntityTransaction
IllegalStateException
- if isActive() is false.javax.persistence.RollbackException
- if the commit fails.public void rollback()
rollback
in interface javax.persistence.EntityTransaction
IllegalStateException
- if isActive() is false.javax.persistence.PersistenceException
- if an unexpected error condition is encountered.public boolean getRollbackOnly()
getRollbackOnly
in interface javax.persistence.EntityTransaction
IllegalStateException
- if isActive() is false.public void setRollbackOnly()
setRollbackOnly
in interface javax.persistence.EntityTransaction
IllegalStateException
- Thrown if the transaction is not activepublic void setOption(String option, int value)
option
- option namevalue
- The valuepublic void setOption(String option, boolean value)
option
- option namevalue
- The valuepublic void setOption(String option, String value)
option
- option namevalue
- The valuepublic void setSavepoint(String name)
name
- Name of the savepoint.UnsupportedOperationException
- if the underlying datastore doesn't support savepointsIllegalStateException
- if no name is providedpublic void releaseSavepoint(String name)
name
- Name of the savepoint.UnsupportedOperationException
- if the underlying datastore doesn't support savepointsIllegalStateException
- if no name is provided, or the name doesn't correspond to a known savepointpublic void rollbackToSavepoint(String name)
name
- Name of the savepoint.UnsupportedOperationException
- if the underlying datastore doesn't support savepointsIllegalStateException
- if no name is provided, or the name doesn't correspond to a known savepointprotected void assertActive()
IllegalStateException
- Thrown if the transaction is not active.protected void assertNotActive()
IllegalStateException
- Thrown if the transaction is active.public void registerEventListener(org.datanucleus.TransactionEventListener listener)
listener
- The listenerpublic void deregisterEventListener(org.datanucleus.TransactionEventListener listener)
listener
- The listener to removeCopyright © 2020. All rights reserved.