org.hibernate.engine.jdbc.internal
Class JdbcCoordinatorImpl

java.lang.Object
  extended by org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl
All Implemented Interfaces:
Serializable, JdbcCoordinator

public class JdbcCoordinatorImpl
extends Object
implements JdbcCoordinator

Standard Hibernate implementation of JdbcCoordinator

IMPL NOTE : Custom serialization handling!

See Also:
Serialized Form

Constructor Summary
JdbcCoordinatorImpl(Connection userSuppliedConnection, TransactionCoordinator transactionCoordinator)
           
JdbcCoordinatorImpl(LogicalConnectionImpl logicalConnection, TransactionCoordinator transactionCoordinator)
           
 
Method Summary
 void abortBatch()
          Abort the currently managed batch (if any)
 void afterDeserialize(TransactionCoordinatorImpl transactionCoordinator)
           
 void afterStatementExecution()
          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 afterTransaction()
          Signals the end of transaction.
protected  BatchBuilder batchBuilder()
           
 void cancelLastQuery()
          Attempt to cancel the last query sent to the JDBC driver.
 Connection close()
          Close this coordinator and release and resources.
protected  void close(ResultSet resultSet)
           
protected  void close(Statement statement)
           
protected  void closeAll(Set<ResultSet> resultSets)
           
<T> T
coordinateWork(WorkExecutorVisitable<T> work)
          Perform the requested work handling exceptions, coordinating and handling return processing.
static JdbcCoordinatorImpl deserialize(ObjectInputStream ois, TransactionContext transactionContext)
           
 int determineRemainingTransactionTimeOutPeriod()
          Calculate the amount of time, in seconds, still remaining before transaction timeout occurs.
 void disableReleases()
           
 void enableReleases()
           
 void executeBatch()
          Execute the currently managed batch (if any)
 void flushBeginning()
          Callback to let us know that a flush is beginning.
 void flushEnding()
          Callback to let us know that a flush is ending.
 Batch getBatch(BatchKey key)
          Get a batch instance.
 LogicalConnectionImplementor getLogicalConnection()
          Retrieves the logical connection associated with this JDBC coordinator.
 ResultSetReturn getResultSetReturn()
          Obtain the resultset extractor associated with this JDBC coordinator.
 StatementPreparer getStatementPreparer()
          Obtain the statement preparer associated with this JDBC coordinator.
 TransactionCoordinator getTransactionCoordinator()
          Retrieve the transaction coordinator associated with this JDBC coordinator.
 boolean hasRegisteredResources()
          Does this registry currently have any registered resources?
 boolean isReadyForSerialization()
           
 void register(ResultSet resultSet, Statement statement)
          Register a JDBC result set.
 void register(Statement statement)
          Register a JDBC statement.
 void registerLastQuery(Statement statement)
          Register a query statement as being able to be cancelled.
 void release(ResultSet resultSet, Statement statement)
          Release a previously registered result set.
 void release(Statement statement)
          Release a previously registered statement.
 void releaseResources()
          Release all registered resources.
 void serialize(ObjectOutputStream oos)
           
protected  SessionFactoryImplementor sessionFactory()
           
 void setTransactionTimeOut(int seconds)
          Set the effective transaction timeout period for the current transaction, in seconds.
 SqlExceptionHelper sqlExceptionHelper()
           
protected  TransactionEnvironment transactionEnvironment()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcCoordinatorImpl

public JdbcCoordinatorImpl(Connection userSuppliedConnection,
                           TransactionCoordinator transactionCoordinator)

JdbcCoordinatorImpl

public JdbcCoordinatorImpl(LogicalConnectionImpl logicalConnection,
                           TransactionCoordinator transactionCoordinator)
Method Detail

getTransactionCoordinator

public TransactionCoordinator getTransactionCoordinator()
Description copied from interface: JdbcCoordinator
Retrieve the transaction coordinator associated with this JDBC coordinator.

Specified by:
getTransactionCoordinator in interface JdbcCoordinator
Returns:
The transaction coordinator

getLogicalConnection

public LogicalConnectionImplementor getLogicalConnection()
Description copied from interface: JdbcCoordinator
Retrieves the logical connection associated with this JDBC coordinator.

Specified by:
getLogicalConnection in interface JdbcCoordinator
Returns:
The logical connection

transactionEnvironment

protected TransactionEnvironment transactionEnvironment()

sessionFactory

protected SessionFactoryImplementor sessionFactory()

batchBuilder

protected BatchBuilder batchBuilder()

sqlExceptionHelper

public SqlExceptionHelper 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 complete JdbcCoordinator.flushEnding()

Specified by:
flushBeginning in interface JdbcCoordinator

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 interface JdbcCoordinator

close

public Connection close()
Description copied from interface: JdbcCoordinator
Close this coordinator and release and resources.

