Class JdbcCoordinatorImpl
java.lang.Object
org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl
- All Implemented Interfaces:
Serializable,JdbcCoordinator,JdbcResourceTransactionAccess,TransactionCoordinatorOwner
Standard implementation of
JdbcCoordinator.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJdbcCoordinatorImpl(Connection userSuppliedConnection, JdbcSessionOwner owner, JdbcServices jdbcServices) Constructs aJdbcCoordinatorImpl -
Method Summary
Modifier and TypeMethodDescriptionvoidAbort the currently managed batch (if any)voidUsed to signify that a statement has completed execution which may indicate that this logical connection need to perform an aggressive release of its physical connection.voidSignals the end of transaction.voidAn after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed) An after-completion callback from the coordinator to its owner.voidA before-completion callback from the coordinator to its owner.voidAttempt to cancel the last query sent to the JDBC driver.close()Close this coordinator and release and resources.voidConditionally execute the currently managed batch (if any), if the keys do not match<T> TcoordinateWork(WorkExecutorVisitable<T> work) Perform the requested work handling exceptions, coordinating and handling return processing.static JdbcCoordinatorImpldeserialize(ObjectInputStream ois, JdbcSessionOwner owner) JDK deserialization hookintCalculate the amount of time, in seconds, still remaining before transaction timeout occurs.voidDisable connection releasesvoidEnable connection releasesvoidExecute the currently managed batch (if any)voidvoidCallback to let us know that a flush is beginning.voidCallback to let us know that a flush is ending.getBatch(BatchKey key, Integer batchSize, Supplier<PreparedStatementGroup> statementGroupSupplier) Get the batch for the supplied key, creating one if needed using the supplied statementGroupSupplier.Retrieves the logical connection associated with this JDBC coordinator.The builder of prepared and callable JDBC statements for mutation operations (insert, update and delete) originating from persistent context events, as opposed to Query handlingProvides access to the resource local transaction of this data store, which is used by theTransactionCoordinatorto manage transactions against the data store when not using JTA.Obtain theResultSetextractor associated with this JDBC coordinator.Obtain the statement preparer associated with this JDBC coordinator.booleanisActive()Is the TransactionCoordinator owner considered active?booleanCan this coordinator be serialized?voidregisterLastQuery(Statement statement) Register a query statement as being able to be cancelled.voidJDK serialization hookvoidsetTransactionTimeOut(int seconds) Set the effective transaction timeout period for the current transaction, in seconds.Access to theSqlExceptionHelperMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner
startTransactionBoundary
-
Constructor Details
-
JdbcCoordinatorImpl
public JdbcCoordinatorImpl(Connection userSuppliedConnection, JdbcSessionOwner owner, JdbcServices jdbcServices) Constructs aJdbcCoordinatorImpl- Parameters:
userSuppliedConnection- The user supplied connection (may be null)
-
-
Method Details
-
getLogicalConnection
Description copied from interface:JdbcCoordinatorRetrieves the logical connection associated with this JDBC coordinator.- Specified by:
getLogicalConnectionin interfaceJdbcCoordinator- Returns:
- The logical connection
-
sqlExceptionHelper
Access to theSqlExceptionHelper- Returns:
- The
SqlExceptionHelper
-
flushBeginning
public void flushBeginning()Description copied from interface:JdbcCoordinatorCallback to let us know that a flush is beginning. We use this fact to temporarily circumvent aggressive connection releasing until after the flush cycle is completeJdbcCoordinator.flushEnding()- Specified by:
flushBeginningin interfaceJdbcCoordinator
-
flushEnding
public void flushEnding()Description copied from interface:JdbcCoordinatorCallback to let us know that a flush is ending. We use this fact to stop circumventing aggressive releasing connections.- Specified by:
flushEndingin interfaceJdbcCoordinator
-
close
Description copied from interface:JdbcCoordinatorClose this coordinator and release and resources.- Specified by:
closein interfaceJdbcCoordinator- Returns:
- The
Connectionassociated with the managedlogical connection - See Also:
-
getBatch
public Batch getBatch(BatchKey key, Integer batchSize, Supplier<PreparedStatementGroup> statementGroupSupplier) Description copied from interface:JdbcCoordinatorGet the batch for the supplied key, creating one if needed using the supplied statementGroupSupplier.- Specified by:
getBatchin interfaceJdbcCoordinator
-
executeBatch
public void executeBatch()Description copied from interface:JdbcCoordinatorExecute the currently managed batch (if any)- Specified by:
executeBatchin interfaceJdbcCoordinator
-
conditionallyExecuteBatch
Description copied from interface:JdbcCoordinatorConditionally execute the currently managed batch (if any), if the keys do not match- Specified by:
conditionallyExecuteBatchin interfaceJdbcCoordinator
-
abortBatch
public void abortBatch()Description copied from interface:JdbcCoordinatorAbort the currently managed batch (if any)- Specified by:
abortBatchin interfaceJdbcCoordinator
-
getStatementPreparer
Description copied from interface:JdbcCoordinatorObtain the statement preparer associated with this JDBC coordinator.- Specified by:
getStatementPreparerin interfaceJdbcCoordinator- Returns:
- This coordinator's statement preparer
-
getMutationStatementPreparer
Description copied from interface:JdbcCoordinatorThe builder of prepared and callable JDBC statements for mutation operations (insert, update and delete) originating from persistent context events, as opposed to Query handling- Specified by:
getMutationStatementPreparerin interfaceJdbcCoordinator
-
getResultSetReturn
Description copied from interface:JdbcCoordinatorObtain theResultSetextractor associated with this JDBC coordinator.- Specified by:
getResultSetReturnin interfaceJdbcCoordinator- Returns:
- This coordinator's resultset extractor
-
setTransactionTimeOut
public void setTransactionTimeOut(int seconds) Description copied from interface:TransactionCoordinatorOwnerSet the effective transaction timeout period for the current transaction, in seconds.- Specified by:
setTransactionTimeOutin interfaceTransactionCoordinatorOwner- Parameters:
seconds- The number of seconds before a time out should occur.
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()- Specified by:
flushBeforeTransactionCompletionin interfaceTransactionCoordinatorOwner
-
determineRemainingTransactionTimeOutPeriod
public int determineRemainingTransactionTimeOutPeriod()Description copied from interface:JdbcCoordinatorCalculate the amount of time, in seconds, still remaining before transaction timeout occurs.- Specified by:
determineRemainingTransactionTimeOutPeriodin interfaceJdbcCoordinator- Returns:
- The number of seconds remaining until a transaction timeout occurs. A negative value indicates no timeout was requested.
-
afterStatementExecution
public void afterStatementExecution()Description copied from interface:JdbcCoordinatorUsed to signify that a statement has completed execution which may indicate that this logical connection need to perform an aggressive release of its physical connection.- Specified by:
afterStatementExecutionin interfaceJdbcCoordinator
-
afterTransaction
public void afterTransaction()Description copied from interface:JdbcCoordinatorSignals the end of transaction.Intended for use from the transaction coordinator, after local transaction completion. Used to conditionally release the JDBC connection aggressively if the configured release mode indicates.
- Specified by:
afterTransactionin interfaceJdbcCoordinator
-
coordinateWork
Description copied from interface:JdbcCoordinatorPerform the requested work handling exceptions, coordinating and handling return processing.- Specified by:
coordinateWorkin interfaceJdbcCoordinator- Type Parameters:
T- The result type.- Parameters:
work- The work to be performed.- Returns:
- The work result.
-
isReadyForSerialization
public boolean isReadyForSerialization()Description copied from interface:JdbcCoordinatorCan this coordinator be serialized?- Specified by:
isReadyForSerializationin interfaceJdbcCoordinator- Returns:
trueindicates the coordinator can be serialized.
-
registerLastQuery
Description copied from interface:JdbcCoordinatorRegister a query statement as being able to be cancelled.- Specified by:
registerLastQueryin interfaceJdbcCoordinator- Parameters:
statement- The cancel-able query statement.
-
cancelLastQuery
public void cancelLastQuery()Description copied from interface:JdbcCoordinatorAttempt to cancel the last query sent to the JDBC driver.- Specified by:
cancelLastQueryin interfaceJdbcCoordinator
-
enableReleases
public void enableReleases()Description copied from interface:JdbcCoordinatorEnable connection releases- Specified by:
enableReleasesin interfaceJdbcCoordinator
-
disableReleases
public void disableReleases()Description copied from interface:JdbcCoordinatorDisable connection releases- Specified by:
disableReleasesin interfaceJdbcCoordinator
-
isActive
public boolean isActive()Description copied from interface:TransactionCoordinatorOwnerIs the TransactionCoordinator owner considered active?- Specified by:
isActivein interfaceTransactionCoordinatorOwner- Returns:
trueindicates the owner is still active;falseindicates it is not.
-
afterTransactionBegin
public void afterTransactionBegin()Description copied from interface:TransactionCoordinatorOwnerAn after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBeginin interfaceTransactionCoordinatorOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()Description copied from interface:TransactionCoordinatorOwnerA before-completion callback from the coordinator to its owner.- Specified by:
beforeTransactionCompletionin interfaceTransactionCoordinatorOwner
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed) Description copied from interface:TransactionCoordinatorOwnerAn after-completion callback from the coordinator to its owner.- Specified by:
afterTransactionCompletionin interfaceTransactionCoordinatorOwner- Parameters:
successful- Was the transaction successful?delayed- Is this delayed after transaction completion call (aka after a timeout)?
-
getJdbcSessionOwner
- Specified by:
getJdbcSessionOwnerin interfaceTransactionCoordinatorOwner
-
getResourceLocalTransaction
Description copied from interface:JdbcResourceTransactionAccessProvides access to the resource local transaction of this data store, which is used by theTransactionCoordinatorto manage transactions against the data store when not using JTA.- Specified by:
getResourceLocalTransactionin interfaceJdbcResourceTransactionAccess- Returns:
- The resource-local transaction
-
serialize
JDK serialization hook- Specified by:
serializein interfaceJdbcCoordinator- Parameters:
oos- The stream into which to write our state- Throws:
IOException- Trouble accessing the stream
-
deserialize
public static JdbcCoordinatorImpl deserialize(ObjectInputStream ois, JdbcSessionOwner owner) throws IOException, ClassNotFoundException JDK deserialization hook- Parameters:
ois- The stream into which to write our stateowner- The Jdbc Session owner which owns the JdbcCoordinatorImpl to be deserialized.- Returns:
- The deserialized
JdbcCoordinatorImpl - Throws:
IOException- Trouble accessing the streamClassNotFoundException- Trouble reading the stream
-