Top Description Fields Constructors Methods
org.hibernate.resource.jdbc.internal

public Class LogicalConnectionManagedImpl

extends AbstractLogicalConnectionImplementor
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.sql.Connection, .SQLException, org.hibernate.ConnectionAcquisitionMode, .ConnectionReleaseMode, .HibernateException, .ResourceClosedException, org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess, org.hibernate.engine.jdbc.spi.JdbcServices, .SqlExceptionHelper, org.hibernate.resource.jdbc.ResourceRegistry, org.hibernate.resource.jdbc.spi.JdbcObserver, .JdbcSessionContext, .LogicalConnectionImplementor, .PhysicalConnectionHandlingMode, org.jboss.logging.Logger

Represents a LogicalConnection where we manage obtaining and releasing the Connection as needed. This implementation does not claim to be threadsafe 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.
Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private boolean
private final transient PhysicalConnectionHandlingMode
pack-priv boolean
private final transient JdbcConnectionAccess
private static final Logger
private final transient JdbcObserver
observer

Deprecated as a consequence of JdbcObserver being deprecated.
private transient Connection
private boolean
private final transient SqlExceptionHelper
Inherited from org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor:
resourceRegistry

Constructor Summary

AccessConstructor and Description
public
LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, ResourceRegistry resourceRegistry, JdbcServices jdbcServices)

private
LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, boolean closed)

Method Summary

Modifier and TypeMethod and Description
private Connection
protected void
public void
public void
public void
public void
public Connection
close()

Implements org.hibernate.resource.jdbc.LogicalConnection.close.

Closes the JdbcSession, making it inactive and forcing release of any held resources
public static LogicalConnectionManagedImpl
deserialize(ObjectInputStream ois, JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext)

private PhysicalConnectionHandlingMode
protected boolean
protected Connection
public PhysicalConnectionHandlingMode
public Connection
public boolean
isOpen()

Implements org.hibernate.resource.jdbc.LogicalConnection.isOpen.

Is this (logical) JDBC Connection still open/active.
public boolean
isPhysicallyConnected()

Implements org.hibernate.resource.jdbc.LogicalConnection.isPhysicallyConnected.

Is this JdbcSession currently physically connected (meaning does it currently hold a JDBC Connection)?
public LogicalConnectionImplementor
makeShareableCopy()

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.makeShareableCopy.

Creates a shareable copy of itself for use in "shared sessions"
public Connection
manualDisconnect()

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.manualDisconnect.

Manually disconnect the underlying JDBC Connection.
public void
manualReconnect(Connection
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.
suppliedConnection
)

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.manualReconnect.

Manually reconnect the underlying JDBC Connection.
private void
public void
serialize(ObjectOutputStream
The stream to write out state to
oos
)

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.serialize.

Serialization hook
Inherited from org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor:
commitdetermineInitialAutoCommitModeerrorIfClosedgetPhysicalJdbcTransactiongetResourceRegistrygetStatusresetConnectionrollback

Field Detail

closedback to summary
private boolean closed
connectionHandlingModeback to summary
private final transient PhysicalConnectionHandlingMode connectionHandlingMode
initiallyAutoCommitback to summary
pack-priv boolean initiallyAutoCommit
jdbcConnectionAccessback to summary
private final transient JdbcConnectionAccess jdbcConnectionAccess
logback to summary
private static final Logger log

Hides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.log.

observerback to summary
private final transient JdbcObserver observer

Deprecated

as a consequence of JdbcObserver being deprecated. See corresponding docs for further information.

physicalConnectionback to summary
private transient Connection physicalConnection
providerDisablesAutoCommitback to summary
private boolean providerDisablesAutoCommit
sqlExceptionHelperback to summary
private final transient SqlExceptionHelper sqlExceptionHelper

Constructor Detail

LogicalConnectionManagedImplback to summary
public LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, ResourceRegistry resourceRegistry, JdbcServices jdbcServices)
LogicalConnectionManagedImplback to summary
private LogicalConnectionManagedImpl(JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext, boolean closed)

Method Detail

acquireConnectionIfNeededback to summary
private Connection acquireConnectionIfNeeded()
afterCompletionback to summary
protected void afterCompletion()

Overrides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.afterCompletion.

Annotations
@Override
afterStatementback to summary
public void afterStatement()

Overrides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.afterStatement.

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.afterStatement.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.afterStatement.

Notification indicating a JDBC statement has been executed to trigger org.hibernate.ConnectionReleaseMode#AFTER_STATEMENT releasing if needed

Annotations
@Override
afterTransactionback to summary
public void afterTransaction()

