Class LogicalConnectionManagedImpl
java.lang.Object
org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor
org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl
- All Implemented Interfaces:
LogicalConnection
,LogicalConnectionImplementor
,PhysicalJdbcTransaction
,JdbcResourceTransaction
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 avoid 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
ConstructorsConstructorDescriptionLogicalConnectionManagedImpl
(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, SqlExceptionHelper sqlExceptionHelper, ResourceRegistry resourceRegistry) LogicalConnectionManagedImpl
(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, ResourceRegistry resourceRegistry, JdbcServices jdbcServices) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
Notification indicating a JDBC statement has been executed, to triggerConnectionReleaseMode.AFTER_STATEMENT
releasing if needed.void
Notification indicating a transaction has just completed, to triggerConnectionReleaseMode.AFTER_TRANSACTION
releasing if needed.void
Notification indicating a transaction is about to be completed, to trigger release of the JDBC connection if needed, that is, ifConnectionReleaseMode.BEFORE_TRANSACTION_COMPLETION
is enabled.void
begin()
Begin the resource transactionclose()
Closes the logical connection, making it inactive and forcing release of any held resources.static LogicalConnectionManagedImpl
deserialize
(ObjectInputStream ois, JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext) protected boolean
protected Connection
Exposes access to the "real"Connection
.boolean
isOpen()
Is this (logical) JDBC connection still open/active?boolean
Is this logical connection currently physically connected?Manually disconnect the underlying JDBC Connection.void
manualReconnect
(Connection suppliedConnection) Manually reconnect the underlying JDBC Connection.void
Serialization hook.Methods inherited from class org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor
commit, determineInitialAutoCommitMode, errorIfClosed, getPhysicalJdbcTransaction, getResourceRegistry, getStatus, resetConnection, rollback
-
Constructor Details
-
LogicalConnectionManagedImpl
public LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, SqlExceptionHelper sqlExceptionHelper, ResourceRegistry resourceRegistry) -
LogicalConnectionManagedImpl
public LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, ResourceRegistry resourceRegistry, JdbcServices jdbcServices)
-
-
Method Details
-
isOpen
public boolean isOpen()Description copied from interface:LogicalConnection
Is this (logical) JDBC connection still open/active?That is, has
LogicalConnection.close()
not yet been called?- Returns:
true
if still open, sinceLogicalConnection.close()
has not yet been called;false
if not open, sinceLogicalConnection.close()
was called.
-
getConnectionHandlingMode
-
isPhysicallyConnected
public boolean isPhysicallyConnected()Description copied from interface:LogicalConnection
Is this logical connection currently physically connected?That is, does it currently hold a physical JDBC
Connection
?- Returns:
true
if currently holding a JDBCConnection
;false
if not.
-
getPhysicalConnection
Description copied from interface:LogicalConnectionImplementor
Exposes access to the "real"Connection
.- Returns:
- The connection
-
afterStatement
public void afterStatement()Description copied from interface:LogicalConnectionImplementor
Notification indicating a JDBC statement has been executed, to triggerConnectionReleaseMode.AFTER_STATEMENT
releasing if needed.- Specified by:
afterStatement
in interfaceLogicalConnectionImplementor
- Overrides:
afterStatement
in classAbstractLogicalConnectionImplementor
-
beforeTransactionCompletion
public void beforeTransactionCompletion()Description copied from interface:LogicalConnectionImplementor
Notification indicating a transaction is about to be completed, to trigger release of the JDBC connection if needed, that is, ifConnectionReleaseMode.BEFORE_TRANSACTION_COMPLETION
is enabled.- Specified by:
beforeTransactionCompletion
in interfaceLogicalConnectionImplementor
- Overrides:
beforeTransactionCompletion
in classAbstractLogicalConnectionImplementor
-
afterTransaction
public void afterTransaction()Description copied from interface:LogicalConnectionImplementor
Notification indicating a transaction has just completed, to triggerConnectionReleaseMode.AFTER_TRANSACTION
releasing if needed.- Specified by:
afterTransaction
in interfaceLogicalConnectionImplementor
- Overrides:
afterTransaction
in classAbstractLogicalConnectionImplementor
-
manualDisconnect
Description copied from interface:LogicalConnectionImplementor
Manually 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.
null
if there was no connection cached internally.
-
manualReconnect
Description copied from interface:LogicalConnectionImplementor
Manually 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
Description copied from interface:LogicalConnectionImplementor
Serialization 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
Description copied from interface:LogicalConnection
Closes the logical connection, making it inactive and forcing release of any held resources.- Returns:
- the JDBC
Connection
if the user passed in aConnection
originally
-
getConnectionForTransactionManagement
- Specified by:
getConnectionForTransactionManagement
in classAbstractLogicalConnectionImplementor
-
begin
public void begin()Description copied from interface:JdbcResourceTransaction
Begin the resource transaction- Specified by:
begin
in interfaceJdbcResourceTransaction
- Overrides:
begin
in classAbstractLogicalConnectionImplementor
-
afterCompletion
protected void afterCompletion()- Overrides:
afterCompletion
in classAbstractLogicalConnectionImplementor
-
doConnectionsFromProviderHaveAutoCommitDisabled
protected boolean doConnectionsFromProviderHaveAutoCommitDisabled()- Overrides:
doConnectionsFromProviderHaveAutoCommitDisabled
in classAbstractLogicalConnectionImplementor
-