Class LogicalConnectionManagedImpl
- java.lang.Object
-
- org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor
-
- org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl
-
- All Implemented Interfaces:
LogicalConnection,LogicalConnectionImplementor,PhysicalJdbcTransaction,JdbcResourceTransaction
public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImplementor
Represents a LogicalConnection where we manage obtaining and releasing the Connection as needed. This implementation does not claim to be thread-safe and is not designed to be used by multiple threads, yet we do apply a limited amount of care to be able to void obscure exceptions when this class is used in the wrong way.
-
-
Field Summary
-
Fields inherited from class org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor
resourceRegistry
-
-
Constructor Summary
Constructors Constructor Description LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, SqlExceptionHelper sqlExceptionHelper, ResourceRegistry resourceRegistry)LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, ResourceRegistry resourceRegistry, JdbcServices jdbcServices)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterCompletion()voidafterStatement()Notification indicating a JDBC statement has been executed, to triggerConnectionReleaseMode.AFTER_STATEMENTreleasing if needed.voidafterTransaction()Notification indicating a transaction has just completed, to triggerConnectionReleaseMode.AFTER_TRANSACTIONreleasing if needed.voidbeforeTransactionCompletion()Notification indicating a transaction is about to be completed, to trigger release of the JDBC connection if needed, that is, ifConnectionReleaseMode.BEFORE_TRANSACTION_COMPLETIONis enabled.voidbegin()Begin the resource transactionConnectionclose()Closes the logical connection, making it inactive and forcing release of any held resources.static LogicalConnectionManagedImpldeserialize(ObjectInputStream ois, JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext)protected booleandoConnectionsFromProviderHaveAutoCommitDisabled()protected ConnectiongetConnectionForTransactionManagement()PhysicalConnectionHandlingModegetConnectionHandlingMode()ConnectiongetPhysicalConnection()Exposes access to the "real"Connection.booleanisOpen()Is this (logical) JDBC connection still open/active?booleanisPhysicallyConnected()Is this logical connection currently physically connected?ConnectionmanualDisconnect()Manually disconnect the underlying JDBC Connection.voidmanualReconnect(Connection suppliedConnection)Manually reconnect the underlying JDBC Connection.voidserialize(ObjectOutputStream oos)Serialization hook.-
Methods inherited from class org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor
commit, determineInitialAutoCommitMode, errorIfClosed, getPhysicalJdbcTransaction, getResourceRegistry, getStatus, resetConnection, rollback
-
-
-
-
Constructor Detail
-
LogicalConnectionManagedImpl
public LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, SqlExceptionHelper sqlExceptionHelper, ResourceRegistry resourceRegistry)
-
LogicalConnectionManagedImpl
public LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, ResourceRegistry resourceRegistry, JdbcServices jdbcServices)
-
-
Method Detail
-
isOpen
public boolean isOpen()
Description copied from interface:LogicalConnectionIs this (logical) JDBC connection still open/active?That is, has
LogicalConnection.close()not yet been called?- Returns:
trueif still open, sinceLogicalConnection.close()has not yet been called;falseif not open, sinceLogicalConnection.close()was called.
-
getConnectionHandlingMode
public PhysicalConnectionHandlingMode getConnectionHandlingMode()
-
isPhysicallyConnected
public boolean isPhysicallyConnected()
Description copied from interface:LogicalConnectionIs this logical connection currently physically connected?That is, does it currently hold a physical JDBC
Connection?- Returns:
trueif currently holding a JDBCConnection;falseif not.
-
getPhysicalConnection
public Connection getPhysicalConnection()
Description copied from interface:LogicalConnectionImplementorExposes access to the "real"Connection.- Returns:
- The connection
-
afterStatement
public void afterStatement()
Description copied from interface:LogicalConnectionImplementorNotification indicating a JDBC statement has been executed, to triggerConnectionReleaseMode.AFTER_STATEMENTreleasing if needed.- Specified by:
afterStatementin interfaceLogicalConnectionImplementor- Overrides:
afterStatementin classAbstractLogicalConnectionImplementor
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:LogicalConnectionImplementorNotification indicating a transaction is about to be completed, to trigger release of the JDBC connection if needed, that is, ifConnectionReleaseMode.BEFORE_TRANSACTION_COMPLETIONis enabled.- Specified by:
beforeTransactionCompletionin interfaceLogicalConnectionImplementor- Overrides:
beforeTransactionCompletionin classAbstractLogicalConnectionImplementor
-
afterTransaction
public void afterTransaction()
Description copied from interface:LogicalConnectionImplementorNotification indicating a transaction has just completed, to triggerConnectionReleaseMode.AFTER_TRANSACTIONreleasing if needed.- Specified by:
afterTransactionin interfaceLogicalConnectionImplementor- Overrides:
afterTransactionin classAbstractLogicalConnectionImplementor
-
manualDisconnect
public Connection manualDisconnect()
Description copied from interface:LogicalConnectionImplementorManually disconnect the underlying JDBC Connection. The assumption here is that the manager will be reconnected at a later point in time.- Returns:
- The connection maintained here at time of disconnect.
nullif there was no connection cached internally.
-
manualReconnect
public void manualReconnect(Connection suppliedConnection)
Description copied from interface:LogicalConnectionImplementorManually reconnect the underlying JDBC Connection. Should be called at some point afterLogicalConnectionImplementor.manualDisconnect().- Parameters:
suppliedConnection- For user supplied connection strategy the user needs to hand us the connection with which to reconnect. It is an error to pass a connection in the other strategies.
-
serialize
public void serialize(ObjectOutputStream oos) throws IOException
Description copied from interface:LogicalConnectionImplementorSerialization hook.- Parameters:
oos- The stream to write out state to- Throws:
IOException- Problem accessing stream
-
deserialize
public static LogicalConnectionManagedImpl deserialize(ObjectInputStream ois, JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext) throws IOException
- Throws:
IOException
-
close
public Connection close()
Description copied from interface:LogicalConnectionCloses the logical connection, making it inactive and forcing release of any held resources.- Returns:
- the JDBC
Connectionif the user passed in aConnectionoriginally
-
getConnectionForTransactionManagement
protected Connection getConnectionForTransactionManagement()
- Specified by:
getConnectionForTransactionManagementin classAbstractLogicalConnectionImplementor
-
begin
public void begin()
Description copied from interface:JdbcResourceTransactionBegin the resource transaction- Specified by:
beginin interfaceJdbcResourceTransaction- Overrides:
beginin classAbstractLogicalConnectionImplementor
-
afterCompletion
protected void afterCompletion()
- Overrides:
afterCompletionin classAbstractLogicalConnectionImplementor
-
doConnectionsFromProviderHaveAutoCommitDisabled
protected boolean doConnectionsFromProviderHaveAutoCommitDisabled()
- Overrides:
doConnectionsFromProviderHaveAutoCommitDisabledin classAbstractLogicalConnectionImplementor
-
-