|
|||||||||
| Home >> All >> org >> hibernate >> [ jdbc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.hibernate.jdbc
Class ConnectionManager

java.lang.Objectorg.hibernate.jdbc.ConnectionManager
- All Implemented Interfaces:
- java.io.Serializable
- public class ConnectionManager
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
Encapsulates JDBC Connection management logic needed by Hibernate.
The lifecycle is intended to span a logical series of interactions with the database. Internally, this means the the lifecycle of the Session.
| Nested Class Summary | |
static interface |
ConnectionManager.Callback
|
| Field Summary | |
private Batcher |
batcher
|
private java.sql.Connection |
borrowedConnection
|
private ConnectionManager.Callback |
callback
|
private java.sql.Connection |
connection
|
private org.hibernate.engine.SessionFactoryImplementor |
factory
|
private org.hibernate.Interceptor |
interceptor
|
private boolean |
isClosed
|
private boolean |
isFlushing
|
private static org.apache.commons.logging.Log |
log
|
private org.hibernate.ConnectionReleaseMode |
releaseMode
|
private boolean |
wasConnectionSupplied
|
| Constructor Summary | |
|
ConnectionManager(org.hibernate.engine.SessionFactoryImplementor factory,
ConnectionManager.Callback callback,
org.hibernate.ConnectionReleaseMode releaseMode,
java.sql.Connection connection,
org.hibernate.Interceptor interceptor)
Constructs a ConnectionManager. |
private |
ConnectionManager(org.hibernate.engine.SessionFactoryImplementor factory,
ConnectionManager.Callback callback,
org.hibernate.ConnectionReleaseMode releaseMode,
org.hibernate.Interceptor interceptor,
boolean wasConnectionSupplied,
boolean isClosed)
Private constructor used exclusively from custom serialization |
| Method Summary | |
void |
afterStatement()
To be called after execution of each JDBC statement. |
void |
afterTransaction()
To be called after local transaction completion. |
private void |
aggressiveRelease()
Performs actions required to perform an aggressive release of the JDBC Connection. |
java.sql.Connection |
borrowConnection()
|
private java.sql.Connection |
cleanup()
Releases the Connection and cleans up any resources associated with that Connection. |
java.sql.Connection |
close()
To be called after Session completion. |
private void |
closeConnection()
Physically closes the JDBC Connection. |
static ConnectionManager |
deserialize(java.io.ObjectInputStream ois,
org.hibernate.engine.SessionFactoryImplementor factory,
org.hibernate.Interceptor interceptor,
org.hibernate.ConnectionReleaseMode connectionReleaseMode,
JDBCContext jdbcContext)
|
void |
flushBeginning()
Callback to let us know that a flush is beginning. |
void |
flushEnding()
Callback to let us know that a flush is ending. |
Batcher |
getBatcher()
The batcher managed by this ConnectionManager. |
java.sql.Connection |
getConnection()
Retrieves the connection currently managed by this ConnectionManager. |
org.hibernate.engine.SessionFactoryImplementor |
getFactory()
The session factory. |
boolean |
hasBorrowedConnection()
|
private boolean |
isAfterTransactionRelease()
|
boolean |
isAggressiveRelease()
Will connections be released after each statement execution? Connections will be released after each statement if either: the defined release-mode is ConnectionReleaseMode.AFTER_STATEMENT> ConnectionReleaseMode.AFTER_STATEMENT 55 ; or
the defined release-mode is ConnectionReleaseMode.AFTER_TRANSACTION>ConnectionReleaseMode.AFTER_TRANSACTION 55 but
we are in auto-commit mode. |
private boolean |
isAggressiveReleaseNoTransactionCheck()
Modified version of isAggressiveRelease() 55 which does not force a
transaction check. |
boolean |
isAutoCommit()
Is the connection considered "auto-commit"? |
boolean |
isCurrentlyConnected()
Is this ConnectionManager instance "logically" connected. |
private boolean |
isOnCloseRelease()
|
boolean |
isReadyForSerialization()
|
boolean |
isSuppliedConnection()
Was the connection being used here supplied by the user? |
java.sql.Connection |
manualDisconnect()
Manually disconnect the underlying JDBC Connection. |
void |
manualReconnect()
Manually reconnect the underlying JDBC Connection. |
void |
manualReconnect(java.sql.Connection suppliedConnection)
Manually reconnect the underlying JDBC Connection. |
private void |
openConnection()
Pysically opens a JDBC Connection. |
private void |
readObject(java.io.ObjectInputStream ois)
Used during deserialization. |
void |
releaseBorrowedConnection()
|
void |
serialize(java.io.ObjectOutputStream oos)
|
private void |
writeObject(java.io.ObjectOutputStream oos)
Used during serialization. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
log
private static final org.apache.commons.logging.Log log
factory
private transient org.hibernate.engine.SessionFactoryImplementor factory
callback
private final ConnectionManager.Callback callback
releaseMode
private final org.hibernate.ConnectionReleaseMode releaseMode
connection
private transient java.sql.Connection connection
borrowedConnection
private transient java.sql.Connection borrowedConnection
wasConnectionSupplied
private final boolean wasConnectionSupplied
batcher
private transient Batcher batcher
interceptor
private transient org.hibernate.Interceptor interceptor
isClosed
private boolean isClosed
isFlushing
private transient boolean isFlushing
| Constructor Detail |
ConnectionManager
public ConnectionManager(org.hibernate.engine.SessionFactoryImplementor factory, ConnectionManager.Callback callback, org.hibernate.ConnectionReleaseMode releaseMode, java.sql.Connection connection, org.hibernate.Interceptor interceptor)
- Constructs a ConnectionManager.
This is the form used internally.
ConnectionManager
private ConnectionManager(org.hibernate.engine.SessionFactoryImplementor factory, ConnectionManager.Callback callback, org.hibernate.ConnectionReleaseMode releaseMode, org.hibernate.Interceptor interceptor, boolean wasConnectionSupplied, boolean isClosed)
- Private constructor used exclusively from custom serialization
| Method Detail |
getFactory
public org.hibernate.engine.SessionFactoryImplementor getFactory()
- The session factory.
getBatcher
public Batcher getBatcher()
- The batcher managed by this ConnectionManager.
isSuppliedConnection
public boolean isSuppliedConnection()
- Was the connection being used here supplied by the user?
getConnection
public java.sql.Connection getConnection() throws org.hibernate.HibernateException
- Retrieves the connection currently managed by this ConnectionManager.
Note, that we may need to obtain a connection to return here if a
connection has either not yet been obtained (non-UserSuppliedConnectionProvider)
or has previously been aggressively released (if supported in this environment).
hasBorrowedConnection
public boolean hasBorrowedConnection()
borrowConnection
public java.sql.Connection borrowConnection()
releaseBorrowedConnection
public void releaseBorrowedConnection()
isAutoCommit
public boolean isAutoCommit()
throws java.sql.SQLException
- Is the connection considered "auto-commit"?
isAggressiveRelease
public boolean isAggressiveRelease()
- Will connections be released after each statement execution?
Connections will be released after each statement if either:
- the defined release-mode is ConnectionReleaseMode.AFTER_STATEMENT>
ConnectionReleaseMode.AFTER_STATEMENT55 ; or - the defined release-mode is ConnectionReleaseMode.AFTER_TRANSACTION>
ConnectionReleaseMode.AFTER_TRANSACTION55 but we are in auto-commit mode. release-mode = ConnectionReleaseMode.ON_CLOSE>ConnectionReleaseMode.ON_CLOSE55 should [b]never[/b] release a connection.
- the defined release-mode is ConnectionReleaseMode.AFTER_STATEMENT>
isAggressiveReleaseNoTransactionCheck
private boolean isAggressiveReleaseNoTransactionCheck()
- Modified version of
isAggressiveRelease()55 which does not force a transaction check. This is solely used from ourafterTransaction()55 callback, so no need to do the check; plus it seems to cause problems on websphere (god i love websphere ;) It uses this information to decide if an aggressive release was skipped do to open resources, and if so forces a release.
isCurrentlyConnected
public boolean isCurrentlyConnected()
- Is this ConnectionManager instance "logically" connected. Meaning
do we either have a cached connection available or do we have the
ability to obtain a connection on demand.
afterStatement
public void afterStatement()
- To be called after execution of each JDBC statement. Used to
conditionally release the JDBC connection aggressively if
the configured release mode indicates.
afterTransaction
public void afterTransaction()
- To be called after local transaction completion. Used to conditionally
release the JDBC connection aggressively if the configured release mode
indicates.
isAfterTransactionRelease
private boolean isAfterTransactionRelease()
isOnCloseRelease
private boolean isOnCloseRelease()
close
public java.sql.Connection close()
- To be called after Session completion. Used to release the JDBC
connection.
manualDisconnect
public java.sql.Connection manualDisconnect()
- Manually disconnect the underlying JDBC Connection. The assumption here
is that the manager will be reconnected at a later point in time.
manualReconnect
public void manualReconnect()
- Manually reconnect the underlying JDBC Connection. Should be called at
some point after manualDisconnect().
This form is used for ConnectionProvider-supplied connections.
manualReconnect
public void manualReconnect(java.sql.Connection suppliedConnection)
- Manually reconnect the underlying JDBC Connection. Should be called at
some point after manualDisconnect().
This form is used for user-supplied connections.
cleanup
private java.sql.Connection cleanup() throws org.hibernate.HibernateException
- Releases the Connection and cleans up any resources associated with
that Connection. This is intended for use:
1) at the end of the session
2) on a manual disconnect of the session
3) from afterTransaction(), in the case of skipped aggressive releasing
aggressiveRelease
private void aggressiveRelease()
- Performs actions required to perform an aggressive release of the
JDBC Connection.
openConnection
private void openConnection()
throws org.hibernate.HibernateException
- Pysically opens a JDBC Connection.
closeConnection
private void closeConnection()
- Physically closes the JDBC Connection.
flushBeginning
public void flushBeginning()
- 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
flushEnding()55
flushEnding
public void flushEnding()
- Callback to let us know that a flush is ending. We use this fact to
stop circumventing aggressive releasing connections.
isReadyForSerialization
public boolean isReadyForSerialization()
writeObject
private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException
- Used during serialization.
readObject
private void readObject(java.io.ObjectInputStream ois) throws java.io.IOException, java.lang.ClassNotFoundException
- Used during deserialization.
serialize
public void serialize(java.io.ObjectOutputStream oos) throws java.io.IOException
deserialize
public static ConnectionManager deserialize(java.io.ObjectInputStream ois, org.hibernate.engine.SessionFactoryImplementor factory, org.hibernate.Interceptor interceptor, org.hibernate.ConnectionReleaseMode connectionReleaseMode, JDBCContext jdbcContext) throws java.io.IOException
|
|||||||||
| Home >> All >> org >> hibernate >> [ jdbc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.hibernate.jdbc.ConnectionManager