Class FHIRTransactionHelper
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.helper.FHIRTransactionHelper
-
public class FHIRTransactionHelper extends java.lang.Object
This helper class is used to manage the transaction on the current thread.
-
-
Constructor Summary
Constructors Constructor Description FHIRTransactionHelper(FHIRPersistenceTransaction txn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin()
If a transaction has not yet been started on this thread, then start one.void
commit()
If we previously started a transaction on this thread using this helper instance, then commit it now.void
end()
Same as commit, but is preferred for readability becausecommit()
will actually do a rollback if setRollbackOnly is called on the underlying transactionboolean
hasBegun()
Find out if we're currently in a transactionvoid
rollback()
If we previously started a transaction on this thread using this helper instance, then perform a rollback now; otherwise, set the transaction as 'rollback only' to prevent it from being committed later.void
setRollbackOnly()
Mark the current transaction for rollback.
-
-
-
Constructor Detail
-
FHIRTransactionHelper
public FHIRTransactionHelper(FHIRPersistenceTransaction txn)
-
-
Method Detail
-
begin
public void begin() throws FHIRPersistenceException
If a transaction has not yet been started on this thread, then start one.- Throws:
FHIRPersistenceException
-
commit
public void commit() throws FHIRPersistenceException
If we previously started a transaction on this thread using this helper instance, then commit it now.- Throws:
FHIRPersistenceException
-
end
public void end() throws FHIRPersistenceException
Same as commit, but is preferred for readability becausecommit()
will actually do a rollback if setRollbackOnly is called on the underlying transaction- Throws:
FHIRPersistenceException
-
rollback
public void rollback() throws FHIRPersistenceException
If we previously started a transaction on this thread using this helper instance, then perform a rollback now; otherwise, set the transaction as 'rollback only' to prevent it from being committed later.- Throws:
FHIRPersistenceException
-
setRollbackOnly
public void setRollbackOnly() throws FHIRPersistenceException
Mark the current transaction for rollback.- Throws:
FHIRPersistenceException
-
hasBegun
public boolean hasBegun() throws FHIRPersistenceException
Find out if we're currently in a transaction- Returns:
- Throws:
FHIRPersistenceException
-
-