Class JdbcCoordinatorImpl
- java.lang.Object
-
- org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl
-
- All Implemented Interfaces:
Serializable,JdbcCoordinator,JdbcResourceTransactionAccess,TransactionCoordinatorOwner
public class JdbcCoordinatorImpl extends Object implements JdbcCoordinator
Standard implementation ofJdbcCoordinator.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JdbcCoordinatorImpl(Connection userSuppliedConnection, JdbcSessionOwner owner, JdbcServices jdbcServices)Constructs aJdbcCoordinatorImpl
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabortBatch()Abort the currently managed batch (if any)voidafterStatementExecution()Used 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.voidafterTransaction()Signals the end of transaction.voidafterTransactionBegin()A after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed)An after-completion callback from the coordinator to its owner.voidbeforeTransactionCompletion()A before-completion callback from the coordinator to its owner.voidcancelLastQuery()Attempt to cancel the last query sent to the JDBC driver.Connectionclose()Close this coordinator and release and resources.protected voidclose(ResultSet resultSet)protected voidclose(Statement statement)voidconditionallyExecuteBatch(BatchKey key)Conditionally 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 hookintdetermineRemainingTransactionTimeOutPeriod()Calculate the amount of time, in seconds, still remaining before transaction timeout occurs.voiddisableReleases()Disable connection releasesvoidenableReleases()Enable connection releasesvoidexecuteBatch()Execute the currently managed batch (if any)voidflushBeforeTransactionCompletion()voidflushBeginning()Callback to let us know that a flush is beginning.voidflushEnding()Callback to let us know that a flush is ending.BatchgetBatch(BatchKey key, Integer batchSize, Supplier<PreparedStatementGroup> statementGroupSupplier)Get the batch for the supplied key, creating one if needed using the supplied statementGroupSupplier.JdbcSessionOwnergetJdbcSessionOwner()LogicalConnectionImplementorgetLogicalConnection()Retrieves the logical connection associated with this JDBC coordinator.MutationStatementPreparergetMutationStatementPreparer()The builder of prepared and callable JDBC statements for mutation operations (insert, update and delete) originating from persistent context events, as opposed to Query handlingJdbcResourceTransactiongetResourceLocalTransaction()Provides 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.ResultSetReturngetResultSetReturn()Obtain theResultSetextractor associated with this JDBC coordinator.StatementPreparergetStatementPreparer()Obtain the statement preparer associated with this JDBC coordinator.booleanisActive()Is the TransactionCoordinator owner considered active?booleanisReadyForSerialization()Can this coordinator be serialized?voidregisterLastQuery(Statement statement)Register a query statement as being able to be cancelled.voidserialize(ObjectOutputStream oos)JDK serialization hookvoidsetTransactionTimeOut(int seconds)Set the effective transaction timeout period for the current transaction, in seconds.SqlExceptionHelpersqlExceptionHelper()Access to theSqlExceptionHelper-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner
startTransactionBoundary
-
-
-
-
Constructor Detail
-
JdbcCoordinatorImpl
public JdbcCoordinatorImpl(Connection userSuppliedConnection, JdbcSessionOwner owner, JdbcServices jdbcServices)
Constructs aJdbcCoordinatorImpl- Parameters:
userSuppliedConnection- The user supplied connection (may be null)
-
-
Method Detail
-
getLogicalConnection
public LogicalConnectionImplementor getLogicalConnection()
Description copied from interface:JdbcCoordinatorRetrieves the logical connection associated with this JDBC coordinator.- Specified by:
getLogicalConnectionin interfaceJdbcCoordinator- Returns:
- The logical connection
-
sqlExceptionHelper
public SqlExceptionHelper 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
public Connection 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:
LogicalConnection.close()
-
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
public void conditionallyExecuteBatch(BatchKey key)
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
public StatementPreparer 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
public MutationStatementPreparer 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
public ResultSetReturn 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
public <T> T coordinateWork(WorkExecutorVisitable<T> work)
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
public void registerLastQuery(Statement statement)
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
-
close
protected void close(Statement statement)
-
close
protected void close(ResultSet resultSet)
-
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:TransactionCoordinatorOwnerA 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
public JdbcSessionOwner getJdbcSessionOwner()
- Specified by:
getJdbcSessionOwnerin interfaceTransactionCoordinatorOwner
-
getResourceLocalTransaction
public JdbcResourceTransaction 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
public void serialize(ObjectOutputStream oos) throws IOException
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
-
-