[hibernate-commits] Hibernate SVN: r12934 - in sandbox/trunk/jdbc-proxy/src: main/java/org/hibernate/jdbc/impl and 3 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Aug 14 13:15:42 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-08-14 13:15:42 -0400 (Tue, 14 Aug 2007)
New Revision: 12934

Added:
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ResultSetWrapper.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/StatementWrapper.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ConnectionObserver.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/main/java/org/hibernate/jdbc/proxy/ResultSetWrapperImplementor.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementWrapperImplementor.java
Removed:
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java
Modified:
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/BasicJDBCContainer.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImpl.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImplementor.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/AbstractStatementProxy.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ConnectionProxy.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/PreparedStatementProxy.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetProxy.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/TestingServiceImpl.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/BasicConnectionProxyTest.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java
Log:
applied some lessons learned from the direct impl approach

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -32,5 +32,6 @@
 
 	public boolean hasRegisteredResources();
 
+	public void releaseResources();
 	public void close();
 }

Deleted: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -1,27 +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;
-
-/**
- * Observer contract
- *
- * @author Steve Ebersole
- */
-public interface Observer {
-	public void physicalConnectionObtained();
-	public void physicalConnectionReleased();
-	public void logicalConnectionClosed();
-}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ResultSetWrapper.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ResultSetWrapper.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ResultSetWrapper.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -0,0 +1,33 @@
+/*
+ * 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.ResultSet;
+
+/**
+ * Extra contract for {@link ResultSet} proxies, for clients to be able to
+ * obtain the wrapped resultset.
+ *
+ * @author Steve Ebersole
+ */
+public interface ResultSetWrapper {
+	/**
+	 * Obtain the wrapped resultset to which this wrapper is delegating.
+	 *
+	 * @return The wrapped resultset.
+	 */
+	public ResultSet getWrappedResultSet();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/StatementWrapper.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/StatementWrapper.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/StatementWrapper.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -0,0 +1,33 @@
+/*
+ * 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.Statement;
+
+/**
+ * Extra contract for {@link Statement} proxies, for clients to be able to
+ * obtain the wrapped statement.
+ *
+ * @author Steve Ebersole
+ */
+public interface StatementWrapper {
+	/**
+	 * Obtain the wrapped statement to which this wrapper is delegating.
+	 *
+	 * @return The wrapped statement.
+	 */
+	public Statement getWrappedStatement();
+}

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/BasicJDBCContainer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/BasicJDBCContainer.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/BasicJDBCContainer.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -15,15 +15,19 @@
  */
 package org.hibernate.jdbc.impl;
 
+import java.sql.ResultSet;
 import java.sql.Statement;
-import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
 import java.util.HashSet;
-import java.util.Iterator;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.hibernate.HibernateException;
+import org.hibernate.jdbc.util.ExceptionHelper;
 import org.hibernate.jdbc.JDBCContainer;
 
 /**
@@ -34,55 +38,111 @@
 public class BasicJDBCContainer implements JDBCContainer {
 	private static final Logger log = LoggerFactory.getLogger( BasicJDBCContainer.class );
 
-	protected final HashSet registeredStatements = new HashSet();
-	protected final HashSet registeredResultSets = new HashSet();
+	private final ExceptionHelper exceptionHelper;
+	protected final HashMap xref = new HashMap();
 
-	public final void register(Statement statement) {
-		log.trace( "registering prepared statement [" + statement + "]" );
-		registeredStatements.add( statement );
+	public BasicJDBCContainer(ExceptionHelper exceptionHelper) {
+		this.exceptionHelper = exceptionHelper;
 	}
 
-	public final void release(Statement statement) {
-		log.trace( "releasing prepared statement [" + statement + "]" );
-		registeredStatements.remove( statement );
+	public void register(Statement statement) {
+		log.trace( "registering statement [" + statement + "]" );
+		if ( xref.containsKey( statement ) ) {
+			throw new HibernateException( "statement already registered with JDBCContainer" );
+		}
+		xref.put( statement, null );
+	}
+
+	public void release(Statement statement) {
+		log.trace( "releasing statement [" + statement + "]" );
+		Set resultSets = ( Set ) xref.get( statement );
+		if ( resultSets != null ) {
+			Iterator itr = resultSets.iterator();
+			while ( itr.hasNext() ) {
+				final ResultSet resultSet = ( ResultSet ) itr.next();
+				close( resultSet );
+			}
+			resultSets.clear();
+		}
+		xref.remove( statement );
 		close( statement );
 	}
 
-	public final void register(ResultSet resultSet) {
+	public void register(ResultSet resultSet) {
 		log.trace( "registering result set [" + resultSet + "]" );
-		registeredResultSets.add( resultSet );
+		Statement statement;
+		try {
+			statement = resultSet.getStatement();
+		}
+		catch ( SQLException e ) {
+			throw exceptionHelper.convert( e, "unable to access statement from resultset" );
+		}
+		if ( log.isWarnEnabled() && !xref.containsKey( statement ) ) {
+			log.warn( "resultset's statement was not yet registered" );
+		}
+		Set resultSets = ( Set ) xref.get( statement );
+		if ( resultSets == null ) {
+			resultSets = new HashSet();
+			xref.put( statement, resultSets );
+		}
+		resultSets.add( resultSet );
 	}
 
-	public final void release(ResultSet resultSet) {
-		log.trace( "releasing result set [" + resultSet + "]" );
-		registeredResultSets.remove( resultSet );
+	public void release(ResultSet resultSet) {
+		log.trace( "releasing result set [{}]", resultSet );
+		Statement statement;
+		try {
+			statement = resultSet.getStatement();
+		}
+		catch ( SQLException e ) {
+			throw exceptionHelper.convert( e, "unable to access statement from resultset" );
+		}
+		if ( log.isWarnEnabled() && !xref.containsKey( statement ) ) {
+			log.warn( "resultset's statement was not registered" );
+		}
+		Set resultSets = ( Set ) xref.get( statement );
+		if ( resultSets != null ) {
+			resultSets.remove( resultSet );
+		}
 		close( resultSet );
 	}
 
 	public boolean hasRegisteredResources() {
-		return ! ( registeredStatements.isEmpty() && registeredResultSets.isEmpty() );
+		return !xref.isEmpty();
 	}
 
-	public void close() {
-		log.trace( "closing JDBC container [" + this + "]" );
-		Iterator iter;
-		iter = registeredResultSets.iterator();
-		while ( iter.hasNext() ) {
-			close( ( ResultSet ) iter.next() );
-		}
-		registeredResultSets.clear();
+	public void releaseResources() {
+		log.trace( "releasing JDBC container resources [{}]", this );
+		cleanup();
+	}
 
-		iter = registeredStatements.iterator();
-		while ( iter.hasNext() ) {
-			close( ( Statement ) iter.next() );
+	private void cleanup() {
+		Iterator statementIterator = xref.keySet().iterator();
+		while ( statementIterator.hasNext() ) {
+			final Statement statement = ( Statement ) statementIterator.next();
+			final Set resultSets = ( Set ) xref.get( statement );
+			if ( resultSets != null ) {
+				Iterator resultSetIterator = resultSets.iterator();
+				while ( resultSetIterator.hasNext() ) {
+					final ResultSet resultSet = ( ResultSet ) resultSetIterator.next();
+					close( resultSet );
+				}
+				resultSets.clear();
+			}
+			close( statement );
 		}
-		registeredStatements.clear();
+		xref.clear();
 	}
 
+	public void close() {
+		log.trace( "closing JDBC container [{}]", this );
+		cleanup();
+	}
+
 	protected void close(Statement statement) {
-		log.trace( "closing prepared statement [" + statement + "]" );
+		log.trace( "closing prepared statement [{}]", statement );
 		try {
-			// if we are unable to "clan" the prepared statement,
+			// if we are unable to "clean" the prepared statement,
 			// we do not close it
 			try {
 				if ( statement.getMaxRows() != 0 ) {
@@ -94,23 +154,23 @@
 			}
 			catch( SQLException sqle ) {
 				// there was a problem "cleaning" the prepared statement
-				log.debug( "Exception clearing maxRows/queryTimeout [" + sqle.getMessage() + "]" );
+				log.debug( "Exception clearing maxRows/queryTimeout [{}]", sqle.getMessage() );
 				return; // EARLY EXIT!!!
 			}
 			statement.close();
 		}
 		catch( SQLException sqle ) {
-			log.debug( "Unable to release statement [" + sqle.getMessage() + "]" );
+			log.debug( "Unable to release statement [{}]", sqle.getMessage() );
 		}
 	}
 
 	protected void close(ResultSet resultSet) {
-		log.trace( "closing result set [" + resultSet + "]" );
+		log.trace( "closing result set [{}]", resultSet );
 		try {
 			resultSet.close();
 		}
 		catch( SQLException e ) {
-			log.debug( "Unable to release result set [" + e.getMessage() + "]" );
+			log.debug( "Unable to release result set [{}]", e.getMessage() );
 		}
 	}
 }

Copied: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ConnectionObserver.java (from rev 12911, sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java)
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ConnectionObserver.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/ConnectionObserver.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * ConnectionObserver contract
+ *
+ * @author Steve Ebersole
+ */
+public interface ConnectionObserver {
+	public void physicalConnectionObtained();
+	public void physicalConnectionReleased();
+	public void logicalConnectionClosed();
+}

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImpl.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImpl.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImpl.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -29,7 +29,6 @@
 import org.hibernate.JDBCException;
 import org.hibernate.jdbc.JDBCServices;
 import org.hibernate.jdbc.JDBCContainer;
-import org.hibernate.jdbc.Observer;
 
 /**
  * LogicalConnectionImpl implementation
@@ -84,28 +83,13 @@
 	/**
 	 * {@inheritDoc}
 	 */
-	public void addObserver(Observer observer) {
+	public void addObserver(ConnectionObserver observer) {
 		observers.add( observer );
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public void afterStatement() {
-		// todo : implement...
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	public void afterTransaction() {
-		// todo : implement...
-	}
-
-
-	/**
-	 * {@inheritDoc}
-	 */
 	public boolean isOpen() {
 		return !isClosed;
 	}
@@ -141,14 +125,14 @@
 		log.trace( "closing logical connection" );
 		Connection c = physicalConnection;
 		if ( !isUserSuppliedConnection && physicalConnection != null ) {
+			jdbcContainer.close();
 			releaseConnection();
 		}
 		// not matter what
 		physicalConnection = null;
 		isClosed = true;
-		jdbcContainer.close();
 		for ( Iterator itr = observers.iterator(); itr.hasNext(); ) {
-			( ( Observer ) itr.next() ).logicalConnectionClosed();
+			( ( ConnectionObserver ) itr.next() ).logicalConnectionClosed();
 		}
 		log.trace( "logical connection closed" );
 		return c;
@@ -165,20 +149,26 @@
 //	public boolean isAutoCommit() throws SQLException {
 //		return physicalConnection == null || physicalConnection.getAutoCommit();
 //	}
-//
-//	/**
-//	 * Force aggresive release of the underlying connection.
-//	 */
-//	public void aggressiveRelease() {
-//		if ( !isUserSuppliedConnection ) {
-//			log.debug( "aggressively releasing JDBC connection" );
-//			if ( physicalConnection != null ) {
-//				releaseConnection();
-//			}
-//		}
-//	}
 
+	/**
+	 * Force aggresive release of the underlying connection.
+	 */
+	public void aggressiveRelease() {
+		if ( isUserSuppliedConnection ) {
+			log.debug( "cannot aggresively release user-supplied connection; skipping" );
+		}
+		else if ( ! getJdbcServices().getConnectionProvider().supportsAggressiveRelease() ) {
+			log.debug( "connection provider reports to not support aggreswsive release; skipping" );
+		}
+		else {
+			log.debug( "aggressively releasing JDBC connection" );
+			if ( physicalConnection != null ) {
+				releaseConnection();
+			}
+		}
+	}
 
+
 	/**
 	 * Pysically opens a JDBC Connection.
 	 *
@@ -189,7 +179,7 @@
 		try {
 			physicalConnection = getJdbcServices().getConnectionProvider().getConnection();
 			for ( Iterator itr = observers.iterator(); itr.hasNext(); ) {
-				( ( Observer ) itr.next() ).physicalConnectionObtained();
+				( ( ConnectionObserver ) itr.next() ).physicalConnectionObtained();
 			}
 			log.debug( "obtained JDBC connection" );
 		}
@@ -209,11 +199,11 @@
 			if ( !physicalConnection.isClosed() ) {
 				getJdbcServices().getExceptionHelper().logAndClearWarnings( physicalConnection );
 			}
-			getJdbcServices().getConnectionProvider().closeConnection( physicalConnection );
-			physicalConnection = null;
 			for ( Iterator itr = observers.iterator(); itr.hasNext(); ) {
-				( ( Observer ) itr.next() ).physicalConnectionReleased();
+				( ( ConnectionObserver ) itr.next() ).physicalConnectionReleased();
 			}
+			getJdbcServices().getConnectionProvider().closeConnection( physicalConnection );
+			physicalConnection = null;
 			log.debug( "released JDBC connection" );
 		}
 		catch (SQLException sqle) {

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImplementor.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImplementor.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImplementor.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -19,7 +19,6 @@
 import org.hibernate.jdbc.JDBCContainer;
 import org.hibernate.jdbc.JDBCServices;
 import org.hibernate.jdbc.LogicalConnection;
-import org.hibernate.jdbc.Observer;
 
 /**
  * The "internal" contract for LogicalConnection
@@ -34,9 +33,7 @@
 
 	public JDBCContainer getJdbcContainer();
 
-	public void addObserver(Observer observer);
+	public void addObserver(ConnectionObserver observer);
 
-	public void afterStatement();
-
-	public void afterTransaction();
+	public void aggressiveRelease();
 }

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/AbstractStatementProxy.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/AbstractStatementProxy.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/AbstractStatementProxy.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -18,15 +18,9 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,24 +35,22 @@
  * @author Steve Ebersole
  */
 public abstract class AbstractStatementProxy implements InvocationHandler {
-	public static final Class[] PROXY_INTERFACES = new Class[] { Statement.class };
-	public static final Class[] PS_PROXY_INTERFACES = new Class[] { PreparedStatement.class };
-	public static final Class[] CS_PROXY_INTERFACES = new Class[] { CallableStatement.class };
 
 	private static final Logger log = LoggerFactory.getLogger( AbstractStatementProxy.class );
 
 	private boolean valid = true;
 	private Statement statement;
 	private ConnectionProxy connectionProxy;
-	private Set resultSetProxies;
 
 	protected AbstractStatementProxy(Statement statement, ConnectionProxy connectionProxy) {
 		this.statement = statement;
 		this.connectionProxy = connectionProxy;
-		getJdbcContainer().register( statement );
 	}
 
 	protected Statement getStatement() {
+		if ( !valid ) {
+			throw new HibernateException( "statment proxy is no longer valid" );
+		}
 		return statement;
 	}
 
@@ -66,10 +58,6 @@
 		return connectionProxy;
 	}
 
-	protected Set getResultSetProxies() {
-		return resultSetProxies;
-	}
-
 	protected JDBCServices getJdbcServices() {
 		return getConnectionProxy().getJdbcServices();
 	}
@@ -78,19 +66,12 @@
 		return getConnectionProxy().getJdbcContainer();
 	}
 
-	protected Set getOrCreateResultSetProxies() {
-		if ( resultSetProxies == null ) {
-			resultSetProxies = new HashSet();
-		}
-		return resultSetProxies;
-	}
-
 	public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 		String methodName = method.getName();
 		log.trace( "Handling invocation of statement method [{}]", methodName );
 
-		if ( !valid ) {
-			throw new HibernateException( "connection handle is invalid" );
+		if ( "toString".equals( methodName ) ) {
+			return this.toString();
 		}
 
 		if ( "close".equals( methodName ) ) {
@@ -98,6 +79,19 @@
 			return null;
 		}
 
+		if ( "invalidate".equals( methodName ) ) {
+			invalidateHandle();
+			return null;
+		}
+
+		if ( "getWrappedStatement".equals( methodName ) ) {
+			return getStatement();
+		}
+
+		if ( !valid ) {
+			throw new HibernateException( "connection handle is no longer valid" );
+		}
+
 		beginningInvocationHandling( method, args );
 
 		try {
@@ -106,13 +100,8 @@
 			Object result = method.invoke( statement, args );
 
 			if ( exposingResultSet ) {
-				ResultSetProxy handler = new ResultSetProxy( ( ResultSet ) result, this );
-				result = Proxy.newProxyInstance(
-						getClass().getClassLoader(),
-						ResultSetProxy.PROXY_INTERFACES,
-						handler
-				);
-				getOrCreateResultSetProxies().add( result );
+				result = ProxyBuilder.buildResultSet( ( ResultSet ) result, this );
+				getJdbcContainer().register( ( ResultSet ) result );
 			}
 
 			return result;
@@ -132,26 +121,14 @@
 	}
 
 	private void explicitClose(Statement proxy) {
-		if ( resultSetProxies != null ) {
-			Iterator itr = resultSetProxies.iterator();
-			while ( itr.hasNext() ) {
-				final ResultSet resultSetProxy = ( ResultSet ) itr.next();
-				try {
-					resultSetProxy.close();
-				}
-				catch ( SQLException e ) {
-					// should never ever happen...
-					log.warn( "unhandled SQLException escaped proxy handling!", e );
-					// but the underlying resources should still get cleaned up when the logical connection closes...
-				}
-				itr.remove();
-			}
+		if ( valid ) {
+			getJdbcContainer().release( proxy );
 		}
-		connectionProxy.getJdbcContainer().release( statement );
-		connectionProxy.proxiedStatementExplicitlyClosed( proxy );
-		statement = null;
+	}
+
+	private void invalidateHandle() {
 		connectionProxy = null;
-		resultSetProxies = null;
+		statement = null;
 		valid = false;
 	}
 
@@ -159,8 +136,4 @@
 		return ResultSet.class.isAssignableFrom( method.getReturnType() )
 				&& !method.getName().equals( "getGeneratedKeys" );
 	}
-
-	/*package-protected*/ void proxiedResultSetExplicitlyClosed(ResultSet proxy) {
-		resultSetProxies.remove( proxy );
-	}
 }

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ConnectionProxy.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ConnectionProxy.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ConnectionProxy.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -18,23 +18,19 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
+import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.hibernate.HibernateException;
-import org.hibernate.jdbc.ConnectionWrapper;
 import org.hibernate.jdbc.JDBCContainer;
 import org.hibernate.jdbc.JDBCServices;
-import org.hibernate.jdbc.Observer;
+import org.hibernate.jdbc.impl.ConnectionObserver;
 import org.hibernate.jdbc.impl.LogicalConnectionImplementor;
 
 /**
@@ -42,14 +38,12 @@
  *
  * @author Steve Ebersole
  */
-public class ConnectionProxy implements InvocationHandler, Observer {
-	public static final Class[] PROXY_INTERFACES = new Class[] { Connection.class, ConnectionWrapper.class };
+public class ConnectionProxy implements InvocationHandler, ConnectionObserver {
 
 	private static final Logger log = LoggerFactory.getLogger( ConnectionProxy.class );
 
 	private boolean valid = true;
 	private LogicalConnectionImplementor logicalConnection;
-	private HashSet statementProxies;
 
 	public ConnectionProxy(LogicalConnectionImplementor logicalConnection) {
 		this.logicalConnection = logicalConnection;
@@ -58,8 +52,17 @@
 
 	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 		String methodName = method.getName();
-		log.trace( "Handling invocation of Connection method [{}]", methodName );
+		log.trace( "Handling invocation of connection method [{}]", methodName );
 
+		if ( "close".equals( methodName ) ) {
+			explicitClose();
+			return null;
+		}
+
+		if ( "toString".equals( methodName ) ) {
+			return this.toString();
+		}
+
 		if ( !valid ) {
 			throw new HibernateException( "connection handle is invalid" );
 		}
@@ -68,11 +71,6 @@
 			return extractPhysicalConnection();
 		}
 
-		if ( "close".equals( methodName ) ) {
-			explicitClose();
-			return null;
-		}
-
 		try {
 			boolean creatingBasicStatement = "createStatement".equals( methodName );
 			boolean creatingPreparedStatement = "prepareStatement".equals( methodName );
@@ -81,27 +79,16 @@
 			Object result = method.invoke( extractPhysicalConnection(), args );
 
 			if ( creatingBasicStatement || creatingPreparedStatement || creatingCallableStatement ) {
-				AbstractStatementProxy proxyHandler;
-				Class[] interfaces;
 				if ( creatingPreparedStatement ) {
-					proxyHandler = new PreparedStatementProxy( ( String ) args[0], ( PreparedStatement ) result, this );
-					interfaces = AbstractStatementProxy.PS_PROXY_INTERFACES;
+					result = ProxyBuilder.buildPreparedStatement( ( String ) args[0], ( PreparedStatement ) result, this );
 				}
 				else if ( creatingCallableStatement ) {
-					proxyHandler = new PreparedStatementProxy( ( String ) args[0], ( PreparedStatement ) result, this );
-					interfaces = AbstractStatementProxy.CS_PROXY_INTERFACES;
+					result = ProxyBuilder.buildCallableStatement( ( String ) args[0], ( CallableStatement ) result, this );
 				}
 				else {
-					proxyHandler = new StatementProxy( ( Statement ) result, this );
-					interfaces = AbstractStatementProxy.PROXY_INTERFACES;
+					result = ProxyBuilder.buildStatement( ( Statement ) result, this );
 				}
-
-				result = Proxy.newProxyInstance(
-						getClass().getClassLoader(), // use our classloader
-						interfaces,
-						proxyHandler
-				);
-				getOrCreateStatementProxies().add( result );
+				getJdbcContainer().register( ( Statement ) result );
 			}
 
 			return result;
@@ -109,7 +96,7 @@
 		catch( InvocationTargetException e ) {
 			Throwable realException = e.getTargetException();
 			if ( SQLException.class.isInstance( realException ) ) {
-				throw logicalConnection.getJdbcServices().getExceptionHelper().convert( ( SQLException ) realException, "???", "???" );
+				throw logicalConnection.getJdbcServices().getExceptionHelper().convert( ( SQLException ) realException, realException.getMessage(), "???" );
 			}
 			else {
 				throw realException;
@@ -117,49 +104,22 @@
 		}
 	}
 
-	private Set getOrCreateStatementProxies() {
-		if ( statementProxies == null ) {
-			statementProxies = new HashSet();
-		}
-		return statementProxies;
-	}
-
 	private void explicitClose() {
-		if ( statementProxies != null ) {
-			Iterator itr = statementProxies.iterator();
-			while ( itr.hasNext() ) {
-				final Statement proxy = ( Statement ) itr.next();
-				try {
-					proxy.close();
-				}
-				catch ( SQLException e ) {
-					// should never ever happen...
-					log.warn( "unhandled SQLException escaped proxy handling!", e );
-					// but the underlying resources should still get cleaned up when the logical connection closes...
-				}
-			}
+		if ( valid ) {
+			invalidateHandle();
 		}
-		invalidateHandle();
 	}
 
 	private void invalidateHandle() {
 		log.trace( "Invalidating connection handle" );
 		logicalConnection = null;
 		valid = false;
-		if ( statementProxies != null ) {
-			statementProxies.clear();
-			statementProxies = null;
-		}
 	}
 
 	private Connection extractPhysicalConnection() {
 		return logicalConnection.getConnection();
 	}
 
-	/*package-protected*/ void proxiedStatementExplicitlyClosed(Statement proxy) {
-		statementProxies.remove( proxy );
-	}
-
 	/*package-protected*/ JDBCServices getJdbcServices() {
 		return logicalConnection.getJdbcServices();
 	}
@@ -168,7 +128,7 @@
 		return logicalConnection.getJdbcContainer();
 	}
 
-	// JDBC Observer impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+	// JDBC ConnectionObserver impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 	public void physicalConnectionObtained() {
 	}

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/PreparedStatementProxy.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/PreparedStatementProxy.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/PreparedStatementProxy.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -16,6 +16,7 @@
 package org.hibernate.jdbc.proxy;
 
 import java.sql.Statement;
+import java.lang.reflect.Method;
 
 /**
  * PreparedStatementProxy implementation
@@ -30,4 +31,31 @@
 		connectionProxy.getJdbcServices().getSqlStatementLogger().logStatement( sql );
 		this.sql = sql;
 	}
+
+	protected void beginningInvocationHandling(Method method, Object[] args) {
+		if ( isExecution( method ) ) {
+			logExecution();
+		}
+		else {
+			journalPossibleParameterBind( method, args );
+		}
+	}
+
+	private void journalPossibleParameterBind(Method method, Object[] args) {
+		String methodName = method.getName();
+		// todo : is this enough???
+		if ( methodName.startsWith( "set" ) && args != null && args.length >= 2 ) {
+			journalParameterBind( method, args );
+		}
+	}
+
+	private void journalParameterBind(Method method, Object[] args) {
+	}
+
+	private boolean isExecution(Method method) {
+		return false;
+	}
+
+	private void logExecution() {
+	}
 }

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyBuilder.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -0,0 +1,89 @@
+/*
+ * 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 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 org.hibernate.jdbc.ConnectionWrapper;
+import org.hibernate.jdbc.impl.LogicalConnectionImplementor;
+
+/**
+ * ProxyBuilder implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ProxyBuilder {
+
+	// static for now simply to alleviate question about where to keep it...
+
+	public static final Class[] CONNECTION_PROXY_INTERFACES = new Class[] { Connection.class, ConnectionWrapper.class };
+
+	public static final Class[] STMNT_PROXY_INTERFACES = new Class[] { Statement.class, StatementWrapperImplementor.class };
+	public static final Class[] PREPARED_STMNT_PROXY_INTERFACES = new Class[] { PreparedStatement.class, StatementWrapperImplementor.class };
+	public static final Class[] CALLABLE_STMNT_PROXY_INTERFACES = new Class[] { CallableStatement.class, StatementWrapperImplementor.class };
+
+	public static final Class[] RESULTSET_PROXY_INTERFACES = new Class[] { ResultSet.class, ResultSetWrapperImplementor.class };
+
+	public static Connection buildConnection(LogicalConnectionImplementor logicalConnection) {
+		ConnectionProxy proxyHandler = new ConnectionProxy( logicalConnection );
+		return ( Connection ) Proxy.newProxyInstance(
+				ConnectionWrapper.class.getClassLoader(),
+				CONNECTION_PROXY_INTERFACES,
+				proxyHandler
+		);
+	}
+
+	public static Statement buildStatement(Statement statement, ConnectionProxy connectionProxy) {
+		StatementProxy proxyHandler = new StatementProxy( statement, connectionProxy );
+		return ( Statement ) Proxy.newProxyInstance(
+				StatementWrapperImplementor.class.getClassLoader(),
+				STMNT_PROXY_INTERFACES,
+				proxyHandler
+		);
+	}
+
+	public static PreparedStatement buildPreparedStatement(String sql, PreparedStatement statement, ConnectionProxy connectionProxy) {
+		PreparedStatementProxy proxyHandler = new PreparedStatementProxy( sql, statement, connectionProxy );
+		return ( PreparedStatement ) Proxy.newProxyInstance(
+				StatementWrapperImplementor.class.getClassLoader(),
+				PREPARED_STMNT_PROXY_INTERFACES,
+				proxyHandler
+		);
+	}
+
+	public static CallableStatement buildCallableStatement(String sql, CallableStatement statement, ConnectionProxy connectionProxy) {
+		PreparedStatementProxy proxyHandler = new PreparedStatementProxy( sql, statement, connectionProxy );
+		return ( CallableStatement ) Proxy.newProxyInstance(
+				StatementWrapperImplementor.class.getClassLoader(),
+				CALLABLE_STMNT_PROXY_INTERFACES,
+				proxyHandler
+		);
+	}
+
+	public static ResultSet buildResultSet(ResultSet resultSet, AbstractStatementProxy statementProxy) {
+		ResultSetProxy proxyHandler = new ResultSetProxy( resultSet, statementProxy );
+		return ( ResultSet ) Proxy.newProxyInstance(
+				ResultSetWrapperImplementor.class.getClassLoader(),
+				RESULTSET_PROXY_INTERFACES,
+				proxyHandler
+		);
+	}
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ProxyJDBCContainer.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -0,0 +1,55 @@
+/*
+ * 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 java.sql.Statement;
+import java.sql.ResultSet;
+
+import org.hibernate.jdbc.impl.BasicJDBCContainer;
+import org.hibernate.jdbc.util.ExceptionHelper;
+
+/**
+ * ProxyJDBCContainer implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ProxyJDBCContainer extends BasicJDBCContainer {
+	public ProxyJDBCContainer(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 );
+		}
+	}
+}

Modified: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetProxy.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetProxy.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetProxy.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -25,6 +25,8 @@
 import org.slf4j.LoggerFactory;
 
 import org.hibernate.HibernateException;
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.JDBCContainer;
 
 /**
  * ResultSetProxy implementation
@@ -32,7 +34,6 @@
  * @author Steve Ebersole
  */
 public class ResultSetProxy implements InvocationHandler {
-	public static final Class[] PROXY_INTERFACES = new Class[] { ResultSet.class };
 
 	private static final Logger log = LoggerFactory.getLogger( ResultSetProxy.class );
 
@@ -46,12 +47,35 @@
 		associatedStatementProxy.getJdbcContainer().register( physicalResultSet );
 	}
 
+	protected ResultSet getResultSet() {
+		errorIfInvalid();
+		return physicalResultSet;
+	}
+
+	protected void errorIfInvalid() {
+		if ( !valid ) {
+			throw new HibernateException( "resultset handle is no longer valid" );
+		}
+	}
+
+	protected AbstractStatementProxy getStatementProxy() {
+		return associatedStatementProxy;
+	}
+
+	protected JDBCServices getJdbcServices() {
+		return getStatementProxy().getJdbcServices();
+	}
+
+	protected JDBCContainer getJdbcContainer() {
+		return getStatementProxy().getJdbcContainer();
+	}
+
 	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 		String methodName = method.getName();
 		log.trace( "Handling invocation of resultset method [{}]", methodName );
 
-		if ( !valid ) {
-			throw new HibernateException( "connection handle is invalid" );
+		if ( "toString".equals( methodName ) ) {
+			return this.toString();
 		}
 
 		if ( "close".equals( methodName ) ) {
@@ -59,13 +83,24 @@
 			return null;
 		}
 
+		if ( "invalidate".equals( methodName ) ) {
+			invalidateHandle();
+			return null;
+		}
+
+		if ( "getWrappedStatement".equals( methodName ) ) {
+			return getResultSet();
+		}
+
+		errorIfInvalid();
+
 		try {
 			return method.invoke( physicalResultSet, args );
 		}
 		catch ( InvocationTargetException e ) {
 			Throwable realException = e.getTargetException();
 			if ( SQLException.class.isInstance( realException ) ) {
-				throw associatedStatementProxy.getJdbcServices().getExceptionHelper().convert( ( SQLException ) realException, "???", "???" );
+				throw getJdbcServices().getExceptionHelper().convert( ( SQLException ) realException, "???" );
 			}
 			else {
 				throw realException;
@@ -74,10 +109,14 @@
 	}
 
 	private void explicitClose(ResultSet proxy) {
-		associatedStatementProxy.getJdbcContainer().release( physicalResultSet );
-		associatedStatementProxy.proxiedResultSetExplicitlyClosed( proxy );
+		if ( valid ) {
+			associatedStatementProxy.getJdbcContainer().release( proxy );
+		}
+	}
+
+	private void invalidateHandle() {
+		associatedStatementProxy = null;
 		physicalResultSet = null;
-		associatedStatementProxy = null;
 		valid = false;
 	}
 }

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ResultSetWrapperImplementor.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -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.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();
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementWrapperImplementor.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -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.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();
+}

Modified: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/TestingServiceImpl.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/TestingServiceImpl.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/TestingServiceImpl.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -41,11 +41,6 @@
 	public void prepare() {
 		connectionProvider = ConnectionProviderBuilder.buildConnectionProvider();
 		sqlStatementLogger = new SQLStatementLogger( true );
-		jdbcContainerBuilder = new JDBCContainerBuilder() {
-			public JDBCContainer buildJdbcContainer() {
-				return new BasicJDBCContainer();
-			}
-		};
 		exceptionHelper = new ExceptionHelper(
 				new SQLStateConverter(
 						new ViolatedConstraintNameExtracter() {
@@ -55,6 +50,11 @@
 						}
 				)
 		);
+		jdbcContainerBuilder = new JDBCContainerBuilder() {
+			public JDBCContainer buildJdbcContainer() {
+				return new BasicJDBCContainer( exceptionHelper );
+			}
+		};
 	}
 
 	public void release() {

Modified: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/BasicConnectionProxyTest.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/BasicConnectionProxyTest.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/BasicConnectionProxyTest.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -35,7 +35,6 @@
 import org.hibernate.JDBCException;
 import org.hibernate.jdbc.ConnectionWrapper;
 import org.hibernate.jdbc.impl.LogicalConnectionImpl;
-import org.hibernate.jdbc.impl.TestingServiceImpl;
 
 /**
  * BasicConnectionProxyTest implementation
@@ -45,7 +44,7 @@
 public class BasicConnectionProxyTest {
 	private static final Logger log = LoggerFactory.getLogger( BasicConnectionProxyTest.class );
 
-	private org.hibernate.jdbc.impl.TestingServiceImpl services = new TestingServiceImpl();
+	private TestingServiceImpl services = new TestingServiceImpl();
 
 	@BeforeClass
 	protected void create() {
@@ -79,7 +78,7 @@
 			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();
+			logicalConnection.getJdbcContainer().releaseResources();
 			assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
 
 			PreparedStatement ps = proxiedConnection.prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );

Modified: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java	2007-08-14 14:27:03 UTC (rev 12933)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java	2007-08-14 17:15:42 UTC (rev 12934)
@@ -21,7 +21,6 @@
 import org.hibernate.jdbc.JDBCContainerBuilder;
 import org.hibernate.jdbc.ConnectionProviderBuilder;
 import org.hibernate.jdbc.JDBCContainer;
-import org.hibernate.jdbc.impl.BasicJDBCContainer;
 import org.hibernate.jdbc.util.SQLStatementLogger;
 import org.hibernate.jdbc.util.ExceptionHelper;
 import org.hibernate.connection.ConnectionProvider;
@@ -42,12 +41,6 @@
 	public void prepare() {
 		connectionProvider = ConnectionProviderBuilder.buildConnectionProvider();
 		sqlStatementLogger = new SQLStatementLogger( true );
-		jdbcContainerBuilder = new JDBCContainerBuilder() {
-			public JDBCContainer buildJdbcContainer() {
-				// todo : need to over ride this to handle statement/resultset proxies properly
-				return new BasicJDBCContainer();
-			}
-		};
 		exceptionHelper = new ExceptionHelper(
 				new SQLStateConverter(
 						new ViolatedConstraintNameExtracter() {
@@ -57,6 +50,11 @@
 						}
 				)
 		);
+		jdbcContainerBuilder = new JDBCContainerBuilder() {
+			public JDBCContainer buildJdbcContainer() {
+				return new ProxyJDBCContainer( exceptionHelper );
+			}
+		};
 	}
 
 	public void release() {




More information about the hibernate-commits mailing list