Class FHIRUserTransactionAdapter
- java.lang.Object
 - 
- com.ibm.fhir.persistence.jdbc.connection.FHIRUserTransactionAdapter
 
 
- 
- All Implemented Interfaces:
 FHIRPersistenceTransaction
public class FHIRUserTransactionAdapter extends Object implements FHIRPersistenceTransaction
Adapter to simplify transaction handling. This object is returned by FHIRPersistenceJDBCImpl and can be used instead of the old FHIRTransactionHelper 
- 
- 
Constructor Summary
Constructors Constructor Description FHIRUserTransactionAdapter(UserTransaction tx, TransactionSynchronizationRegistry syncRegistry, FHIRPersistenceJDBCCache cache, String transactionDataKey)Public constructor 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()If a transaction has not yet been started on this thread, then start one.voidend()If we previously started a transaction on this thread using this helper instance, then commit it now.(package private) <T> Tfunc(Supplier<T> s)Call the supplier function within a begin/endprotected intgetStatus()Get theStatusof the global transactionbooleanhasBegun()Determine if the transaction status is currently activeprotected booleanisActive(int status)Is there a transaction currently on this thread?protected booleanisMarkedForRollback(int status)Has this transaction been marked for rollback?protected booleanisNoTransaction(int status)Are we in the NO TRANSACTION state?booleanisTransactional()Does the underlying implementation actually support transactions? A persistence layer must always return a FHIRPersistenceTransaction even if it doesn't support transactions.voidsetRollbackOnly()Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction. 
 - 
 
- 
- 
Constructor Detail
- 
FHIRUserTransactionAdapter
public FHIRUserTransactionAdapter(UserTransaction tx, TransactionSynchronizationRegistry syncRegistry, FHIRPersistenceJDBCCache cache, String transactionDataKey)
Public constructor- Parameters:
 tx-
 
 - 
 
- 
Method Detail
- 
begin
public void begin() throws FHIRPersistenceExceptionIf a transaction has not yet been started on this thread, then start one.- Specified by:
 beginin interfaceFHIRPersistenceTransaction- Throws:
 FHIRPersistenceException
 
- 
end
public void end() throws FHIRPersistenceExceptionIf we previously started a transaction on this thread using this helper instance, then commit it now.- Specified by:
 endin interfaceFHIRPersistenceTransaction- Throws:
 FHIRPersistenceException
 
- 
setRollbackOnly
public void setRollbackOnly() throws FHIRPersistenceExceptionDescription copied from interface:FHIRPersistenceTransactionModify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.- Specified by:
 setRollbackOnlyin interfaceFHIRPersistenceTransaction- Throws:
 FHIRPersistenceException
 
- 
isTransactional
public boolean isTransactional()
Description copied from interface:FHIRPersistenceTransactionDoes the underlying implementation actually support transactions? A persistence layer must always return a FHIRPersistenceTransaction even if it doesn't support transactions. This reduces boilerplate code by avoiding the need to check for null every time.- Specified by:
 isTransactionalin interfaceFHIRPersistenceTransaction- Returns:
 
 
- 
isActive
protected boolean isActive(int status)
Is there a transaction currently on this thread?- Returns:
 - true if a global transaction is active on the current thread
 
 
- 
isMarkedForRollback
protected boolean isMarkedForRollback(int status)
Has this transaction been marked for rollback?- Returns:
 
 
- 
isNoTransaction
protected boolean isNoTransaction(int status)
Are we in the NO TRANSACTION state?- Parameters:
 status-- Returns:
 
 
- 
getStatus
protected int getStatus() throws FHIRPersistenceDataAccessExceptionGet theStatusof the global transaction- Returns:
 - Throws:
 FHIRPersistenceDataAccessException
 
- 
func
<T> T func(Supplier<T> s) throws FHIRPersistenceException
Call the supplier function within a begin/end- Type Parameters:
 T-- Parameters:
 s-- Returns:
 - Throws:
 FHIRPersistenceException
 
- 
hasBegun
public boolean hasBegun() throws FHIRPersistenceExceptionDescription copied from interface:FHIRPersistenceTransactionDetermine if the transaction status is currently active- Specified by:
 hasBegunin interfaceFHIRPersistenceTransaction- Returns:
 - true if transaction begin has been called
 - Throws:
 FHIRPersistenceException
 
 - 
 
 -