Class FHIRTestTransactionAdapter
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.connection.FHIRTestTransactionAdapter
-
- All Implemented Interfaces:
FHIRPersistenceTransaction
public class FHIRTestTransactionAdapter extends java.lang.Object implements FHIRPersistenceTransaction
Hides the logic behind obtaining a JDBCConnectionfrom the DAO code. Use by unit tests or other scenarios where connections are obtained using an IConnectionProvider implementation, outside the scope of a JEE container. Transactions are managed with the help of the SimpleTransactionProvider and wrapped by this class, meaning we have a uniform interface for handling transactions across JEE and unit-test scenarios.
-
-
Constructor Summary
Constructors Constructor Description FHIRTestTransactionAdapter(IConnectionProvider cp, IFHIRTransactionAdapterCallback beforeCommitCallback)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()Begin a new transaction on the current thread if a transaction is not started yet.voidend()End the current thread's transaction.booleanhasBegun()Determine if the transaction status is currently activevoidsetRollbackOnly()Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.linuxforhealth.fhir.persistence.FHIRPersistenceTransaction
isTransactional
-
-
-
-
Constructor Detail
-
FHIRTestTransactionAdapter
public FHIRTestTransactionAdapter(IConnectionProvider cp, IFHIRTransactionAdapterCallback beforeCommitCallback)
Public constructor- Parameters:
cp-beforeCommit- callback before transaction commit, can be null
-
-
Method Detail
-
begin
public void begin() throws FHIRPersistenceExceptionDescription copied from interface:FHIRPersistenceTransactionBegin a new transaction on the current thread if a transaction is not started yet.- Specified by:
beginin interfaceFHIRPersistenceTransaction- Throws:
FHIRPersistenceException
-
end
public void end() throws FHIRPersistenceExceptionDescription copied from interface:FHIRPersistenceTransactionEnd the current thread's transaction. If setRollbackOnly has been called, then roll back the transaction instead. This call only affects the current transaction if this object actually started the transaction (i.e. is the outermost instance of a transaction).- 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
-
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
-
-