Specified by:
close in interface JdbcCoordinator
Returns:
The Connection associated with the managed logical connection
See Also:
LogicalConnection.close()

getBatch

public Batch getBatch(BatchKey key)
Description copied from interface: JdbcCoordinator
Get a batch instance.

Specified by:
getBatch in interface JdbcCoordinator
Parameters:
key - The unique batch key.
Returns:
The batch

executeBatch

public void executeBatch()
Description copied from interface: JdbcCoordinator
Execute the currently managed batch (if any)

Specified by:
executeBatch in interface JdbcCoordinator

abortBatch

public void abortBatch()
Description copied from interface: JdbcCoordinator
Abort the currently managed batch (if any)

Specified by:
abortBatch in interface JdbcCoordinator

getStatementPreparer

public StatementPreparer getStatementPreparer()
Description copied from interface: JdbcCoordinator
Obtain the statement preparer associated with this JDBC coordinator.

Specified by:
getStatementPreparer in interface JdbcCoordinator
Returns:
This coordinator's statement preparer

getResultSetReturn

public ResultSetReturn getResultSetReturn()
Description copied from interface: JdbcCoordinator
Obtain the resultset extractor associated with this JDBC coordinator.

Specified by:
getResultSetReturn in interface JdbcCoordinator
Returns:
This coordinator's resultset extractor

setTransactionTimeOut

public void setTransactionTimeOut(int seconds)
Description copied from interface: JdbcCoordinator
Set the effective transaction timeout period for the current transaction, in seconds.

Specified by:
setTransactionTimeOut in interface JdbcCoordinator
Parameters:
seconds - The number of seconds before a time out should occur.

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 interface JdbcCoordinator
Returns:
The number of seconds remaining until 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 interface JdbcCoordinator

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 interface JdbcCoordinator

coordinateWork

public <T> T coordinateWork(WorkExecutorVisitable<T> work)
Description copied from interface: JdbcCoordinator
Perform the requested work handling exceptions, coordinating and handling return processing.

Specified by:
coordinateWork in interface JdbcCoordinator
Type Parameters:
T - The result type.
Parameters:
work - The work to be performed.
Returns:
The work result.

isReadyForSerialization

public boolean isReadyForSerialization()
Specified by:
isReadyForSerialization in interface JdbcCoordinator

serialize

public void serialize(ObjectOutputStream oos)
               throws IOException
Throws:
IOException

deserialize

public static JdbcCoordinatorImpl deserialize(ObjectInputStream ois,
                                              TransactionContext transactionContext)
                                       throws IOException,
                                              ClassNotFoundException
Throws:
IOException
ClassNotFoundException

afterDeserialize

public void afterDeserialize(TransactionCoordinatorImpl transactionCoordinator)

register

public void register(Statement statement)
Description copied from interface: JdbcCoordinator
Register a JDBC statement.

Specified by:
register in interface JdbcCoordinator
Parameters:
statement - The statement to register.

registerLastQuery

public void registerLastQuery(Statement statement)
Description copied from interface: JdbcCoordinator
Register a query statement as being able to be cancelled.

Specified by:
registerLastQuery in interface JdbcCoordinator
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 interface JdbcCoordinator

release

public void release(Statement statement)
Description copied from interface: JdbcCoordinator
Release a previously registered statement.

Specified by:
release in interface JdbcCoordinator
Parameters:
statement - The statement to release.

register

public void register(ResultSet resultSet,
                     Statement statement)
Description copied from interface: JdbcCoordinator
Register a JDBC result set.

Implementation note: Second parameter has been introduced to prevent multiple registrations of the same statement in case ResultSet.getStatement() does not return original Statement object.

Specified by:
register in interface JdbcCoordinator
Parameters:
resultSet - The result set to register.
statement - Statement from which ResultSet has been generated.

release

public void release(ResultSet resultSet,
                    Statement statement)
Description copied from interface: JdbcCoordinator
Release a previously registered result set.

Specified by:
release in interface JdbcCoordinator
Parameters:
resultSet - The result set to release.
statement - Statement from which ResultSet has been generated.

hasRegisteredResources

public boolean hasRegisteredResources()
Description copied from interface: JdbcCoordinator
Does this registry currently have any registered resources?

Specified by:
hasRegisteredResources in interface JdbcCoordinator
Returns:
True if the registry does have registered resources; false otherwise.

releaseResources

public void releaseResources()
Description copied from interface: JdbcCoordinator
Release all registered resources.

Specified by:
releaseResources in interface JdbcCoordinator

enableReleases

public void enableReleases()
Specified by:
enableReleases in interface JdbcCoordinator

disableReleases

public void disableReleases()
Specified by:
disableReleases in interface JdbcCoordinator

closeAll

protected void closeAll(Set<ResultSet> resultSets)

close

protected void close(Statement statement)

close

protected void close(ResultSet resultSet)


Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.