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 TypeMethodDescriptionvoid
Abort the currently managed batch (if any)void
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.void
Signals the end of transaction.void
An after-begin callback from the coordinator to its owner.void
afterTransactionCompletion
(boolean successful, boolean delayed) An after-completion callback from the coordinator to its owner.void
A before-completion callback from the coordinator to its owner.void
Attempt to cancel the last query sent to the JDBC driver.close()
Close this coordinator and release and resources.void
Conditionally execute the currently managed batch (if any), if the keys do not match<T> T
coordinateWork
(WorkExecutorVisitable<T> work) Perform the requested work handling exceptions, coordinating and handling return processing.static JdbcCoordinatorImpl
deserialize
(ObjectInputStream ois, JdbcSessionOwner owner) JDK deserialization hookint
Calculate the amount of time, in seconds, still remaining before transaction timeout occurs.void
Disable connection releasesvoid
Enable connection releasesvoid
Execute the currently managed batch (if any)void
void
Callback to let us know that a flush is beginning.void
Callback 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 theTransactionCoordinator
to manage transactions against the data store when not using JTA.Obtain theResultSet
extractor associated with this JDBC coordinator.Obtain the statement preparer associated with this JDBC coordinator.boolean
isActive()
Is the TransactionCoordinator owner considered active?boolean
Can this coordinator be serialized?void
registerLastQuery
(Statement statement) Register a query statement as being able to be cancelled.void
JDK serialization hookvoid
setTransactionTimeOut
(int seconds) Set the effective transaction timeout period for the current transaction, in seconds.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 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:JdbcCoordinator
Retrieves the logical connection associated with this JDBC coordinator.- Specified by:
getLogicalConnection
in interfaceJdbcCoordinator
- Returns:
- The logical connection
-
sqlExceptionHelper
Access to theSqlExceptionHelper
- Returns:
- The
SqlExceptionHelper
-
flushBeginning
public void flushBeginning()Description copied from interface:JdbcCoordinator
Callback 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:
flushBeginning
in interfaceJdbcCoordinator
-
flushEnding
public void flushEnding()Description copied from interface:JdbcCoordinator
Callback to let us know that a flush is ending. We use this fact to stop circumventing aggressive releasing connections.- Specified by:
flushEnding
in interfaceJdbcCoordinator
-
close
Description copied from interface:JdbcCoordinator
Close this coordinator and release and resources.- Specified by:
close
in interfaceJdbcCoordinator
- Returns:
- The
Connection
associated with the managedlogical connection
- See Also:
-
getBatch
public Batch getBatch(BatchKey key, Integer batchSize, Supplier<PreparedStatementGroup> statementGroupSupplier) Description copied from interface:JdbcCoordinator
Get the batch for the supplied key, creating one if needed using the supplied statementGroupSupplier.- Specified by:
getBatch
in interfaceJdbcCoordinator
-
executeBatch
public void executeBatch()Description copied from interface:JdbcCoordinator
Execute the currently managed batch (if any)- Specified by:
executeBatch
in interfaceJdbcCoordinator
-
conditionallyExecuteBatch
Description copied from interface:JdbcCoordinator
Conditionally execute the currently managed batch (if any), if the keys do not match- Specified by:
conditionallyExecuteBatch
in interfaceJdbcCoordinator
-
abortBatch
public void abortBatch()Description copied from interface:JdbcCoordinator
Abort the currently managed batch (if any)- Specified by:
abortBatch
in interfaceJdbcCoordinator
-
getStatementPreparer
Description copied from interface:JdbcCoordinator
Obtain the statement preparer associated with this JDBC coordinator.- Specified by:
getStatementPreparer
in interfaceJdbcCoordinator
- Returns:
- This coordinator's statement preparer
-
getMutationStatementPreparer
Description copied from interface:JdbcCoordinator
The 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:
getMutationStatementPreparer
in interfaceJdbcCoordinator
-
getResultSetReturn
Description copied from interface:JdbcCoordinator
Obtain theResultSet
extractor associated with this JDBC coordinator.- Specified by:
getResultSetReturn
in interfaceJdbcCoordinator
- Returns:
- This coordinator's resultset extractor
-
setTransactionTimeOut
public void setTransactionTimeOut(int seconds) Description copied from interface:TransactionCoordinatorOwner
Set the effective transaction timeout period for the current transaction, in seconds.- Specified by:
setTransactionTimeOut
in interfaceTransactionCoordinatorOwner
- Parameters:
seconds
- The number of seconds before a time out should occur.
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()- Specified by:
flushBeforeTransactionCompletion
in interfaceTransactionCoordinatorOwner
-
determineRemainingTransactionTimeOutPeriod
public int determineRemainingTransactionTimeOutPeriod()Description copied from interface:JdbcCoordinator
Calculate the amount of time, in seconds, still remaining before transaction timeout occurs.- Specified by:
determineRemainingTransactionTimeOutPeriod
in 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:JdbcCoordinator
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.- Specified by:
afterStatementExecution
in interfaceJdbcCoordinator
-
afterTransaction
public void afterTransaction()Description copied from interface:JdbcCoordinator
Signals 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:
afterTransaction
in interfaceJdbcCoordinator
-
coordinateWork
Description copied from interface:JdbcCoordinator
Perform the requested work handling exceptions, coordinating and handling return processing.- Specified by:
coordinateWork
in 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:JdbcCoordinator
Can this coordinator be serialized?- Specified by:
isReadyForSerialization
in interfaceJdbcCoordinator
- Returns:
true
indicates the coordinator can be serialized.
-
registerLastQuery
Description copied from interface:JdbcCoordinator
Register a query statement as being able to be cancelled.- Specified by:
registerLastQuery
in interfaceJdbcCoordinator
- Parameters:
statement
- The cancel-able query statement.
-
cancelLastQuery
public void cancelLastQuery()Description copied from interface:JdbcCoordinator
Attempt to cancel the last query sent to the JDBC driver.- Specified by:
cancelLastQuery
in interfaceJdbcCoordinator
-
enableReleases
public void enableReleases()Description copied from interface:JdbcCoordinator
Enable connection releases- Specified by:
enableReleases
in interfaceJdbcCoordinator
-
disableReleases
public void disableReleases()Description copied from interface:JdbcCoordinator
Disable connection releases- Specified by:
disableReleases
in interfaceJdbcCoordinator
-
isActive
public boolean isActive()Description copied from interface:TransactionCoordinatorOwner
Is the TransactionCoordinator owner considered active?- Specified by:
isActive
in interfaceTransactionCoordinatorOwner
- Returns:
true
indicates the owner is still active;false
indicates it is not.
-
afterTransactionBegin
public void afterTransactionBegin()Description copied from interface:TransactionCoordinatorOwner
An after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBegin
in interfaceTransactionCoordinatorOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()Description copied from interface:TransactionCoordinatorOwner
A before-completion callback from the coordinator to its owner.- Specified by:
beforeTransactionCompletion
in interfaceTransactionCoordinatorOwner
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed) Description copied from interface:TransactionCoordinatorOwner
An after-completion callback from the coordinator to its owner.- Specified by:
afterTransactionCompletion
in interfaceTransactionCoordinatorOwner
- Parameters:
successful
- Was the transaction successful?delayed
- Is this delayed after transaction completion call (aka after a timeout)?
-
getJdbcSessionOwner
- Specified by:
getJdbcSessionOwner
in interfaceTransactionCoordinatorOwner
-
getResourceLocalTransaction
Description copied from interface:JdbcResourceTransactionAccess
Provides access to the resource local transaction of this data store, which is used by theTransactionCoordinator
to manage transactions against the data store when not using JTA.- Specified by:
getResourceLocalTransaction
in interfaceJdbcResourceTransactionAccess
- Returns:
- The resource-local transaction
-
serialize
JDK serialization hook- Specified by:
serialize
in 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
-