FileDocCategorySizeDatePackage
SuppliedConnectionProviderConnectionHelper.javaAPI DocHibernate 3.2.51551Thu Feb 09 20:48:38 GMT 2006org.hibernate.tool.hbm2ddl

SuppliedConnectionProviderConnectionHelper

public class SuppliedConnectionProviderConnectionHelper extends Object implements ConnectionHelper
A {@link ConnectionHelper} implementation based on a provided {@link ConnectionProvider}. Essentially, ensures that the connection gets cleaned up, but that the provider itself remains usable since it was externally provided to us.
author
Steve Ebersole

Fields Summary
private org.hibernate.connection.ConnectionProvider
provider
private Connection
connection
private boolean
toggleAutoCommit
Constructors Summary
public SuppliedConnectionProviderConnectionHelper(org.hibernate.connection.ConnectionProvider provider)

		this.provider = provider;
	
Methods Summary
public java.sql.ConnectiongetConnection()

		return connection;
	
public voidprepare(boolean needsAutoCommit)

		connection = provider.getConnection();
		toggleAutoCommit = needsAutoCommit && !connection.getAutoCommit();
		if ( toggleAutoCommit ) {
			try {
				connection.commit();
			}
			catch( Throwable ignore ) {
				// might happen with a managed connection
			}
			connection.setAutoCommit( true );
		}
	
public voidrelease()

		// we only release the connection
		if ( connection != null ) {
			JDBCExceptionReporter.logAndClearWarnings( connection );
			if ( toggleAutoCommit ) {
				connection.setAutoCommit( false );
			}
			provider.closeConnection( connection );
			connection = null;
		}