[hibernate-commits] Hibernate SVN: r13935 - in sandbox/trunk/jdbc-proxy/src: main/java/org/hibernate/jdbc/batch and 11 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Sat Aug 18 09:48:50 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-08-18 09:48:50 -0400 (Sat, 18 Aug 2007)
New Revision: 13935

Added:
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/AbstractStatementDelegate.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/BasicStatementDelegate.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/CallableStatementDelegate.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ConnectionDelegate.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/DelegateJDBCContainer.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/PreparedStatementDelegate.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ResultSetDelegate.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ResultSetWrapperImplementor.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/StatementWrapperImplementor.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/AggressiveReleaseTest.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/BasicDelegationTests.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/TestingServiceImpl.java
   sandbox/trunk/jdbc-proxy/src/test/perf/
   sandbox/trunk/jdbc-proxy/src/test/perf/org/
   sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/
   sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/
   sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/Data.java
   sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/PerformanceTest.java
   sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/TestingServiceImpl.java
Removed:
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetWrapperImplementor.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementWrapperImplementor.java
Modified:
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/batch/BatchBuilder.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyBuilder.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyJDBCContainer.java
   sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties
Log:
moved delegation PoC code here for the purpose of combined performance testing

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/batch/BatchBuilder.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/batch/BatchBuilder.java	2007-08-18 08:34:26 UTC (rev 13934)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/batch/BatchBuilder.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -28,7 +28,7 @@
 public class BatchBuilder {
 	private static final Logger log = LoggerFactory.getLogger( BatchBuilder.class );
 
-	// todo : eventually have this take the Settings; this form is needed for testing because Settings is final :(
+	// todo : eventually have this take the Settings; this form is needed for testing because Settings is currently final :(
 
 	private int size;
 

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/AbstractStatementDelegate.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/AbstractStatementDelegate.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/AbstractStatementDelegate.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.HibernateException;
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.JDBCContainer;
+import org.hibernate.jdbc.impl.LogicalConnectionImplementor;
+import org.hibernate.jdbc.impl.StatementWrapperImplementor;
+
+/**
+ * AbstractStatementDelegate implementation
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractStatementDelegate implements Statement, StatementWrapperImplementor {
+	private static final Logger log = LoggerFactory.getLogger( AbstractStatementDelegate.class );
+
+	private ConnectionDelegate connectionDelegate;
+	private Statement statement;
+	private boolean valid = true;
+	private final int hashCode;
+
+	private ResultSet currentResultSetDelegate;
+
+	public AbstractStatementDelegate(ConnectionDelegate connectionDelegate, Statement statement) {
+		this.connectionDelegate = connectionDelegate;
+		this.statement = statement;
+		this.hashCode = statement.hashCode();
+		getJdbcContainer().register( this );
+	}
+
+	protected void errorIfInvalid() {
+		if ( !valid ) {
+			throw new HibernateException( "statement handle is invalid" );
+		}
+	}
+
+	protected JDBCServices getJdbcServices() {
+		errorIfInvalid();
+		return connectionDelegate.getJdbcServices();
+	}
+
+	protected JDBCContainer getJdbcContainer() {
+		errorIfInvalid();
+		return connectionDelegate.getJdbcContainer();
+	}
+
+	protected Statement getWrappedStatementWithoutChecks() {
+		return statement;
+	}
+
+	public Statement getWrappedStatement() {
+		errorIfInvalid();
+		return statement;
+	}
+
+	public void invalidate() {
+		connectionDelegate = null;
+		statement = null;
+		valid = false;
+	}
+
+	public String toString() {
+		return super.toString() + "[valid=" + valid + "]";
+	}
+
+	public int hashCode() {
+		return hashCode;
+	}
+
+
+	// special Statement methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public Connection getConnection() throws SQLException {
+		errorIfInvalid();
+		return connectionDelegate;
+	}
+
+	public void close() throws SQLException {
+		if ( valid ) {
+			LogicalConnectionImplementor lc = connectionDelegate.getLogicalConnection();
+			getJdbcContainer().release( this );
+			lc.afterStatementExecution();
+		}
+	}
+
+	// execution-related methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public ResultSet getGeneratedKeys() throws SQLException {
+		return new ResultSetDelegate( this, getWrappedStatement().getGeneratedKeys() );
+	}
+
+	public ResultSet getResultSet() throws SQLException {
+		currentResultSetDelegate = new ResultSetDelegate( this, getWrappedStatement().getResultSet() );
+		return currentResultSetDelegate;
+	}
+
+	public int getUpdateCount() throws SQLException {
+		return getWrappedStatement().getUpdateCount();
+	}
+
+	public boolean getMoreResults() throws SQLException {
+		return getMoreResults( Statement.CLOSE_CURRENT_RESULT );
+	}
+
+	public boolean getMoreResults(int current) throws SQLException {
+		if ( current == Statement.CLOSE_ALL_RESULTS ) {
+			log.warn( "getMoreResults call requested all previous results be closed, but thats not possible here" );
+			current = Statement.CLOSE_CURRENT_RESULT;
+		}
+		if ( current == Statement.CLOSE_CURRENT_RESULT && currentResultSetDelegate != null ) {
+			getJdbcContainer().release( currentResultSetDelegate );
+		}
+		currentResultSetDelegate = null;
+		return getWrappedStatement().getMoreResults( current );
+	}
+
+	public void cancel() throws SQLException {
+		getWrappedStatement().cancel();
+	}
+
+	public void clearBatch() throws SQLException {
+		getWrappedStatement().clearBatch();
+	}
+
+	public int[] executeBatch() throws SQLException {
+		return getWrappedStatement().executeBatch();
+	}
+
+
+	// general Statement methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public int getMaxFieldSize() throws SQLException {
+		return getWrappedStatement().getMaxFieldSize();
+	}
+
+	public void setMaxFieldSize(int max) throws SQLException {
+		getWrappedStatement().setMaxFieldSize( max );
+	}
+
+	public int getMaxRows() throws SQLException {
+		return getWrappedStatement().getMaxRows();
+	}
+
+	public void setMaxRows(int max) throws SQLException {
+		getWrappedStatement().setMaxRows( max );
+	}
+
+	public void setEscapeProcessing(boolean enable) throws SQLException {
+		getWrappedStatement().setEscapeProcessing( enable );
+	}
+
+	public int getQueryTimeout() throws SQLException {
+		return getWrappedStatement().getQueryTimeout();
+	}
+
+	public void setQueryTimeout(int seconds) throws SQLException {
+		getWrappedStatement().setQueryTimeout( seconds );
+	}
+
+	public void setCursorName(String name) throws SQLException {
+		getWrappedStatement().setCursorName( name );
+	}
+
+	public void setFetchDirection(int direction) throws SQLException {
+		getWrappedStatement().setFetchDirection( direction );
+	}
+
+	public int getFetchDirection() throws SQLException {
+		return getWrappedStatement().getFetchDirection();
+	}
+
+	public void setFetchSize(int rows) throws SQLException {
+		getWrappedStatement().setFetchSize( rows );
+	}
+
+	public int getFetchSize() throws SQLException {
+		return getWrappedStatement().getFetchSize();
+	}
+
+	public int getResultSetConcurrency() throws SQLException {
+		return getWrappedStatement().getResultSetConcurrency();
+	}
+
+	public int getResultSetType() throws SQLException {
+		return getWrappedStatement().getResultSetType();
+	}
+
+	public int getResultSetHoldability() throws SQLException {
+		return getWrappedStatement().getResultSetHoldability();
+	}
+
+	public SQLWarning getWarnings() throws SQLException {
+		return getWrappedStatement().getWarnings();
+	}
+
+	public void clearWarnings() throws SQLException {
+		getWrappedStatement().clearWarnings();
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/BasicStatementDelegate.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/BasicStatementDelegate.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/BasicStatementDelegate.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * BasicStatementDelegate implementation
+ *
+ * @author Steve Ebersole
+ */
+public class BasicStatementDelegate extends AbstractStatementDelegate {
+	public BasicStatementDelegate(ConnectionDelegate connectionDelegate, Statement statement) {
+		super( connectionDelegate, statement );
+	}
+
+	public void addBatch(String sql) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		getWrappedStatement().addBatch( sql );
+	}
+
+	public boolean execute(String sql) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().execute( sql );
+	}
+
+	public ResultSet executeQuery(String sql) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return new ResultSetDelegate( this, getWrappedStatement().executeQuery( sql ) );
+	}
+
+	public int executeUpdate(String sql) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().executeUpdate( sql );
+	}
+
+	public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().executeUpdate( sql, autoGeneratedKeys );
+	}
+
+	public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().executeUpdate( sql, columnIndexes );
+	}
+
+	public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().executeUpdate( sql, columnNames );
+	}
+
+	public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().execute( sql, autoGeneratedKeys );
+	}
+
+	public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().execute( sql, columnIndexes );
+	}
+
+	public boolean execute(String sql, String[] columnNames) throws SQLException {
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+		return getWrappedStatement().execute( sql, columnNames );
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/CallableStatementDelegate.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/CallableStatementDelegate.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/CallableStatementDelegate.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+import org.hibernate.HibernateException;
+
+/**
+ * CallableStatementDelegate implementation
+ *
+ * @author Steve Ebersole
+ */
+public class CallableStatementDelegate extends PreparedStatementDelegate implements CallableStatement {
+	public CallableStatementDelegate(ConnectionDelegate connectionDelegate, Statement statement, String sql) {
+		super( connectionDelegate, statement, sql );
+		if ( ! ( statement instanceof CallableStatement ) ) {
+			throw new HibernateException( "iilegal argument: statement should be PreparedStatement" );
+		}
+	}
+
+	protected CallableStatement getCallableStatement() {
+		return ( CallableStatement ) super.getWrappedStatement();
+	}
+
+
+	// CallableStatement impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
+		getCallableStatement().registerOutParameter( parameterIndex, sqlType );
+	}
+
+	public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
+		getCallableStatement().registerOutParameter( parameterIndex, sqlType, scale );
+	}
+
+	public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException {
+		getCallableStatement().registerOutParameter( paramIndex, sqlType, typeName );
+	}
+
+	public void registerOutParameter(String parameterName, int sqlType) throws SQLException {
+		getCallableStatement().registerOutParameter( parameterName, sqlType );
+	}
+
+	public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {
+		getCallableStatement().registerOutParameter( parameterName, sqlType, scale );
+	}
+
+	public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {
+		getCallableStatement().registerOutParameter( parameterName, sqlType, typeName );
+	}
+
+
+	public boolean wasNull() throws SQLException {
+		return getCallableStatement().wasNull();
+	}
+
+	public void setNull(String parameterName, int sqlType) throws SQLException {
+		getCallableStatement().setNull( parameterName, sqlType );
+	}
+
+	public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {
+		getCallableStatement().setNull( parameterName, sqlType, typeName );
+	}
+
+	public Object getObject(int parameterIndex) throws SQLException {
+		return getCallableStatement().getObject( parameterIndex );
+	}
+
+	public Object getObject(int i, Map<String, Class<?>> map) throws SQLException {
+		return getCallableStatement().getObject( i, map );
+	}
+
+	public Object getObject(String parameterName) throws SQLException {
+		return getCallableStatement().getObject( parameterName );
+	}
+
+	public Object getObject(String parameterName, Map<String, Class<?>> map) throws SQLException {
+		return getCallableStatement().getObject( parameterName, map );
+	}
+
+	public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {
+		getCallableStatement().setObject( parameterName, x, targetSqlType, scale );
+	}
+
+	public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {
+		getCallableStatement().setObject( parameterName, x, targetSqlType );
+	}
+
+	public void setObject(String parameterName, Object x) throws SQLException {
+		getCallableStatement().setObject( parameterName, x );
+	}
+
+	public String getString(int parameterIndex) throws SQLException {
+		return getCallableStatement().getString( parameterIndex );
+	}
+
+	public String getString(String parameterName) throws SQLException {
+		return getCallableStatement().getString( parameterName );
+	}
+
+	public void setString(String parameterName, String x) throws SQLException {
+		getCallableStatement().setString( parameterName, x );
+	}
+
+	public boolean getBoolean(int parameterIndex) throws SQLException {
+		return getCallableStatement().getBoolean( parameterIndex );
+	}
+
+	public boolean getBoolean(String parameterName) throws SQLException {
+		return getCallableStatement().getBoolean( parameterName );
+	}
+
+	public void setBoolean(String parameterName, boolean x) throws SQLException {
+		getCallableStatement().setBoolean( parameterName, x );
+	}
+
+	public byte getByte(int parameterIndex) throws SQLException {
+		return getCallableStatement().getByte( parameterIndex );
+	}
+
+	public byte getByte(String parameterName) throws SQLException {
+		return getCallableStatement().getByte( parameterName );
+	}
+
+	public void setByte(String parameterName, byte x) throws SQLException {
+		getCallableStatement().setByte( parameterName, x );
+	}
+
+	public short getShort(int parameterIndex) throws SQLException {
+		return getCallableStatement().getShort( parameterIndex );
+	}
+
+	public short getShort(String parameterName) throws SQLException {
+		return getCallableStatement().getShort( parameterName );
+	}
+
+	public void setShort(String parameterName, short x) throws SQLException {
+		getCallableStatement().setShort( parameterName, x );
+	}
+
+	public int getInt(int parameterIndex) throws SQLException {
+		return getCallableStatement().getInt( parameterIndex );
+	}
+
+	public int getInt(String parameterName) throws SQLException {
+		return getCallableStatement().getInt( parameterName );
+	}
+
+	public void setInt(String parameterName, int x) throws SQLException {
+		getCallableStatement().setInt( parameterName, x );
+	}
+
+	public long getLong(int parameterIndex) throws SQLException {
+		return getCallableStatement().getLong( parameterIndex );
+	}
+
+	public long getLong(String parameterName) throws SQLException {
+		return getCallableStatement().getLong( parameterName );
+	}
+
+	public void setLong(String parameterName, long x) throws SQLException {
+		getCallableStatement().setLong( parameterName, x );
+	}
+
+	public float getFloat(int parameterIndex) throws SQLException {
+		return getCallableStatement().getFloat( parameterIndex );
+	}
+
+	public float getFloat(String parameterName) throws SQLException {
+		return getCallableStatement().getFloat( parameterName );
+	}
+
+	public void setFloat(String parameterName, float x) throws SQLException {
+		getCallableStatement().setFloat( parameterName, x );
+	}
+
+	public double getDouble(int parameterIndex) throws SQLException {
+		return getCallableStatement().getDouble( parameterIndex );
+	}
+
+	public double getDouble(String parameterName) throws SQLException {
+		return getCallableStatement().getDouble( parameterName );
+	}
+
+	public void setDouble(String parameterName, double x) throws SQLException {
+		getCallableStatement().setDouble( parameterName, x );
+	}
+
+	public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
+		return getCallableStatement().getBigDecimal( parameterIndex );
+	}
+
+	@Deprecated
+	public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
+		return getCallableStatement().getBigDecimal( parameterIndex, scale );
+	}
+
+	public BigDecimal getBigDecimal(String parameterName) throws SQLException {
+		return getCallableStatement().getBigDecimal( parameterName );
+	}
+
+	public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException {
+		getCallableStatement().setBigDecimal( parameterName, x );
+	}
+
+	public byte[] getBytes(int parameterIndex) throws SQLException {
+		return getCallableStatement().getBytes( parameterIndex );
+	}
+
+	public byte[] getBytes(String parameterName) throws SQLException {
+		return getCallableStatement().getBytes( parameterName );
+	}
+
+	public void setBytes(String parameterName, byte[] x) throws SQLException {
+		getCallableStatement().setBytes( parameterName, x );
+	}
+
+	public Date getDate(int parameterIndex) throws SQLException {
+		return getCallableStatement().getDate( parameterIndex );
+	}
+
+	public Date getDate(String parameterName) throws SQLException {
+		return getCallableStatement().getDate( parameterName );
+	}
+
+	public Date getDate(String parameterName, Calendar cal) throws SQLException {
+		return getCallableStatement().getDate( parameterName, cal );
+	}
+
+	public void setDate(String parameterName, Date x) throws SQLException {
+		getCallableStatement().setDate( parameterName, x );
+	}
+
+	public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {
+		getCallableStatement().setDate( parameterName, x, cal );
+	}
+
+	public Time getTime(int parameterIndex) throws SQLException {
+		return getCallableStatement().getTime( parameterIndex );
+	}
+
+	public Timestamp getTimestamp(int parameterIndex) throws SQLException {
+		return getCallableStatement().getTimestamp( parameterIndex );
+	}
+
+	public Ref getRef(int i) throws SQLException {
+		return getCallableStatement().getRef( i );
+	}
+
+	public Ref getRef(String parameterName) throws SQLException {
+		return getCallableStatement().getRef( parameterName );
+	}
+
+	public Blob getBlob(int i) throws SQLException {
+		return getCallableStatement().getBlob( i );
+	}
+
+	public Blob getBlob(String parameterName) throws SQLException {
+		return getCallableStatement().getBlob( parameterName );
+	}
+
+	public Clob getClob(int i) throws SQLException {
+		return getCallableStatement().getClob( i );
+	}
+
+	public Clob getClob(String parameterName) throws SQLException {
+		return getCallableStatement().getClob( parameterName );
+	}
+
+	public Array getArray(int i) throws SQLException {
+		return getCallableStatement().getArray( i );
+	}
+
+	public Array getArray(String parameterName) throws SQLException {
+		return getCallableStatement().getArray( parameterName );
+	}
+
+	public Date getDate(int parameterIndex, Calendar cal) throws SQLException {
+		return getCallableStatement().getDate( parameterIndex, cal );
+	}
+
+	public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
+		return getCallableStatement().getTime( parameterIndex, cal );
+	}
+
+	public Time getTime(String parameterName) throws SQLException {
+		return getCallableStatement().getTime( parameterName );
+	}
+
+	public Time getTime(String parameterName, Calendar cal) throws SQLException {
+		return getCallableStatement().getTime( parameterName, cal );
+	}
+
+	public void setTime(String parameterName, Time x) throws SQLException {
+		getCallableStatement().setTime( parameterName, x );
+	}
+
+	public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {
+		getCallableStatement().setTime( parameterName, x, cal );
+	}
+
+	public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {
+		return getCallableStatement().getTimestamp( parameterIndex, cal );
+	}
+
+	public Timestamp getTimestamp(String parameterName) throws SQLException {
+		return getCallableStatement().getTimestamp( parameterName );
+	}
+
+	public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException {
+		return getCallableStatement().getTimestamp( parameterName, cal );
+	}
+
+	public void setTimestamp(String parameterName, Timestamp x) throws SQLException {
+		getCallableStatement().setTimestamp( parameterName, x );
+	}
+
+	public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {
+		getCallableStatement().setTimestamp( parameterName, x, cal );
+	}
+
+	public URL getURL(int parameterIndex) throws SQLException {
+		return getCallableStatement().getURL( parameterIndex );
+	}
+
+	public URL getURL(String parameterName) throws SQLException {
+		return getCallableStatement().getURL( parameterName );
+	}
+
+	public void setURL(String parameterName, URL val) throws SQLException {
+		getCallableStatement().setURL( parameterName, val );
+	}
+
+	public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {
+		getCallableStatement().setAsciiStream( parameterName, x, length );
+	}
+
+	public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {
+		getCallableStatement().setBinaryStream( parameterName, x, length );
+	}
+
+	public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {
+		getCallableStatement().setCharacterStream( parameterName, reader, length );
+	}
+
+
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ConnectionDelegate.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ConnectionDelegate.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ConnectionDelegate.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.jdbc.impl.ConnectionObserver;
+import org.hibernate.jdbc.ConnectionWrapper;
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.JDBCContainer;
+import org.hibernate.jdbc.impl.LogicalConnectionImplementor;
+import org.hibernate.HibernateException;
+
+/**
+ * Connection implementation which delegates to the current connection as defined
+ * by its logical connection.
+ *
+ * @author Steve Ebersole
+ */
+public class ConnectionDelegate implements Connection, ConnectionWrapper, ConnectionObserver {
+	private static final Logger log = LoggerFactory.getLogger( ConnectionDelegate.class );
+
+	private LogicalConnectionImplementor logicalConnection;
+	private boolean valid = true;
+	private final int hashCode;
+
+	/**
+	 * Builds a connection delegate with the given logical connection.
+	 *
+	 * @param logicalConnection The logical connection handling this
+	 * connection delegate's access to physical connections.
+	 */
+	public ConnectionDelegate(LogicalConnectionImplementor logicalConnection) {
+		this.logicalConnection = logicalConnection;
+		logicalConnection.addObserver( this );
+		this.hashCode = this.logicalConnection.hashCode();
+	}
+
+	/**
+	 * Access to our logical connection.
+	 *
+	 * @return the logical connection
+	 */
+	protected LogicalConnectionImplementor getLogicalConnection() {
+		errorIfInvalid();
+		return logicalConnection;
+	}
+
+	private void errorIfInvalid() {
+		if ( !valid ) {
+			throw new HibernateException( "connection handle is invalid" );
+		}
+	}
+
+	/**
+	 * Provide access to JDBCServices.
+	 * <p/>
+	 * NOTE : package-protected
+	 *
+	 * @return JDBCServices
+	 */
+	JDBCServices getJdbcServices() {
+		return logicalConnection.getJdbcServices();
+	}
+
+	/**
+	 * Provide access to JDBCContainer.
+	 * <p/>
+	 * NOTE : package-protected
+	 *
+	 * @return JDBCContainer
+	 */
+	JDBCContainer getJdbcContainer() {
+		return logicalConnection.getJdbcContainer();
+	}
+
+	public Connection getWrappedConnection() {
+		if ( !valid ) {
+			throw new HibernateException( "connection handle is invalid" );
+		}
+		return logicalConnection.getConnection();
+	}
+
+	protected Connection getWrappedConnectionWithoutChecks() {
+		return logicalConnection.getConnection();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void physicalConnectionObtained(Connection connection) {
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void physicalConnectionReleased() {
+		log.info( "logical connection releasing its physical connection");
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void logicalConnectionClosed() {
+		log.info( "*** logical connection closed ***" );
+		invalidateDelegate();
+	}
+
+	private void invalidateDelegate() {
+		log.trace( "Invalidating connection delegate" );
+		logicalConnection = null;
+		valid = false;
+	}
+
+	public String toString() {
+		return super.toString() + "[valid=" + valid + "]";
+	}
+
+	public int hashCode() {
+		return hashCode;
+	}
+
+
+	// statement-creation methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public Statement createStatement() {
+		try {
+			Statement statement = getWrappedConnection().createStatement();
+			return new BasicStatementDelegate( this, statement );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to create basic statement" );
+		}
+	}
+
+	public Statement createStatement(int resultSetType, int resultSetConcurrency) {
+		try {
+			Statement statement = getWrappedConnection().createStatement( resultSetType, resultSetConcurrency );
+			return new BasicStatementDelegate( this, statement );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to create basic statement" );
+		}
+	}
+
+	public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)  {
+		try {
+			Statement statement = getWrappedConnection()
+					.createStatement( resultSetType, resultSetConcurrency, resultSetHoldability );
+			return new BasicStatementDelegate( this, statement );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to create basic statement" );
+		}
+	}
+
+	public PreparedStatement prepareStatement(String sql) {
+		try {
+			PreparedStatement statement = getWrappedConnection().prepareStatement( sql );
+			return new PreparedStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare statement", sql );
+		}
+	}
+
+	public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) {
+		try {
+			PreparedStatement statement = getWrappedConnection()
+					.prepareStatement( sql, resultSetType, resultSetConcurrency );
+			return new PreparedStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare statement", sql );
+		}
+	}
+
+	public PreparedStatement prepareStatement(
+			String sql,
+			int resultSetType,
+			int resultSetConcurrency,
+			int resultSetHoldability) {
+		try {
+			PreparedStatement statement = getWrappedConnection()
+					.prepareStatement( sql, resultSetType, resultSetConcurrency, resultSetHoldability );
+			return new PreparedStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare statement", sql );
+		}
+	}
+
+	public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) {
+		try {
+			PreparedStatement statement = getWrappedConnection().prepareStatement( sql, autoGeneratedKeys );
+			return new PreparedStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare statement", sql );
+		}
+	}
+
+	public PreparedStatement prepareStatement(String sql, int[] columnIndexes) {
+		try {
+			PreparedStatement statement = getWrappedConnection().prepareStatement( sql, columnIndexes );
+			return new PreparedStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare statement", sql );
+		}
+	}
+
+	public PreparedStatement prepareStatement(String sql, String[] columnNames) {
+		try {
+			PreparedStatement statement = getWrappedConnection().prepareStatement( sql, columnNames );
+			return new PreparedStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare statement", sql );
+		}
+	}
+
+	public CallableStatement prepareCall(String sql) {
+		try {
+			CallableStatement statement = getWrappedConnection().prepareCall( sql );
+			return new CallableStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare call", sql );
+		}
+	}
+
+	public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) {
+		try {
+			CallableStatement statement = getWrappedConnection()
+					.prepareCall( sql, resultSetType, resultSetConcurrency );
+			return new CallableStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare call", sql );
+		}
+	}
+
+	public CallableStatement prepareCall(
+			String sql,
+			int resultSetType,
+			int resultSetConcurrency,
+			int resultSetHoldability) {
+		try {
+			CallableStatement statement = getWrappedConnection()
+					.prepareCall( sql, resultSetType, resultSetConcurrency, resultSetHoldability );
+			return new CallableStatementDelegate( this, statement, sql );
+		}
+		catch ( SQLException e ) {
+			throw getJdbcServices().getExceptionHelper().convert( e, "unable to prepare call", sql );
+		}
+	}
+
+
+	// other Connection methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public void close() {
+		if ( valid ) {
+			invalidateDelegate();
+		}
+	}
+
+	public boolean isClosed() {
+		return !valid;
+	}
+
+	public void setAutoCommit(boolean autoCommit) throws SQLException {
+		getWrappedConnection().setAutoCommit( autoCommit );
+	}
+
+	public boolean getAutoCommit() throws SQLException {
+		return getWrappedConnection().getAutoCommit();
+	}
+
+	public void commit() throws SQLException {
+		getWrappedConnection().commit();
+	}
+
+	public void rollback() throws SQLException {
+		getWrappedConnection().rollback();
+	}
+
+	public DatabaseMetaData getMetaData() throws SQLException {
+		return getWrappedConnection().getMetaData();
+	}
+
+	public String nativeSQL(String sql) throws SQLException {
+		return getWrappedConnection().nativeSQL( sql );
+	}
+
+	public void setReadOnly(boolean readOnly) throws SQLException {
+		getWrappedConnection().setReadOnly( readOnly );
+	}
+
+	public boolean isReadOnly() throws SQLException {
+		return getWrappedConnection().isReadOnly();
+	}
+
+	public void setCatalog(String catalog) throws SQLException {
+		getWrappedConnection().setCatalog( catalog );
+	}
+
+	public String getCatalog() throws SQLException {
+		return getWrappedConnection().getCatalog();
+	}
+
+	public void setTransactionIsolation(int level) throws SQLException {
+		getWrappedConnection().setTransactionIsolation( level );
+	}
+
+	public int getTransactionIsolation() throws SQLException {
+		return getWrappedConnection().getTransactionIsolation();
+	}
+
+	public SQLWarning getWarnings() throws SQLException {
+		return getWrappedConnection().getWarnings();
+	}
+
+	public void clearWarnings() throws SQLException {
+		getWrappedConnection().clearWarnings();
+	}
+
+	public Map<String, Class<?>> getTypeMap() throws SQLException {
+		return getWrappedConnection().getTypeMap();
+	}
+
+	public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+		getWrappedConnection().setTypeMap( map );
+	}
+
+	public void setHoldability(int holdability) throws SQLException {
+		getWrappedConnection().setHoldability( holdability );
+	}
+
+	public int getHoldability() throws SQLException {
+		return getWrappedConnection().getHoldability();
+	}
+
+	public Savepoint setSavepoint() throws SQLException {
+		return getWrappedConnection().setSavepoint();
+	}
+
+	public Savepoint setSavepoint(String name) throws SQLException {
+		return getWrappedConnection().setSavepoint( name );
+	}
+
+	public void rollback(Savepoint savepoint) throws SQLException {
+		getWrappedConnection().rollback( savepoint );
+	}
+
+	public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+		getWrappedConnection().releaseSavepoint( savepoint );
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/DelegateJDBCContainer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/DelegateJDBCContainer.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/DelegateJDBCContainer.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.jdbc.impl.BasicJDBCContainer;
+import org.hibernate.jdbc.impl.StatementWrapperImplementor;
+import org.hibernate.jdbc.impl.ResultSetWrapperImplementor;
+import org.hibernate.jdbc.util.ExceptionHelper;
+
+/**
+ * DelegateJDBCContainer implementation
+ *
+ * @author Steve Ebersole
+ */
+public class DelegateJDBCContainer extends BasicJDBCContainer {
+	private static final Logger log = LoggerFactory.getLogger( DelegateJDBCContainer.class );
+
+	public DelegateJDBCContainer(ExceptionHelper exceptionHelper) {
+		super( exceptionHelper );
+	}
+
+	protected void close(Statement statement) {
+		if ( statement instanceof StatementWrapperImplementor ) {
+			StatementWrapperImplementor wrapper = ( StatementWrapperImplementor ) statement;
+			super.close( wrapper.getWrappedStatement() );
+			wrapper.invalidate();
+		}
+		else {
+			super.close( statement );
+		}
+	}
+
+	protected void close(ResultSet resultSet) {
+		if ( resultSet instanceof ResultSetWrapperImplementor ) {
+			ResultSetWrapperImplementor wrapper = ( ResultSetWrapperImplementor ) resultSet;
+			super.close( wrapper.getWrappedResultSet() );
+			wrapper.invalidate();
+		}
+		else {
+			super.close( resultSet );
+		}
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/PreparedStatementDelegate.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/PreparedStatementDelegate.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/PreparedStatementDelegate.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Ref;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Array;
+import java.sql.ResultSetMetaData;
+import java.sql.ParameterMetaData;
+import java.math.BigDecimal;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Calendar;
+import java.net.URL;
+
+import org.hibernate.HibernateException;
+
+/**
+ * PreparedStatementDelegate implementation
+ *
+ * @author Steve Ebersole
+ */
+public class PreparedStatementDelegate extends AbstractStatementDelegate implements PreparedStatement {
+	private String sql;
+
+	public PreparedStatementDelegate(ConnectionDelegate connectionDelegate, Statement statement, String sql) {
+		super( connectionDelegate, statement );
+		if ( ! ( statement instanceof PreparedStatement ) ) {
+			throw new HibernateException( "iilegal argument: statement should be PreparedStatement" );
+		}
+		this.sql = sql;
+		getJdbcServices().getSqlStatementLogger().logStatement( sql );
+	}
+
+	private PreparedStatement getPreparedStatement() {
+		return ( PreparedStatement ) super.getWrappedStatement();
+	}
+
+
+	// PreparedStatement impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public void addBatch() throws SQLException {
+		getPreparedStatement().addBatch();
+	}
+
+	public boolean execute() throws SQLException {
+		return getPreparedStatement().execute();
+	}
+
+	public ResultSet executeQuery() throws SQLException {
+		return new ResultSetDelegate( this, getPreparedStatement().executeQuery() );
+	}
+
+	public int executeUpdate() throws SQLException {
+		return getPreparedStatement().executeUpdate();
+	}
+
+	public ResultSetMetaData getMetaData() throws SQLException {
+		return getPreparedStatement().getMetaData();
+	}
+
+	public ParameterMetaData getParameterMetaData() throws SQLException {
+		return getPreparedStatement().getParameterMetaData();
+	}
+
+	public void clearParameters() throws SQLException {
+		getPreparedStatement().clearParameters();
+	}
+
+	public void setNull(int parameterIndex, int sqlType) throws SQLException {
+		getPreparedStatement().setNull( parameterIndex, sqlType );
+	}
+
+	public void setBoolean(int parameterIndex, boolean x) throws SQLException {
+		getPreparedStatement().setBoolean( parameterIndex, x );
+	}
+
+	public void setByte(int parameterIndex, byte x) throws SQLException {
+		getPreparedStatement().setByte( parameterIndex, x );
+	}
+
+	public void setShort(int parameterIndex, short x) throws SQLException {
+		getPreparedStatement().setShort( parameterIndex, x );
+	}
+
+	public void setInt(int parameterIndex, int x) throws SQLException {
+		getPreparedStatement().setInt( parameterIndex, x );
+	}
+
+	public void setLong(int parameterIndex, long x) throws SQLException {
+		getPreparedStatement().setLong( parameterIndex, x );
+	}
+
+	public void setFloat(int parameterIndex, float x) throws SQLException {
+		getPreparedStatement().setFloat( parameterIndex, x );
+	}
+
+	public void setDouble(int parameterIndex, double x) throws SQLException {
+		getPreparedStatement().setDouble( parameterIndex, x );
+	}
+
+	public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
+		getPreparedStatement().setBigDecimal( parameterIndex, x );
+	}
+
+	public void setString(int parameterIndex, String x) throws SQLException {
+		getPreparedStatement().setString( parameterIndex, x );
+	}
+
+	public void setBytes(int parameterIndex, byte[] x) throws SQLException {
+		getPreparedStatement().setBytes( parameterIndex, x );
+	}
+
+	public void setDate(int parameterIndex, Date x) throws SQLException {
+		getPreparedStatement().setDate( parameterIndex, x );
+	}
+
+	public void setTime(int parameterIndex, Time x) throws SQLException {
+		getPreparedStatement().setTime( parameterIndex, x );
+	}
+
+	public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
+		getPreparedStatement().setTimestamp( parameterIndex, x );
+	}
+
+	public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
+		getPreparedStatement().setAsciiStream( parameterIndex, x, length );
+	}
+
+	@Deprecated
+	public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
+		getPreparedStatement().setUnicodeStream( parameterIndex, x, length );
+	}
+
+	public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
+		getPreparedStatement().setBinaryStream( parameterIndex, x, length );
+	}
+
+	public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
+		getPreparedStatement().setObject( parameterIndex, x, targetSqlType, scale );
+	}
+
+	public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
+		getPreparedStatement().setObject( parameterIndex, x, targetSqlType );
+	}
+
+	public void setObject(int parameterIndex, Object x) throws SQLException {
+		getPreparedStatement().setObject( parameterIndex, x );
+	}
+
+	public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
+		getPreparedStatement().setCharacterStream( parameterIndex, reader, length );
+	}
+
+	public void setRef(int parameterIndex, Ref x) throws SQLException {
+		getPreparedStatement().setRef( parameterIndex, x );
+	}
+
+	public void setBlob(int parameterIndex, Blob x) throws SQLException {
+		getPreparedStatement().setBlob( parameterIndex, x );
+	}
+
+	public void setClob(int parameterIndex, Clob x) throws SQLException {
+		getPreparedStatement().setClob( parameterIndex, x );
+	}
+
+	public void setArray(int parameterIndex, Array x) throws SQLException {
+		getPreparedStatement().setArray( parameterIndex, x );
+	}
+
+	public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
+		getPreparedStatement().setDate( parameterIndex, x, cal );
+	}
+
+	public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
+		getPreparedStatement().setTime( parameterIndex, x, cal );
+	}
+
+	public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
+		getPreparedStatement().setTimestamp( parameterIndex, x, cal );
+	}
+
+	public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
+		getPreparedStatement().setNull( parameterIndex, sqlType, typeName );
+	}
+
+	public void setURL(int parameterIndex, URL x) throws SQLException {
+		getPreparedStatement().setURL( parameterIndex, x );
+	}
+
+
+	// Statement methods not really valid on PreparedStatements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public boolean execute(String sql) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public ResultSet executeQuery(String sql) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public int executeUpdate(String sql) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public boolean execute(String sql, String[] columnNames) throws SQLException {
+		throw new HibernateException( "This form of execute not allowed here" );
+	}
+
+	public void addBatch(String sql) throws SQLException {
+		throw new HibernateException( "This form of addBatch not allowed here" );
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ResultSetDelegate.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ResultSetDelegate.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/delegation/ResultSetDelegate.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,666 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.SQLWarning;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import java.sql.Ref;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Array;
+import java.math.BigDecimal;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Map;
+import java.util.Calendar;
+import java.net.URL;
+
+import org.hibernate.HibernateException;
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.JDBCContainer;
+import org.hibernate.jdbc.impl.ResultSetWrapperImplementor;
+
+/**
+ * ResultSetDelegate implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ResultSetDelegate implements ResultSet, ResultSetWrapperImplementor {
+
+	private AbstractStatementDelegate statementDelegate;
+	private ResultSet resultSet;
+	private boolean valid = true;
+	private final int hashCode;
+
+	public ResultSetDelegate(AbstractStatementDelegate statementDelegate, ResultSet resultSet) {
+		this.statementDelegate = statementDelegate;
+		this.resultSet = resultSet;
+		this.hashCode = resultSet.hashCode();
+		statementDelegate.getJdbcContainer().register( this );
+	}
+
+	protected JDBCServices getJdbcServices() {
+		return statementDelegate.getJdbcServices();
+	}
+
+	protected JDBCContainer getJdbcContainer() {
+		return statementDelegate.getJdbcContainer();
+	}
+
+	public ResultSet getWrappedResultSetWithoutChecks() {
+		return resultSet;
+	}
+
+	public ResultSet getWrappedResultSet() {
+		if ( !valid ) {
+			throw new HibernateException( "resultset handle is invalid" );
+		}
+		return resultSet;
+	}
+
+	public void invalidate() {
+		statementDelegate = null;
+		resultSet = null;
+		valid = false;
+	}
+
+	public String toString() {
+		return super.toString() + "[valid=" + valid + "]";
+	}
+
+	public int hashCode() {
+		return hashCode;
+	}
+
+
+	// special ResultSet methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public Statement getStatement() throws SQLException {
+		return statementDelegate;
+	}
+
+	public void close() throws SQLException {
+		if ( valid ) {
+			getJdbcContainer().release( this );
+		}
+	}
+
+
+	// Navigational ResultSet methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public boolean next() throws SQLException {
+		return getWrappedResultSet().next();
+	}
+
+	public boolean isBeforeFirst() throws SQLException {
+		return getWrappedResultSet().isBeforeFirst();
+	}
+
+	public boolean isAfterLast() throws SQLException {
+		return getWrappedResultSet().isAfterLast();
+	}
+
+	public boolean isFirst() throws SQLException {
+		return getWrappedResultSet().isFirst();
+	}
+
+	public boolean isLast() throws SQLException {
+		return getWrappedResultSet().isLast();
+	}
+
+	public void beforeFirst() throws SQLException {
+		getWrappedResultSet().beforeFirst();
+	}
+
+	public void afterLast() throws SQLException {
+		getWrappedResultSet().afterLast();
+	}
+
+	public boolean first() throws SQLException {
+		return getWrappedResultSet().first();
+	}
+
+	public boolean last() throws SQLException {
+		return getWrappedResultSet().last();
+	}
+
+	public int getRow() throws SQLException {
+		return getWrappedResultSet().getRow();
+	}
+
+	public boolean absolute(int row) throws SQLException {
+		return getWrappedResultSet().absolute( row );
+	}
+
+	public boolean relative(int rows) throws SQLException {
+		return getWrappedResultSet().relative( rows );
+	}
+
+	public boolean previous() throws SQLException {
+		return getWrappedResultSet().previous();
+	}
+
+
+	// informational ResultSet methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public String getCursorName() throws SQLException {
+		return getWrappedResultSet().getCursorName();
+	}
+
+	public ResultSetMetaData getMetaData() throws SQLException {
+		return getWrappedResultSet().getMetaData();
+	}
+
+	public void setFetchDirection(int direction) throws SQLException {
+		getWrappedResultSet().setFetchDirection( direction );
+	}
+
+	public int getFetchDirection() throws SQLException {
+		return getWrappedResultSet().getFetchDirection();
+	}
+
+	public void setFetchSize(int rows) throws SQLException {
+		getWrappedResultSet().setFetchSize( rows );
+	}
+
+	public int getFetchSize() throws SQLException {
+		return getWrappedResultSet().getFetchSize();
+	}
+
+	public int getType() throws SQLException {
+		return getWrappedResultSet().getType();
+	}
+
+	public int getConcurrency() throws SQLException {
+		return getWrappedResultSet().getConcurrency();
+	}
+
+	public SQLWarning getWarnings() throws SQLException {
+		return getWrappedResultSet().getWarnings();
+	}
+
+	public void clearWarnings() throws SQLException {
+		getWrappedResultSet().clearWarnings();
+	}
+
+
+	// value accessors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public boolean wasNull() throws SQLException {
+		return getWrappedResultSet().wasNull();
+	}
+
+	public String getString(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getString( columnIndex );
+	}
+
+	public boolean getBoolean(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getBoolean( columnIndex );
+	}
+
+	public byte getByte(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getByte( columnIndex );
+	}
+
+	public short getShort(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getShort( columnIndex );
+	}
+
+	public int getInt(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getInt( columnIndex );
+	}
+
+	public long getLong(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getLong( columnIndex );
+	}
+
+	public float getFloat(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getFloat( columnIndex );
+	}
+
+	public double getDouble(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getDouble( columnIndex );
+	}
+
+	public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+		return getWrappedResultSet().getBigDecimal( columnIndex, scale );
+	}
+
+	public byte[] getBytes(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getBytes( columnIndex );
+	}
+
+	public Date getDate(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getDate( columnIndex );
+	}
+
+	public Time getTime(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getTime( columnIndex );
+	}
+
+	public Timestamp getTimestamp(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getTimestamp( columnIndex );
+	}
+
+	public InputStream getAsciiStream(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getAsciiStream( columnIndex );
+	}
+
+	public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getUnicodeStream( columnIndex );
+	}
+
+	public InputStream getBinaryStream(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getBinaryStream( columnIndex );
+	}
+
+	public String getString(String columnName) throws SQLException {
+		return getWrappedResultSet().getString( columnName );
+	}
+
+	public boolean getBoolean(String columnName) throws SQLException {
+		return getWrappedResultSet().getBoolean( columnName );
+	}
+
+	public byte getByte(String columnName) throws SQLException {
+		return getWrappedResultSet().getByte( columnName );
+	}
+
+	public short getShort(String columnName) throws SQLException {
+		return getWrappedResultSet().getShort( columnName );
+	}
+
+	public int getInt(String columnName) throws SQLException {
+		return getWrappedResultSet().getInt( columnName );
+	}
+
+	public long getLong(String columnName) throws SQLException {
+		return getWrappedResultSet().getLong( columnName );
+	}
+
+	public float getFloat(String columnName) throws SQLException {
+		return getWrappedResultSet().getFloat( columnName );
+	}
+
+	public double getDouble(String columnName) throws SQLException {
+		return getWrappedResultSet().getDouble( columnName );
+	}
+
+	public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
+		return getWrappedResultSet().getBigDecimal( columnName, scale );
+	}
+
+	public byte[] getBytes(String columnName) throws SQLException {
+		return getWrappedResultSet().getBytes( columnName );
+	}
+
+	public Date getDate(String columnName) throws SQLException {
+		return getWrappedResultSet().getDate( columnName );
+	}
+
+	public Time getTime(String columnName) throws SQLException {
+		return getWrappedResultSet().getTime( columnName );
+	}
+
+	public Timestamp getTimestamp(String columnName) throws SQLException {
+		return getWrappedResultSet().getTimestamp( columnName );
+	}
+
+	public InputStream getAsciiStream(String columnName) throws SQLException {
+		return getWrappedResultSet().getAsciiStream( columnName );
+	}
+
+	public InputStream getUnicodeStream(String columnName) throws SQLException {
+		return getWrappedResultSet().getUnicodeStream( columnName );
+	}
+
+	public InputStream getBinaryStream(String columnName) throws SQLException {
+		return getWrappedResultSet().getBinaryStream( columnName );
+	}
+
+	public Object getObject(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getObject( columnIndex );
+	}
+
+	public Object getObject(String columnName) throws SQLException {
+		return getWrappedResultSet().getObject( columnName );
+	}
+
+	public int findColumn(String columnName) throws SQLException {
+		return getWrappedResultSet().findColumn( columnName );
+	}
+
+	public Reader getCharacterStream(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getCharacterStream( columnIndex );
+	}
+
+	public Reader getCharacterStream(String columnName) throws SQLException {
+		return getWrappedResultSet().getCharacterStream( columnName );
+	}
+
+	public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getBigDecimal( columnIndex );
+	}
+
+	public BigDecimal getBigDecimal(String columnName) throws SQLException {
+		return getWrappedResultSet().getBigDecimal( columnName );
+	}
+
+	public Object getObject(int i, Map<String, Class<?>> map) throws SQLException {
+		return getWrappedResultSet().getObject( i, map );
+	}
+
+	public Ref getRef(int i) throws SQLException {
+		return getWrappedResultSet().getRef( i );
+	}
+
+	public Blob getBlob(int i) throws SQLException {
+		return getWrappedResultSet().getBlob( i );
+	}
+
+	public Clob getClob(int i) throws SQLException {
+		return getWrappedResultSet().getClob( i );
+	}
+
+	public Array getArray(int i) throws SQLException {
+		return getWrappedResultSet().getArray( i );
+	}
+
+	public Object getObject(String colName, Map<String, Class<?>> map) throws SQLException {
+		return getWrappedResultSet().getObject( colName, map );
+	}
+
+	public Ref getRef(String colName) throws SQLException {
+		return getWrappedResultSet().getRef( colName );
+	}
+
+	public Blob getBlob(String colName) throws SQLException {
+		return getWrappedResultSet().getBlob( colName );
+	}
+
+	public Clob getClob(String colName) throws SQLException {
+		return getWrappedResultSet().getClob( colName );
+	}
+
+	public Array getArray(String colName) throws SQLException {
+		return getWrappedResultSet().getArray( colName );
+	}
+
+	public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+		return getWrappedResultSet().getDate( columnIndex, cal );
+	}
+
+	public Date getDate(String columnName, Calendar cal) throws SQLException {
+		return getWrappedResultSet().getDate( columnName, cal );
+	}
+
+	public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+		return getWrappedResultSet().getTime( columnIndex, cal );
+	}
+
+	public Time getTime(String columnName, Calendar cal) throws SQLException {
+		return getWrappedResultSet().getTime( columnName, cal );
+	}
+
+	public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+		return getWrappedResultSet().getTimestamp( columnIndex, cal );
+	}
+
+	public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
+		return getWrappedResultSet().getTimestamp( columnName, cal );
+	}
+
+	public URL getURL(int columnIndex) throws SQLException {
+		return getWrappedResultSet().getURL( columnIndex );
+	}
+
+	public URL getURL(String columnName) throws SQLException {
+		return getWrappedResultSet().getURL( columnName );
+	}
+
+
+	// ResultSet mutability ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public boolean rowUpdated() throws SQLException {
+		return getWrappedResultSet().rowUpdated();
+	}
+
+	public boolean rowInserted() throws SQLException {
+		return getWrappedResultSet().rowInserted();
+	}
+
+	public boolean rowDeleted() throws SQLException {
+		return getWrappedResultSet().rowDeleted();
+	}
+
+	public void updateNull(int columnIndex) throws SQLException {
+		getWrappedResultSet().updateNull( columnIndex );
+	}
+
+	public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+		getWrappedResultSet().updateBoolean( columnIndex, x );
+	}
+
+	public void updateByte(int columnIndex, byte x) throws SQLException {
+		getWrappedResultSet().updateByte( columnIndex, x );
+	}
+
+	public void updateShort(int columnIndex, short x) throws SQLException {
+		getWrappedResultSet().updateShort( columnIndex, x );
+	}
+
+	public void updateInt(int columnIndex, int x) throws SQLException {
+		getWrappedResultSet().updateInt( columnIndex, x );
+	}
+
+	public void updateLong(int columnIndex, long x) throws SQLException {
+		getWrappedResultSet().updateLong( columnIndex, x );
+	}
+
+	public void updateFloat(int columnIndex, float x) throws SQLException {
+		getWrappedResultSet().updateFloat( columnIndex, x );
+	}
+
+	public void updateDouble(int columnIndex, double x) throws SQLException {
+		getWrappedResultSet().updateDouble( columnIndex, x );
+	}
+
+	public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+		getWrappedResultSet().updateBigDecimal( columnIndex, x );
+	}
+
+	public void updateString(int columnIndex, String x) throws SQLException {
+		getWrappedResultSet().updateString( columnIndex, x );
+	}
+
+	public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+		getWrappedResultSet().updateBytes( columnIndex, x );
+	}
+
+	public void updateDate(int columnIndex, Date x) throws SQLException {
+		getWrappedResultSet().updateDate( columnIndex, x );
+	}
+
+	public void updateTime(int columnIndex, Time x) throws SQLException {
+		getWrappedResultSet().updateTime( columnIndex, x );
+	}
+
+	public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+		getWrappedResultSet().updateTimestamp( columnIndex, x );
+	}
+
+	public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+		getWrappedResultSet().updateAsciiStream( columnIndex, x, length );
+	}
+
+	public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+		getWrappedResultSet().updateBinaryStream( columnIndex, x, length );
+	}
+
+	public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+		getWrappedResultSet().updateCharacterStream( columnIndex, x, length );
+	}
+
+	public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
+		getWrappedResultSet().updateObject( columnIndex, x, scale );
+	}
+
+	public void updateObject(int columnIndex, Object x) throws SQLException {
+		getWrappedResultSet().updateObject( columnIndex, x );
+	}
+
+	public void updateNull(String columnName) throws SQLException {
+		getWrappedResultSet().updateNull( columnName );
+	}
+
+	public void updateBoolean(String columnName, boolean x) throws SQLException {
+		getWrappedResultSet().updateBoolean( columnName, x );
+	}
+
+	public void updateByte(String columnName, byte x) throws SQLException {
+		getWrappedResultSet().updateByte( columnName, x );
+	}
+
+	public void updateShort(String columnName, short x) throws SQLException {
+		getWrappedResultSet().updateShort( columnName, x );
+	}
+
+	public void updateInt(String columnName, int x) throws SQLException {
+		getWrappedResultSet().updateInt( columnName, x );
+	}
+
+	public void updateLong(String columnName, long x) throws SQLException {
+		getWrappedResultSet().updateLong( columnName, x );
+	}
+
+	public void updateFloat(String columnName, float x) throws SQLException {
+		getWrappedResultSet().updateFloat( columnName, x );
+	}
+
+	public void updateDouble(String columnName, double x) throws SQLException {
+		getWrappedResultSet().updateDouble( columnName, x );
+	}
+
+	public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException {
+		getWrappedResultSet().updateBigDecimal( columnName, x );
+	}
+
+	public void updateString(String columnName, String x) throws SQLException {
+		getWrappedResultSet().updateString( columnName, x );
+	}
+
+	public void updateBytes(String columnName, byte[] x) throws SQLException {
+		getWrappedResultSet().updateBytes( columnName, x );
+	}
+
+	public void updateDate(String columnName, Date x) throws SQLException {
+		getWrappedResultSet().updateDate( columnName, x );
+	}
+
+	public void updateTime(String columnName, Time x) throws SQLException {
+		getWrappedResultSet().updateTime( columnName, x );
+	}
+
+	public void updateTimestamp(String columnName, Timestamp x) throws SQLException {
+		getWrappedResultSet().updateTimestamp( columnName, x );
+	}
+
+	public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException {
+		getWrappedResultSet().updateAsciiStream( columnName, x, length );
+	}
+
+	public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException {
+		getWrappedResultSet().updateBinaryStream( columnName, x, length );
+	}
+
+	public void updateCharacterStream(String columnName, Reader reader, int length) throws SQLException {
+		getWrappedResultSet().updateCharacterStream( columnName, reader, length );
+	}
+
+	public void updateObject(String columnName, Object x, int scale) throws SQLException {
+		getWrappedResultSet().updateObject( columnName, x, scale );
+	}
+
+	public void updateObject(String columnName, Object x) throws SQLException {
+		getWrappedResultSet().updateObject( columnName, x );
+	}
+
+	public void insertRow() throws SQLException {
+		getWrappedResultSet().insertRow();
+	}
+
+	public void updateRow() throws SQLException {
+		getWrappedResultSet().updateRow();
+	}
+
+	public void deleteRow() throws SQLException {
+		getWrappedResultSet().deleteRow();
+	}
+
+	public void refreshRow() throws SQLException {
+		getWrappedResultSet().refreshRow();
+	}
+
+	public void cancelRowUpdates() throws SQLException {
+		getWrappedResultSet().cancelRowUpdates();
+	}
+
+	public void moveToInsertRow() throws SQLException {
+		getWrappedResultSet().moveToInsertRow();
+	}
+
+	public void moveToCurrentRow() throws SQLException {
+		getWrappedResultSet().moveToCurrentRow();
+	}
+
+	public void updateRef(int columnIndex, Ref x) throws SQLException {
+		getWrappedResultSet().updateRef( columnIndex, x );
+	}
+
+	public void updateRef(String columnName, Ref x) throws SQLException {
+		getWrappedResultSet().updateRef( columnName, x );
+	}
+
+	public void updateBlob(int columnIndex, Blob x) throws SQLException {
+		getWrappedResultSet().updateBlob( columnIndex, x );
+	}
+
+	public void updateBlob(String columnName, Blob x) throws SQLException {
+		getWrappedResultSet().updateBlob( columnName, x );
+	}
+
+	public void updateClob(int columnIndex, Clob x) throws SQLException {
+		getWrappedResultSet().updateClob( columnIndex, x );
+	}
+
+	public void updateClob(String columnName, Clob x) throws SQLException {
+		getWrappedResultSet().updateClob( columnName, x );
+	}
+
+	public void updateArray(int columnIndex, Array x) throws SQLException {
+		getWrappedResultSet().updateArray( columnIndex, x );
+	}
+
+	public void updateArray(String columnName, Array x) throws SQLException {
+		getWrappedResultSet().updateArray( columnName, x );
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ResultSetWrapperImplementor.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ResultSetWrapperImplementor.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ResultSetWrapperImplementor.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.impl;
+
+import org.hibernate.jdbc.ResultSetWrapper;
+
+/**
+ * Extra, internal contract for implementations of ResultSetWrapper for allowing
+ * invalidation of the wrapper.
+ *
+ * @author Steve Ebersole
+ */
+public interface ResultSetWrapperImplementor extends ResultSetWrapper {
+	/**
+	 * Make the wrapper invalid for further usage.
+	 */
+	public void invalidate();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/StatementWrapperImplementor.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/StatementWrapperImplementor.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/StatementWrapperImplementor.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.impl;
+
+import org.hibernate.jdbc.StatementWrapper;
+
+/**
+ * Extra, internal contract for implementations of StatementWrapper for allowing
+ * invalidation of the wrapper.
+ *
+ * @author Steve Ebersole
+ */
+public interface StatementWrapperImplementor extends StatementWrapper {
+	/**
+	 * Make the wrapper invalid for further usage.
+	 */
+	public void invalidate();
+}

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyBuilder.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyBuilder.java	2007-08-18 08:34:26 UTC (rev 13934)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyBuilder.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -15,15 +15,17 @@
  */
 package org.hibernate.jdbc.proxy;
 
+import java.lang.reflect.Proxy;
+import java.sql.CallableStatement;
 import java.sql.Connection;
-import java.sql.Statement;
 import java.sql.PreparedStatement;
-import java.sql.CallableStatement;
 import java.sql.ResultSet;
-import java.lang.reflect.Proxy;
+import java.sql.Statement;
 
 import org.hibernate.jdbc.ConnectionWrapper;
 import org.hibernate.jdbc.impl.LogicalConnectionImplementor;
+import org.hibernate.jdbc.impl.ResultSetWrapperImplementor;
+import org.hibernate.jdbc.impl.StatementWrapperImplementor;
 
 /**
  * ProxyBuilder implementation

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyJDBCContainer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyJDBCContainer.java	2007-08-18 08:34:26 UTC (rev 13934)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyJDBCContainer.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -15,10 +15,12 @@
  */
 package org.hibernate.jdbc.proxy;
 
+import java.sql.ResultSet;
 import java.sql.Statement;
-import java.sql.ResultSet;
 
 import org.hibernate.jdbc.impl.BasicJDBCContainer;
+import org.hibernate.jdbc.impl.ResultSetWrapperImplementor;
+import org.hibernate.jdbc.impl.StatementWrapperImplementor;
 import org.hibernate.jdbc.util.ExceptionHelper;
 
 /**

Deleted: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetWrapperImplementor.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetWrapperImplementor.java	2007-08-18 08:34:26 UTC (rev 13934)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetWrapperImplementor.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.hibernate.jdbc.proxy;
-
-import org.hibernate.jdbc.ResultSetWrapper;
-
-/**
- * Extra, internal contract for implementations of ResultSetWrapper for allowing
- * invalidation of the wrapper.
- *
- * @author Steve Ebersole
- */
-public interface ResultSetWrapperImplementor extends ResultSetWrapper {
-	/**
-	 * Make the wrapper invalid for further usage.
-	 */
-	public void invalidate();
-}

Deleted: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementWrapperImplementor.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementWrapperImplementor.java	2007-08-18 08:34:26 UTC (rev 13934)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementWrapperImplementor.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details. You should have received a
- * copy of the GNU Lesser General Public License, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.hibernate.jdbc.proxy;
-
-import org.hibernate.jdbc.StatementWrapper;
-
-/**
- * Extra, internal contract for implementations of StatementWrapper for allowing
- * invalidation of the wrapper.
- *
- * @author Steve Ebersole
- */
-public interface StatementWrapperImplementor extends StatementWrapper {
-	/**
-	 * Make the wrapper invalid for further usage.
-	 */
-	public void invalidate();
-}

Added: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/AggressiveReleaseTest.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/AggressiveReleaseTest.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/AggressiveReleaseTest.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.fail;
+
+import org.hibernate.jdbc.impl.ConnectionObserver;
+import org.hibernate.jdbc.impl.LogicalConnectionImpl;
+import org.hibernate.ConnectionReleaseMode;
+
+/**
+ * AggressiveReleaseTest implementation
+ *
+ * @author Steve Ebersole
+ */
+public class AggressiveReleaseTest {
+	private static final Logger log = LoggerFactory.getLogger( AggressiveReleaseTest.class );
+	private TestingServiceImpl services = new TestingServiceImpl();
+
+	private static class ConnectionCounter implements ConnectionObserver {
+		public int obtainCount = 0;
+		public int releaseCount = 0;
+
+		public void physicalConnectionObtained(Connection connection) {
+			obtainCount++;
+		}
+
+		public void physicalConnectionReleased() {
+			releaseCount++;
+		}
+
+		public void logicalConnectionClosed() {
+		}
+	}
+
+	@BeforeClass
+	protected void create() {
+		log.debug( "starting @BeforeClass" );
+		services.prepare( true );
+	}
+
+	@AfterClass
+	protected void destroy() {
+		services.release();
+	}
+
+	@BeforeMethod
+	protected void setUpSchema() throws SQLException {
+		log.debug( "starting @BeforeMethod" );
+		Connection connection = null;
+		Statement stmnt = null;
+		try {
+			connection = services.getConnectionProvider().getConnection();
+			stmnt = connection.createStatement();
+			stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" );
+			stmnt.execute( "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" );
+		}
+		finally {
+			if ( stmnt != null ) {
+				try {
+					stmnt.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close statement used to set up schema", ignore );
+				}
+			}
+			if ( connection != null ) {
+				try {
+					connection.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close connection used to set up schema", ignore );
+				}
+			}
+		}
+	}
+
+	@AfterMethod
+	protected void tearDownSchema() throws SQLException {
+		Connection connection = null;
+		Statement stmnt = null;
+		try {
+			connection = services.getConnectionProvider().getConnection();
+			stmnt = connection.createStatement();
+			stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" );
+		}
+		finally {
+			if ( stmnt != null ) {
+				try {
+					stmnt.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close statement used to set up schema", ignore );
+				}
+			}
+			if ( connection != null ) {
+				try {
+					connection.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close connection used to set up schema", ignore );
+				}
+			}
+		}
+	}
+
+	@Test
+	public void testBasicRelease() {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_STATEMENT, services );
+		Connection proxiedConnection = new ConnectionDelegate( logicalConnection );
+		ConnectionCounter observer = new ConnectionCounter();
+		logicalConnection.addObserver( observer );
+
+		try {
+			PreparedStatement ps = proxiedConnection.prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
+			ps.setLong( 1, 1 );
+			ps.setString( 2, "name" );
+			ps.execute();
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 1, observer.obtainCount );
+			assertEquals( 0, observer.releaseCount );
+			ps.close();
+			assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 1, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+		}
+		catch ( SQLException sqle ) {
+			fail( "incorrect exception type : sqlexception" );
+		}
+		finally {
+			logicalConnection.close();
+		}
+
+		assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+	}
+
+	@Test
+	public void testReleaseCircumventedByHeldResources() {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_STATEMENT, services );
+		Connection proxiedConnection = new ConnectionDelegate( logicalConnection );
+		ConnectionCounter observer = new ConnectionCounter();
+		logicalConnection.addObserver( observer );
+
+		try {
+			PreparedStatement ps = proxiedConnection.prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
+			ps.setLong( 1, 1 );
+			ps.setString( 2, "name" );
+			ps.execute();
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 1, observer.obtainCount );
+			assertEquals( 0, observer.releaseCount );
+			ps.close();
+			assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 1, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+
+			// open a result set and hold it open...
+			ps = proxiedConnection.prepareStatement( "select * from SANDBOX_JDBC_TST" );
+			ps.executeQuery();
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 2, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+
+			// open a second result set
+			PreparedStatement ps2 = proxiedConnection.prepareStatement( "select * from SANDBOX_JDBC_TST" );
+			ps2.execute();
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 2, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+			// and close it...
+			ps2.close();
+			// the release should be circumvented...
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 2, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+
+			// let the close of the logical connection below release all resources (hopefully)...
+		}
+		catch ( SQLException sqle ) {
+			fail( "incorrect exception type : sqlexception" );
+		}
+		finally {
+			logicalConnection.close();
+		}
+
+		assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+		assertEquals( 2, observer.obtainCount );
+		assertEquals( 2, observer.releaseCount );
+	}
+
+	@Test
+	public void testReleaseCircumventedManually() {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_STATEMENT, services );
+		Connection proxiedConnection = new ConnectionDelegate( logicalConnection );
+		ConnectionCounter observer = new ConnectionCounter();
+		logicalConnection.addObserver( observer );
+
+		try {
+			PreparedStatement ps = proxiedConnection.prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
+			ps.setLong( 1, 1 );
+			ps.setString( 2, "name" );
+			ps.execute();
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 1, observer.obtainCount );
+			assertEquals( 0, observer.releaseCount );
+			ps.close();
+			assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 1, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+
+			// disable releases...
+			logicalConnection.disableReleases();
+
+			// open a result set...
+			ps = proxiedConnection.prepareStatement( "select * from SANDBOX_JDBC_TST" );
+			ps.executeQuery();
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 2, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+			// and close it...
+			ps.close();
+			// the release should be circumvented...
+			assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			assertEquals( 2, observer.obtainCount );
+			assertEquals( 1, observer.releaseCount );
+
+			// let the close of the logical connection below release all resources (hopefully)...
+		}
+		catch ( SQLException sqle ) {
+			fail( "incorrect exception type : sqlexception" );
+		}
+		finally {
+			logicalConnection.close();
+		}
+
+		assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+		assertEquals( 2, observer.obtainCount );
+		assertEquals( 2, observer.releaseCount );
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/BasicDelegationTests.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/BasicDelegationTests.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/BasicDelegationTests.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.JDBCException;
+import org.hibernate.jdbc.impl.LogicalConnectionImpl;
+
+/**
+ * BasicDelegationTests implementation
+ *
+ * @author Steve Ebersole
+ */
+public class BasicDelegationTests {
+
+	private TestingServiceImpl services = new TestingServiceImpl();
+
+	@BeforeClass
+	protected void create() {
+		services.prepare( false );
+	}
+
+	@AfterClass
+	protected void destroy() {
+		services.release();
+	}
+
+	@Test
+	public void testExceptionHandling() {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+		ConnectionDelegate connection = new ConnectionDelegate( logicalConnection );
+		try {
+			connection.prepareStatement( "select count(*) from NON_EXISTENT" ).executeQuery();
+		}
+		catch ( SQLException sqle ) {
+			fail( "incorrect exception type : sqlexception" );
+		}
+		catch ( JDBCException ok ) {
+			// expected outcome
+		}
+		finally {
+			logicalConnection.close();
+		}
+	}
+
+	@Test
+	public void testBasicJdbcUsage() throws JDBCException {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+		ConnectionDelegate connection = new ConnectionDelegate( logicalConnection );
+
+		try {
+			Statement stmnt = connection.createStatement();
+			stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" );
+			stmnt.execute( "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" );
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+			logicalConnection.getJdbcContainer().close();
+			assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+
+			PreparedStatement ps = connection.prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
+			ps.setLong( 1, 1 );
+			ps.setString( 2, "name" );
+			ps.execute();
+
+			ps = connection.prepareStatement( "select * from SANDBOX_JDBC_TST" );
+			ps.executeQuery();
+
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+		}
+		catch ( SQLException sqle ) {
+			fail( "incorrect exception type : sqlexception" );
+		}
+		finally {
+			logicalConnection.close();
+		}
+
+		assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/TestingServiceImpl.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/TestingServiceImpl.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/delegation/TestingServiceImpl.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc.delegation;
+
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.JDBCContainerBuilder;
+import org.hibernate.jdbc.ConnectionProviderBuilder;
+import org.hibernate.jdbc.JDBCContainer;
+import org.hibernate.jdbc.util.SQLStatementLogger;
+import org.hibernate.jdbc.util.ExceptionHelper;
+import org.hibernate.connection.ConnectionProvider;
+
+/**
+ * TestingServiceImpl implementation
+ *
+ * @author Steve Ebersole
+ */
+public class TestingServiceImpl implements JDBCServices {
+	private ConnectionProvider connectionProvider;
+	private SQLStatementLogger sqlStatementLogger;
+	private JDBCContainerBuilder jdbcContainerBuilder;
+	private ExceptionHelper exceptionHelper;
+
+	public void prepare(boolean allowAggressiveRelease) {
+		connectionProvider = ConnectionProviderBuilder.buildConnectionProvider( allowAggressiveRelease );
+		sqlStatementLogger = new SQLStatementLogger( true );
+		exceptionHelper = new ExceptionHelper();
+		jdbcContainerBuilder = new JDBCContainerBuilder() {
+			public JDBCContainer buildJdbcContainer() {
+				return new DelegateJDBCContainer( exceptionHelper );
+			}
+		};
+	}
+
+	public void release() {
+		connectionProvider.close();
+	}
+
+	public ConnectionProvider getConnectionProvider() {
+		return connectionProvider;
+	}
+
+	public JDBCContainerBuilder getJdbcContainerBuilder() {
+		return jdbcContainerBuilder;
+	}
+
+	public SQLStatementLogger getSqlStatementLogger() {
+		return sqlStatementLogger;
+	}
+
+	public ExceptionHelper getExceptionHelper() {
+		return exceptionHelper;
+	}
+}
\ No newline at end of file

Added: sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/Data.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/Data.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/Data.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc;
+
+/**
+ * Data implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Data {
+	private long id;
+	private String name;
+
+	public Data() {
+	}
+
+	public Data(long id, String name) {
+		this.id = id;
+		this.name = name;
+	}
+
+	public long getId() {
+		return id;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/PerformanceTest.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/PerformanceTest.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/PerformanceTest.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,370 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.jdbc.delegation.ConnectionDelegate;
+import org.hibernate.jdbc.impl.LogicalConnectionImpl;
+import org.hibernate.jdbc.proxy.ProxyBuilder;
+
+/**
+ * PerformanceTest implementation
+ *
+ * @author Steve Ebersole
+ */
+public class PerformanceTest {
+	private static final Logger log = LoggerFactory.getLogger( PerformanceTest.class );
+	private TestingServiceImpl services = new TestingServiceImpl();
+
+	@BeforeClass
+	protected void create() {
+		services.prepare( true );
+	}
+
+	@AfterClass
+	protected void destroy() {
+		services.release();
+	}
+
+	@BeforeMethod
+	protected void setUpSchema() throws SQLException {
+		Connection connection = null;
+		Statement stmnt = null;
+		try {
+			connection = services.getConnectionProvider().getConnection();
+			stmnt = connection.createStatement();
+			stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" );
+			stmnt.execute( "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" );
+		}
+		finally {
+			if ( stmnt != null ) {
+				try {
+					stmnt.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close statement used to set up schema", ignore );
+				}
+			}
+			if ( connection != null ) {
+				try {
+					connection.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close connection used to set up schema", ignore );
+				}
+			}
+		}
+	}
+
+	@AfterMethod
+	protected void tearDownSchema() throws SQLException {
+		Connection connection = null;
+		Statement stmnt = null;
+		try {
+			connection = services.getConnectionProvider().getConnection();
+			stmnt = connection.createStatement();
+			stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" );
+		}
+		finally {
+			if ( stmnt != null ) {
+				try {
+					stmnt.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close statement used to set up schema", ignore );
+				}
+			}
+			if ( connection != null ) {
+				try {
+					connection.close();
+				}
+				catch ( SQLException ignore ) {
+					log.warn( "could not close connection used to set up schema", ignore );
+				}
+			}
+		}
+	}
+
+	@Test
+	public void testSimultaneous() throws Throwable {
+		System.gc();
+		System.gc();
+
+		for ( int n = 2; n < 5000; n *= 2 ) {
+			Data[] datum = new Data[n];
+			for ( int i = 0; i < n; i++ ) {
+				datum[i] = new Data( i, "test - many [" + i + "]" );
+			}
+
+			// prime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+			Connection c;
+			LogicalConnectionImpl lc;
+
+			c = services.getConnectionProvider().getConnection();
+			process( c, datum );
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			c = services.getConnectionProvider().getConnection();
+			process( c, datum );
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			// Now do timings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+			long proxies = 0, deleg = 0, jdbc = 0, start = 0;
+
+			c = services.getConnectionProvider().getConnection();
+			start = System.currentTimeMillis();
+			process( c, datum );
+			jdbc += System.currentTimeMillis() - start;
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			start = System.currentTimeMillis();
+			process( c, datum );
+			proxies += System.currentTimeMillis() - start;
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			start = System.currentTimeMillis();
+			process( c, datum );
+			deleg += System.currentTimeMillis() - start;
+			c.close();
+			lc.close();
+
+			c = services.getConnectionProvider().getConnection();
+			start = System.currentTimeMillis();
+			process( c, datum );
+			jdbc += System.currentTimeMillis() - start;
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			start = System.currentTimeMillis();
+			process( c, datum );
+			proxies += System.currentTimeMillis() - start;
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			start = System.currentTimeMillis();
+			process( c, datum );
+			deleg += System.currentTimeMillis() - start;
+			c.close();
+			lc.close();
+
+			c = services.getConnectionProvider().getConnection();
+			start = System.currentTimeMillis();
+			process( c, datum );
+			jdbc += System.currentTimeMillis() - start;
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			start = System.currentTimeMillis();
+			process( c, datum );
+			proxies += System.currentTimeMillis() - start;
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			start = System.currentTimeMillis();
+			process( c, datum );
+			deleg += System.currentTimeMillis() - start;
+			c.close();
+			lc.close();
+
+			System.out.println( "-----------------------------------------------------------------------------------" );
+			System.out.println( "    Objects : " + n );
+			System.out.println( "Direct JDBC : " + jdbc + " ms" );
+			System.out.println( "    Proxies : " + proxies + " ms (ratio=" + ( ( (float) proxies )/jdbc ) + ")" );
+			System.out.println( " Delegation : " + deleg + " ms (ratio=" + ( ( (float) deleg )/jdbc ) + ")" );
+			System.out.println( "-----------------------------------------------------------------------------------" );
+
+		}
+	}
+
+	@Test
+	public void testMany() throws Throwable {
+		System.gc();
+		System.gc();
+
+		int N = 30;
+		long proxies = 0, jdbc = 0, deleg = 0, start = 0;
+
+		for ( int n = 1; n < 20; n++ ) {
+			Data[] datum = new Data[n];
+			for ( int i = 0; i < n; i++ ) {
+				datum[i] = new Data( i, "test - many [" + i + "]" );
+			}
+
+			Connection c;
+			LogicalConnectionImpl lc;
+
+			// prime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+			c = services.getConnectionProvider().getConnection();
+			process( c, datum );
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			c = services.getConnectionProvider().getConnection();
+			process( c, datum );
+			services.getConnectionProvider().closeConnection( c );
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			process( c, datum );
+			c.close();
+			lc.close();
+
+			// Now do timings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+			start = System.currentTimeMillis();
+			c = services.getConnectionProvider().getConnection();
+			for ( int i = 0; i < N; i++ ) {
+				process( c, datum );
+			}
+			services.getConnectionProvider().closeConnection( c );
+			jdbc += System.currentTimeMillis() - start;
+
+			start = System.currentTimeMillis();
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = ProxyBuilder.buildConnection( lc );
+			for ( int i = 0; i < N; i++ ) {
+				process( c, datum );
+			}
+			c.close();
+			lc.close();
+			proxies += ( System.currentTimeMillis() - start );
+
+			start = System.currentTimeMillis();
+			lc = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+			c = new ConnectionDelegate( lc );
+			for ( int i = 0; i < N; i++ ) {
+				process( c, datum );
+			}
+			c.close();
+			lc.close();
+			deleg += ( System.currentTimeMillis() - start );
+
+		}
+
+		System.out.println( "-----------------------------------------------------------------------------------" );
+		System.out.println( "Direct JDBC : " + jdbc + " ms" );
+		System.out.println( "    Proxies : " + proxies + " ms (ratio=" + ( (float) proxies )/jdbc + ")" );
+		System.out.println( " Delegation : " + deleg + " ms (ratio=" + ( (float) deleg )/jdbc + ")" );
+		System.out.println( "-----------------------------------------------------------------------------------" );
+	}
+
+	private void process(Connection connection, Data[] datums) throws Throwable {
+		connection.setAutoCommit( false );
+
+		PreparedStatement insert = connection.prepareStatement( "insert into SANDBOX_JDBC_TST ( name, id ) values ( ?, ? )" );
+		for ( int i = 0, n = datums.length; i < n; i++ ) {
+			insert.setString( 1, datums[i].getName() );
+			insert.setLong( 2, datums[i].getId() );
+			insert.executeUpdate();
+		}
+		insert.close();
+
+		PreparedStatement update = connection.prepareStatement( "update SANDBOX_JDBC_TST set name = ? where id = ?" );
+		for ( int i = 0, n = datums.length; i < n; i++ ) {
+			update.setString( 1, "A Different Name!" + i + n );
+			update.setLong( 2, datums[i].getId() );
+			update.executeUpdate();
+		}
+		update.close();
+
+		PreparedStatement select = connection.prepareStatement( "select s.id s_id, s.name s_name FROM SANDBOX_JDBC_TST s" );
+		ResultSet rs = select.executeQuery();
+		while ( rs.next() ) {
+			rs.getLong( "s_id" );
+			rs.getString( "s_name" );
+		}
+		rs.close();
+		select.close();
+
+		PreparedStatement delete = connection.prepareStatement( "delete from SANDBOX_JDBC_TST where id = ?" );
+		for ( int i = 0, n = datums.length; i < n; i++ ) {
+			delete.setLong( 1, datums[i].getId() );
+			delete.executeUpdate();
+		}
+		delete.close();
+
+		connection.commit();
+	}
+}

Copied: sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/TestingServiceImpl.java (from rev 13928, sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java)
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/TestingServiceImpl.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/perf/org/hibernate/jdbc/TestingServiceImpl.java	2007-08-18 13:48:50 UTC (rev 13935)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.jdbc;
+
+import java.sql.SQLException;
+
+import org.hibernate.jdbc.proxy.ProxyJDBCContainer;
+import org.hibernate.jdbc.util.SQLStatementLogger;
+import org.hibernate.jdbc.util.ExceptionHelper;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.exception.SQLStateConverter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+
+/**
+ * TestingServiceImpl implementation
+ *
+ * @author Steve Ebersole
+ */
+public class TestingServiceImpl implements JDBCServices {
+	private ConnectionProvider connectionProvider;
+	private SQLStatementLogger sqlStatementLogger;
+	private JDBCContainerBuilder jdbcContainerBuilder;
+	private ExceptionHelper exceptionHelper;
+
+	public void prepare(boolean allowAggressiveRelease) {
+		connectionProvider = ConnectionProviderBuilder.buildConnectionProvider( allowAggressiveRelease );
+		sqlStatementLogger = new SQLStatementLogger( false );
+		exceptionHelper = new ExceptionHelper(
+				new SQLStateConverter(
+						new ViolatedConstraintNameExtracter() {
+							public String extractConstraintName(SQLException e) {
+								return null;
+							}
+						}
+				)
+		);
+		jdbcContainerBuilder = new JDBCContainerBuilder() {
+			public JDBCContainer buildJdbcContainer() {
+				return new ProxyJDBCContainer( exceptionHelper );
+			}
+		};
+	}
+
+	public void release() {
+		connectionProvider.close();
+	}
+
+	public ConnectionProvider getConnectionProvider() {
+		return connectionProvider;
+	}
+
+	public JDBCContainerBuilder getJdbcContainerBuilder() {
+		return jdbcContainerBuilder;
+	}
+
+	public SQLStatementLogger getSqlStatementLogger() {
+		return sqlStatementLogger;
+	}
+
+	public ExceptionHelper getExceptionHelper() {
+		return exceptionHelper;
+	}
+}
\ No newline at end of file

Modified: sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties	2007-08-18 08:34:26 UTC (rev 13934)
+++ sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties	2007-08-18 13:48:50 UTC (rev 13935)
@@ -18,6 +18,6 @@
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
 
-log4j.rootLogger=info, stdout
+log4j.rootLogger=error, stdout
 
-log4j.logger.org.hibernate=trace
\ No newline at end of file
+#log4j.logger.org.hibernate=error
\ No newline at end of file




More information about the hibernate-commits mailing list