Class FHIRDbTestConnectionStrategy
- java.lang.Object
-
- com.ibm.fhir.persistence.jdbc.connection.FHIRDbTestConnectionStrategy
-
- All Implemented Interfaces:
FHIRDbConnectionStrategy
public class FHIRDbTestConnectionStrategy extends Object implements FHIRDbConnectionStrategy
Hides the logic behind obtaining a JDBCConnectionfrom the DAO code. This strategy object is local to a thread, and because we use the same underlying connection to our test database within a transaction, we only need to configure the connection once. We can track this initialization with nothing more complicated than a Boolean flag. Use by unit tests or other scenarios where connections are obtained using an IConnectionProvider implementation, outside the scope of a JEE container. For example, this is used when connecting to in-memory instances of Derby when running persistence layer unit-tests.
-
-
Constructor Summary
Constructors Constructor Description FHIRDbTestConnectionStrategy(IConnectionProvider cp, Action action)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplySearchOptimizerOptions(Connection c, boolean isCompartment)Apply any optimizer options configured to improve search query performance See issue-1911 for details.ConnectiongetConnection()Get a connection to the desired data source identified by the currentFHIRRequestContextFHIRDbFlavorgetFlavor()Get the flavor of the database we are working with to reveal its capabilitiesQueryHintsgetQueryHints()Append the given hint to FHIR search queries
-
-
-
Constructor Detail
-
FHIRDbTestConnectionStrategy
public FHIRDbTestConnectionStrategy(IConnectionProvider cp, Action action)
Public constructor- Parameters:
cp-action-
-
-
Method Detail
-
getConnection
public Connection getConnection() throws FHIRPersistenceDBConnectException
Description copied from interface:FHIRDbConnectionStrategyGet a connection to the desired data source identified by the currentFHIRRequestContext- Specified by:
getConnectionin interfaceFHIRDbConnectionStrategy- Returns:
- a
Connection. Never null. - Throws:
FHIRPersistenceDBConnectException
-
getFlavor
public FHIRDbFlavor getFlavor() throws FHIRPersistenceDataAccessException
Description copied from interface:FHIRDbConnectionStrategyGet the flavor of the database we are working with to reveal its capabilities- Specified by:
getFlavorin interfaceFHIRDbConnectionStrategy- Returns:
- the datastore/source flavor from the FHIR configuration
- Throws:
FHIRPersistenceDataAccessException- if there is an issue with the configuration
-
getQueryHints
public QueryHints getQueryHints()
Description copied from interface:FHIRDbConnectionStrategyAppend the given hint to FHIR search queries- Specified by:
getQueryHintsin interfaceFHIRDbConnectionStrategy- Returns:
-
applySearchOptimizerOptions
public void applySearchOptimizerOptions(Connection c, boolean isCompartment)
Description copied from interface:FHIRDbConnectionStrategyApply any optimizer options configured to improve search query performance See issue-1911 for details.- Specified by:
applySearchOptimizerOptionsin interfaceFHIRDbConnectionStrategy- Parameters:
c- the connection to be configuredisCompartment- true if the query is a compartment-based search
-
-