Overrides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.afterTransaction.

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.afterTransaction.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.afterTransaction.

Notification indicating a transaction has completed to trigger org.hibernate.ConnectionReleaseMode#AFTER_TRANSACTION releasing if needed

Annotations
@Override
beforeTransactionCompletionback to summary
public void beforeTransactionCompletion()

Overrides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.beforeTransactionCompletion.

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.beforeTransactionCompletion.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.beforeTransactionCompletion.

Notification indicating a transaction is about to be completed, so to trigger releasing of the connection if needed (org.hibernate.ConnectionReleaseMode#BEFORE_TRANSACTION_COMPLETION is enabled)

Annotations
@Override
beginback to summary
public void begin()

Overrides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.begin.

Implements org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransaction.begin.

Doc from org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransaction.begin.

Begin the resource transaction

Annotations
@Override
closeback to summary
public Connection close()

Implements org.hibernate.resource.jdbc.LogicalConnection.close.

Doc from org.hibernate.resource.jdbc.LogicalConnection.close.

Closes the JdbcSession, making it inactive and forcing release of any held resources

Returns:Connection

Legacy :( Returns the JDBC Connection *if* the user passed in a Connection originally.

Annotations
@Override
deserializeback to summary
public static LogicalConnectionManagedImpl deserialize(ObjectInputStream ois, JdbcConnectionAccess jdbcConnectionAccess, JdbcSessionContext jdbcSessionContext) throws IOException
determineConnectionHandlingModeback to summary
private PhysicalConnectionHandlingMode determineConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode, JdbcConnectionAccess jdbcConnectionAccess)
doConnectionsFromProviderHaveAutoCommitDisabledback to summary
protected boolean doConnectionsFromProviderHaveAutoCommitDisabled()

Overrides org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.doConnectionsFromProviderHaveAutoCommitDisabled.

Annotations
@Override
getConnectionForTransactionManagementback to summary
protected Connection getConnectionForTransactionManagement()

Implements abstract org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.getConnectionForTransactionManagement.

Annotations
@Override
getConnectionHandlingModeback to summary
public PhysicalConnectionHandlingMode getConnectionHandlingMode()

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.getConnectionHandlingMode.

Annotations
@Override
getPhysicalConnectionback to summary
public Connection getPhysicalConnection()

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.getPhysicalConnection.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.getPhysicalConnection.

Exposes access to the "real" Connection.

Returns:Connection

The connection

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements org.hibernate.resource.jdbc.LogicalConnection.isOpen.

Doc from org.hibernate.resource.jdbc.LogicalConnection.isOpen.

Is this (logical) JDBC Connection still open/active. In other words, has close not been called yet?

Returns:boolean

true if still open (close has not been called yet); false if not open (close has been called).

Annotations
@Override
isPhysicallyConnectedback to summary
public boolean isPhysicallyConnected()

Implements org.hibernate.resource.jdbc.LogicalConnection.isPhysicallyConnected.

Doc from org.hibernate.resource.jdbc.LogicalConnection.isPhysicallyConnected.

Is this JdbcSession currently physically connected (meaning does it currently hold a JDBC Connection)?

Returns:boolean

true if the JdbcSession currently hold a JDBC Connection; false if it does not.

Annotations
@Override
makeShareableCopyback to summary
public LogicalConnectionImplementor makeShareableCopy()

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.makeShareableCopy.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.makeShareableCopy.

Creates a shareable copy of itself for use in "shared sessions"

Returns:LogicalConnectionImplementor

The shareable copy.

Annotations
@Override
manualDisconnectback to summary
public Connection manualDisconnect()

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.manualDisconnect.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.manualDisconnect.

Manually disconnect the underlying JDBC Connection. The assumption here is that the manager will be reconnected at a later point in time.

Returns:Connection

The connection maintained here at time of disconnect. null if there was no connection cached internally.

Annotations
@Override
manualReconnectback to summary
public void manualReconnect(Connection suppliedConnection)

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.manualReconnect.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.manualReconnect.

Manually reconnect the underlying JDBC Connection. Should be called at some point after manualDisconnect().

Parameters
suppliedConnection:Connection

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.

Annotations
@Override
releaseConnectionback to summary
private void releaseConnection()
serializeback to summary
public void serialize(ObjectOutputStream oos) throws IOException

Implements org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.serialize.

Doc from org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor.serialize.

Serialization hook

Parameters
oos:ObjectOutputStream

The stream to write out state to

Annotations
@Override
Exceptions
IOException:
Problem accessing stream