[hibernate-commits] Hibernate SVN: r12911 - in sandbox/trunk: jdbc-proxy and 18 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Aug 9 15:54:17 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-08-09 15:54:17 -0400 (Thu, 09 Aug 2007)
New Revision: 12911

Added:
   sandbox/trunk/jdbc-proxy/
   sandbox/trunk/jdbc-proxy/pom.xml
   sandbox/trunk/jdbc-proxy/src/
   sandbox/trunk/jdbc-proxy/src/main/
   sandbox/trunk/jdbc-proxy/src/main/java/
   sandbox/trunk/jdbc-proxy/src/main/java/org/
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ConnectionWrapper.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainerBuilder.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCServices.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/LogicalConnection.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/
   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/
   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/StatementProxy.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/ExceptionHelper.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/SQLStatementLogger.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/Observer.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/ResourceTransaction.java
   sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/TransactionCoordinator.java
   sandbox/trunk/jdbc-proxy/src/test/
   sandbox/trunk/jdbc-proxy/src/test/java/
   sandbox/trunk/jdbc-proxy/src/test/java/org/
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/ConnectionProviderBuilder.java
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/
   sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/BasicConnectionTests.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/
   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
   sandbox/trunk/jdbc-proxy/src/test/resources/
   sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties
Log:
initial checkin of possible proxy-based jdbc interaction


Property changes on: sandbox/trunk/jdbc-proxy
___________________________________________________________________
Name: svn:ignore
   + target
test-output
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover


Added: sandbox/trunk/jdbc-proxy/pom.xml
===================================================================
--- sandbox/trunk/jdbc-proxy/pom.xml	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/pom.xml	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,73 @@
+ <project xmlns="http://maven.apache.org/POM/4.0.0" 
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.hibernate</groupId>
+        <artifactId>hibernate-core-parent</artifactId>
+        <version>1</version>
+    </parent>
+
+    <groupId>org.hibernate.sandbox</groupId>
+    <artifactId>jdbc-proxy</artifactId>
+    <version>1</version>
+    <packaging>jar</packaging>
+
+    <name>JDBC Proxy (sandbox)</name>
+    <description>PoC of a proxy-based approach to JDBC interaction</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-core</artifactId>
+            <version>3.3.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.4.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.14</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>5.5</version>
+            <classifier>jdk15</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>1.8.0.2</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+     <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+              </plugin>
+         </plugins>
+     </build>
+
+</project>
+

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ConnectionWrapper.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ConnectionWrapper.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/ConnectionWrapper.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Extra contract for {@link java.sql.Connection} proxies, for clients to be able to
+ * obtain the wrapped connection.
+ *
+ * @author Steve Ebersole
+ */
+public interface ConnectionWrapper {
+	/**
+	 * Obtain the wrapped connection being delegated to.
+	 * <p/>
+	 * NOTE : The scope of validity for the returned connection is
+	 * undefined.
+	 * 
+	 * @return The wrapped connection.
+	 */
+	public Connection getWrappedConnection();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainer.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,35 @@
+/*
+ * 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;
+import java.sql.Statement;
+
+/**
+ * JDBCContainer contract
+ *
+ * @author Steve Ebersole
+ */
+public interface JDBCContainer {
+	public void register(Statement statement);
+	public void release(Statement statement);
+	public void register(ResultSet resultSet);
+	public void release(ResultSet resultSet);
+
+	public boolean hasRegisteredResources();
+
+	public void close();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainerBuilder.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainerBuilder.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCContainerBuilder.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * Contract for building {@link JDBCContainer} instances.
+ * <p/>
+ * Used mainly to make explicit the contract that a
+ * {@link LogicalConnection} owns the lifecycle of the container.
+ *
+ * @author Steve Ebersole
+ */
+public interface JDBCContainerBuilder {
+	public JDBCContainer buildJdbcContainer();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCServices.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCServices.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/JDBCServices.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,32 @@
+/*
+ * 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 org.hibernate.connection.ConnectionProvider;
+import org.hibernate.jdbc.util.ExceptionHelper;
+import org.hibernate.jdbc.util.SQLStatementLogger;
+
+/**
+ * Contract for services around JDBC operations.
+ *
+ * @author Steve Ebersole
+ */
+public interface JDBCServices {
+	public ConnectionProvider getConnectionProvider();
+	public JDBCContainerBuilder getJdbcContainerBuilder();
+	public SQLStatementLogger getSqlStatementLogger();
+	public ExceptionHelper getExceptionHelper();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/LogicalConnection.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/LogicalConnection.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/LogicalConnection.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -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;
+
+import java.sql.Connection;
+
+/**
+ * LogicalConnection contract
+ *
+ * @author Steve Ebersole
+ */
+public interface LogicalConnection {
+	/**
+	 * Is this LogicalConnection open?  Another phraseology sometimes used is: "are we
+	 * logically connected"?
+	 *
+	 * @return True if physically connected; false otherwise.
+	 */
+	public boolean isOpen();
+
+	/**
+	 * Is this LogicalConnection instance "physically" connected.  Meaning
+	 * do we currently internally have a cached connection.
+	 *
+	 * @return True if physically connected; false otherwise.
+	 */
+	public boolean isPhysicallyConnected();
+
+	/**
+	 * Retreives the connection currently "logically" managed by this LogicalConnectionImpl.
+	 * <p/>
+	 * Note, that we may need to obtain a connection to return here if a
+	 * connection has either not yet been obtained (non-UserSuppliedConnectionProvider)
+	 * or has previously been aggressively released.
+	 *
+	 * @return The current Connection.
+	 */
+	public Connection getConnection();
+
+	/**
+	 * Release the underlying connection and clean up any other resources associated
+	 * with this logical connection.
+	 * <p/>
+	 * This leaves the logical connection in a "no longer useable" state.
+	 *
+	 * @return The physical connection which was being used.
+	 */
+	public Connection close();
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/Observer.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -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;
+
+/**
+ * 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/impl/BasicJDBCContainer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/BasicJDBCContainer.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/BasicJDBCContainer.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,117 @@
+/*
+ * 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 java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.jdbc.JDBCContainer;
+
+/**
+ * BasicJDBCContainer implementation
+ *
+ * @author Steve Ebersole
+ */
+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();
+
+	public final void register(Statement statement) {
+		log.trace( "registering prepared statement [" + statement + "]" );
+		registeredStatements.add( statement );
+	}
+
+	public final void release(Statement statement) {
+		log.trace( "releasing prepared statement [" + statement + "]" );
+		registeredStatements.remove( statement );
+		close( statement );
+	}
+
+	public final void register(ResultSet resultSet) {
+		log.trace( "registering result set [" + resultSet + "]" );
+		registeredResultSets.add( resultSet );
+	}
+
+	public final void release(ResultSet resultSet) {
+		log.trace( "releasing result set [" + resultSet + "]" );
+		registeredResultSets.remove( resultSet );
+		close( resultSet );
+	}
+
+	public boolean hasRegisteredResources() {
+		return ! ( registeredStatements.isEmpty() && registeredResultSets.isEmpty() );
+	}
+
+	public void close() {
+		log.trace( "closing JDBC container [" + this + "]" );
+		Iterator iter;
+		iter = registeredResultSets.iterator();
+		while ( iter.hasNext() ) {
+			close( ( ResultSet ) iter.next() );
+		}
+		registeredResultSets.clear();
+
+		iter = registeredStatements.iterator();
+		while ( iter.hasNext() ) {
+			close( ( Statement ) iter.next() );
+		}
+		registeredStatements.clear();
+	}
+
+	protected final void close(Statement statement) {
+		log.trace( "closing prepared statement [" + statement + "]" );
+		try {
+			// if we are unable to "clean" the prepared statement,
+			// we do not close it
+			try {
+				if ( statement.getMaxRows() != 0 ) {
+					statement.setMaxRows( 0 );
+				}
+				if ( statement.getQueryTimeout() != 0 ) {
+					statement.setQueryTimeout( 0 );
+				}
+			}
+			catch( SQLException sqle ) {
+				// there was a problem "cleaning" the prepared statement
+				log.debug( "Exception clearing maxRows/queryTimeout [" + sqle.getMessage() + "]" );
+				return; // EARLY EXIT!!!
+			}
+			statement.close();
+		}
+		catch( SQLException sqle ) {
+			log.debug( "Unable to release statement [" + sqle.getMessage() + "]" );
+		}
+	}
+
+	protected final void close(ResultSet resultSet) {
+		log.trace( "closing result set [" + resultSet + "]" );
+		try {
+			resultSet.close();
+		}
+		catch( SQLException e ) {
+			log.debug( "Unable to release result set [" + e.getMessage() + "]" );
+		}
+	}
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImpl.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -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.impl;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.HibernateException;
+import org.hibernate.JDBCException;
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.JDBCContainer;
+import org.hibernate.jdbc.Observer;
+
+/**
+ * LogicalConnectionImpl implementation
+ *
+ * @author Steve Ebersole
+ */
+public class LogicalConnectionImpl implements LogicalConnectionImplementor {
+	private static final Logger log = LoggerFactory.getLogger( LogicalConnectionImpl.class );
+
+	private transient Connection physicalConnection;
+	private final ConnectionReleaseMode connectionReleaseMode;
+	private final JDBCServices jdbcServices;
+	private final JDBCContainer jdbcContainer;
+	private final List observers = new ArrayList();
+
+	private final boolean isUserSuppliedConnection;
+	private boolean isClosed;
+
+	public LogicalConnectionImpl(
+	        Connection userSuppliedConnection,
+	        ConnectionReleaseMode connectionReleaseMode,
+	        JDBCServices jdbcServices) {
+		this.physicalConnection = userSuppliedConnection;
+		this.connectionReleaseMode = connectionReleaseMode;
+		this.jdbcServices = jdbcServices;
+		this.jdbcContainer = jdbcServices.getJdbcContainerBuilder().buildJdbcContainer();
+
+		this.isUserSuppliedConnection = ( userSuppliedConnection != null );
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public JDBCServices getJdbcServices() {
+		return jdbcServices;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public ConnectionReleaseMode getConnectionReleaseMode() {
+		return connectionReleaseMode;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public JDBCContainer getJdbcContainer() {
+		return jdbcContainer;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void addObserver(Observer observer) {
+		observers.add( observer );
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void afterStatement() {
+		// todo : implement...
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void afterTransaction() {
+		// todo : implement...
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isOpen() {
+		return !isClosed;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isPhysicallyConnected() {
+		return physicalConnection != null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Connection getConnection() throws HibernateException {
+		if ( isClosed ) {
+			throw new HibernateException( "Logical connection is closed" );
+		}
+		if ( physicalConnection == null ) {
+			if ( isUserSuppliedConnection ) {
+				// should never happen
+				throw new HibernateException( "User-supplied connection was null" );
+			}
+			obtainConnection();
+		}
+		return physicalConnection;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Connection close() {
+		log.trace( "closing logical connection" );
+		Connection c = physicalConnection;
+		if ( !isUserSuppliedConnection && physicalConnection != null ) {
+			releaseConnection();
+		}
+		// not matter what
+		physicalConnection = null;
+		isClosed = true;
+		jdbcContainer.close();
+		for ( Iterator itr = observers.iterator(); itr.hasNext(); ) {
+			( ( Observer ) itr.next() ).logicalConnectionClosed();
+		}
+		log.trace( "logical connection closed" );
+		return c;
+	}
+
+//	/**
+//	 * Is the connection considered "auto-commit"?
+//	 *
+//	 * @return True if we either do not have a connection, or the connection
+//	 * really is in auto-commit mode.
+//	 *
+//	 * @throws SQLException Can be thrown by the Connection.isAutoCommit() check.
+//	 */
+//	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();
+//			}
+//		}
+//	}
+
+
+	/**
+	 * Pysically opens a JDBC Connection.
+	 *
+	 * @throws JDBCException Indicates problem opening a connection
+	 */
+	private void obtainConnection() throws JDBCException {
+		log.debug( "obtaining JDBC connection" );
+		try {
+			physicalConnection = getJdbcServices().getConnectionProvider().getConnection();
+			for ( Iterator itr = observers.iterator(); itr.hasNext(); ) {
+				( ( Observer ) itr.next() ).physicalConnectionObtained();
+			}
+			log.debug( "obtained JDBC connection" );
+		}
+		catch (SQLException sqle) {
+			throw getJdbcServices().getExceptionHelper().convert( sqle, "Could not open connection" );
+		}
+	}
+
+	/**
+	 * Physically closes the JDBC Connection.
+	 *
+	 * @throws JDBCException Indicates problem closing a connection
+	 */
+	private void releaseConnection() throws JDBCException {
+		log.debug( "releasing JDBC connection" );
+		try {
+			if ( !physicalConnection.isClosed() ) {
+				getJdbcServices().getExceptionHelper().logAndClearWarnings( physicalConnection );
+			}
+			getJdbcServices().getConnectionProvider().closeConnection( physicalConnection );
+			physicalConnection = null;
+			for ( Iterator itr = observers.iterator(); itr.hasNext(); ) {
+				( ( Observer ) itr.next() ).physicalConnectionReleased();
+			}
+			log.debug( "released JDBC connection" );
+		}
+		catch (SQLException sqle) {
+			throw getJdbcServices().getExceptionHelper().convert( sqle, "Could not close connection" );
+		}
+	}
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/impl/LogicalConnectionImplementor.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,42 @@
+/*
+ * 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.ConnectionReleaseMode;
+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
+ *
+ * @author Steve Ebersole
+ */
+public interface LogicalConnectionImplementor extends LogicalConnection {
+
+	public JDBCServices getJdbcServices();
+
+	public ConnectionReleaseMode getConnectionReleaseMode();
+
+	public JDBCContainer getJdbcContainer();
+
+	public void addObserver(Observer observer);
+
+	public void afterStatement();
+
+	public void afterTransaction();
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/AbstractStatementProxy.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,93 @@
+/*
+ * 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.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.Statement;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * AbstractStatementProxy implementation
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractStatementProxy implements InvocationHandler {
+	private final String sql;
+	private final Statement statement;
+	private final ConnectionProxy connectionProxy;
+	private Set resultSets;
+
+	protected AbstractStatementProxy(String sql, Statement statement, ConnectionProxy connectionProxy) {
+		this.sql = sql;
+		this.statement = statement;
+		this.connectionProxy = connectionProxy;
+	}
+
+	protected String getSql() {
+		return sql;
+	}
+
+	protected Statement getStatement() {
+		return statement;
+	}
+
+	protected ConnectionProxy getConnectionProxy() {
+		return connectionProxy;
+	}
+
+	protected Set getResultSets() {
+		return resultSets;
+	}
+
+	protected Set getOrCreateResultSets() {
+		if ( resultSets == null ) {
+			resultSets = new HashSet();
+		}
+		return resultSets;
+	}
+
+	protected Object invokeOnStatement(Method method, Object[] args) throws Throwable {
+		try {
+			return method.invoke( statement, args );
+		}
+		catch ( InvocationTargetException e ) {
+			Throwable realException = e.getTargetException();
+			if ( SQLException.class.isInstance( realException ) ) {
+				throw connectionProxy.getJdbcServices().getExceptionHelper().convert( ( SQLException ) realException, "???", "???" );
+			}
+			else {
+				throw realException;
+			}
+		}
+	}
+
+	void close(Statement statement) {
+		
+	}
+
+	/**
+	 * Release resources associated with this statement.
+	 *
+	 * NOTE : package-protected
+	 */
+	void release() {
+		// todo : eventually need to iterate results and release them
+	}
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/ConnectionProxy.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,109 @@
+/*
+ * 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.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.jdbc.JDBCContainer;
+import org.hibernate.jdbc.JDBCServices;
+import org.hibernate.jdbc.Observer;
+import org.hibernate.jdbc.impl.LogicalConnectionImplementor;
+
+/**
+ * ConnectionProxy implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ConnectionProxy implements InvocationHandler, Observer {
+	private static final Logger log = LoggerFactory.getLogger( ConnectionProxy.class );
+
+	private LogicalConnectionImplementor logicalConnection;
+
+	public ConnectionProxy(LogicalConnectionImplementor logicalConnection) {
+		this.logicalConnection = logicalConnection;
+		this.logicalConnection.addObserver( this );
+	}
+
+	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+		String methodName = method.getName();
+
+		if ( "getWrappedConnection".equals( methodName ) ) {
+			return extractPhysicalConnection();
+		}
+
+		// todo : close??? depends on whether we allow multiple connection proxies on the same logical connection
+
+		try {
+			Object result = method.invoke( extractPhysicalConnection(), args );
+
+			if ( "prepareStatement".equals( methodName )
+					|| "prepareCall".equals( methodName )
+					|| "createStatement".equals( methodName ) ) {
+				getJdbcContainer().register( ( Statement ) result ); // todo : this should eventually be the statemernt proxy
+				if ( args != null && args.length > 0 ) {
+					// there is a version of createStatement which does not take the SQL...
+					logicalConnection.getJdbcServices().getSqlStatementLogger().logStatement( ( String ) args[0] );
+				}
+			}
+
+			return result;
+		}
+		catch( InvocationTargetException e ) {
+			Throwable realException = e.getTargetException();
+			if ( SQLException.class.isInstance( realException ) ) {
+				throw logicalConnection.getJdbcServices().getExceptionHelper().convert( ( SQLException ) realException, "???", "???" );
+			}
+			else {
+				throw realException;
+			}
+		}
+	}
+
+	private Connection extractPhysicalConnection() {
+		return logicalConnection.getConnection();
+	}
+
+	/*package-protected*/ JDBCServices getJdbcServices() {
+		return logicalConnection.getJdbcServices();
+	}
+
+	/*package-protected*/ JDBCContainer getJdbcContainer() {
+		return logicalConnection.getJdbcContainer();
+	}
+
+	// JDBC Observer impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public void physicalConnectionObtained() {
+	}
+
+	public void physicalConnectionReleased() {
+		log.info( "logical connection releasing its physical connection");
+	}
+
+	public void logicalConnectionClosed() {
+		log.info( "*** logical connection closed ***" );
+	}
+
+
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementProxy.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementProxy.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/proxy/StatementProxy.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,34 @@
+/*
+ * 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.lang.reflect.Method;
+import java.sql.Statement;
+
+/**
+ * StatementProxy implementation
+ *
+ * @author Steve Ebersole
+ */
+public class StatementProxy extends AbstractStatementProxy {
+	protected StatementProxy(String sql, Statement statement, ConnectionProxy connectionProxy) {
+		super( sql, statement, connectionProxy );
+	}
+
+	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+		return null;
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/ExceptionHelper.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/ExceptionHelper.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/ExceptionHelper.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,128 @@
+/*
+ * 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.util;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.JDBCException;
+import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.util.StringHelper;
+
+/**
+ * ExceptionHelper implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ExceptionHelper {
+	public static final String DEFAULT_EXCEPTION_MSG = "SQL Exception";
+	public static final String DEFAULT_WARNING_MSG = "SQL Warning";
+
+	private static final Logger log = LoggerFactory.getLogger( ExceptionHelper.class );
+
+	private SQLExceptionConverter sqlExceptionConverter;
+
+	public ExceptionHelper(SQLExceptionConverter sqlExceptionConverter) {
+		this.sqlExceptionConverter = sqlExceptionConverter;
+	}
+
+	public SQLExceptionConverter getSqlExceptionConverter() {
+		return sqlExceptionConverter;
+	}
+
+	public void setSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter) {
+		this.sqlExceptionConverter = sqlExceptionConverter;
+	}
+
+	public JDBCException convert(SQLException sqle, String message) {
+		return convert( sqle, message, "n/a" );
+	}
+
+	public JDBCException convert(SQLException sqle, String message, String sql) {
+		logExceptions( sqle, message + " [" + sql + "]" );
+		return sqlExceptionConverter.convert( sqle, message, sql );
+	}
+
+	public void logAndClearWarnings(Connection connection) {
+		if ( log.isWarnEnabled() ) {
+			try {
+				logWarnings( connection.getWarnings() );
+			}
+			catch ( SQLException sqle ) {
+				//workaround for WebLogic
+				log.debug( "could not log warnings", sqle );
+			}
+		}
+		try {
+			//Sybase fail if we don't do that, sigh...
+			connection.clearWarnings();
+		}
+		catch ( SQLException sqle ) {
+			log.debug( "could not clear warnings", sqle );
+		}
+
+	}
+
+	public void logWarnings(SQLWarning warning) {
+		logWarnings( warning, null );
+	}
+
+	public void logWarnings(SQLWarning warning, String message) {
+		if ( log.isWarnEnabled() ) {
+			if ( log.isDebugEnabled() && warning != null ) {
+				message = StringHelper.isNotEmpty( message ) ? message : DEFAULT_WARNING_MSG;
+				log.debug( message, warning );
+			}
+			while ( warning != null ) {
+				StringBuffer buf = new StringBuffer( 30 )
+						.append( "SQL Warning: " )
+						.append( warning.getErrorCode() )
+						.append( ", SQLState: " )
+						.append( warning.getSQLState() );
+				log.warn( buf.toString() );
+				log.warn( warning.getMessage() );
+				warning = warning.getNextWarning();
+			}
+		}
+	}
+
+	public void logExceptions(SQLException ex) {
+		logExceptions( ex, null );
+	}
+
+	public void logExceptions(SQLException ex, String message) {
+		if ( log.isErrorEnabled() ) {
+			if ( log.isDebugEnabled() ) {
+				message = StringHelper.isNotEmpty( message ) ? message : DEFAULT_EXCEPTION_MSG;
+				log.debug( message, ex );
+			}
+			while ( ex != null ) {
+				StringBuffer buf = new StringBuffer( 30 )
+						.append( "SQL Error: " )
+						.append( ex.getErrorCode() )
+						.append( ", SQLState: " )
+						.append( ex.getSQLState() );
+				log.warn( buf.toString() );
+				log.error( ex.getMessage() );
+				ex = ex.getNextException();
+			}
+		}
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/SQLStatementLogger.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/SQLStatementLogger.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/jdbc/util/SQLStatementLogger.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -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.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Centralize logging for SQL statements.
+ *
+ * @author Steve Ebersole
+ */
+public class SQLStatementLogger {
+	private static final Logger log = LoggerFactory.getLogger( SQLStatementLogger.class );
+
+	private boolean logToStdout;
+
+	/**
+	 * Constructs a new SQLStatementLogger instance.
+	 */
+	public SQLStatementLogger() {
+		this( false );
+	}
+
+	/**
+	 * Constructs a new SQLStatementLogger instance.
+	 *
+	 * @param logToStdout Should we log to STDOUT in addition to our internal logger.
+	 */
+	public SQLStatementLogger(boolean logToStdout) {
+		this.logToStdout = logToStdout;
+	}
+
+	/**
+	 * Setter for property 'logToStdout'.
+	 *
+	 * @param logToStdout Value to set for property 'logToStdout'.
+	 */
+	public void setLogToStdout(boolean logToStdout) {
+		this.logToStdout = logToStdout;
+	}
+
+	/**
+	 * Log a SQL statement string.
+	 *
+	 * @param statement The SQL statement.
+	 */
+	public void logStatement(String statement) {
+		log.debug( statement );
+		if ( logToStdout ) {
+			System.out.println( "Hibernate: " + statement );
+		}
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/Observer.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/Observer.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/Observer.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -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.txn;
+
+/**
+ * Observer contract
+ *
+ * @author Steve Ebersole
+ */
+public interface Observer {
+	public void afterBegin();
+	public void beforeCompletion();
+	public void afterCompletion(boolean successful);
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/ResourceTransaction.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/ResourceTransaction.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/ResourceTransaction.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,24 @@
+/*
+ * 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.txn;
+
+/**
+ * ResourceTransaction contract
+ *
+ * @author Steve Ebersole
+ */
+public interface ResourceTransaction {
+}

Added: sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/TransactionCoordinator.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/TransactionCoordinator.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/main/java/org/hibernate/txn/TransactionCoordinator.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,37 @@
+/*
+ * 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.txn;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * TransactionCoordinator implementation
+ *
+ * @author Steve Ebersole
+ */
+public class TransactionCoordinator {
+	private ResourceTransaction resourceTransaction;
+	private final List observers = new ArrayList();
+
+	public void addObserver(Observer observer) {
+		observers.add( observer );
+	}
+
+	public void pulse() {
+		// attempt jta synch registration...
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/ConnectionProviderBuilder.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/ConnectionProviderBuilder.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/ConnectionProviderBuilder.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,39 @@
+/*
+ * 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.util.Properties;
+
+import org.hibernate.cfg.Environment;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.connection.DriverManagerConnectionProvider;
+
+/**
+ * ConnectionProviderBuilder implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ConnectionProviderBuilder {
+	public static ConnectionProvider buildConnectionProvider() {
+		Properties props = new Properties( null );
+		props.put( Environment.DRIVER, "org.hsqldb.jdbcDriver" );
+		props.put( Environment.URL, "jdbc:hsqldb:mem:target/test/db/hsqldb/hibernate" );
+		props.put( Environment.USER, "sa" );
+		DriverManagerConnectionProvider connectionProvider = new DriverManagerConnectionProvider();
+		connectionProvider.configure( props );
+		return connectionProvider;
+	}
+}

Added: sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/BasicConnectionTests.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/BasicConnectionTests.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/BasicConnectionTests.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,92 @@
+/*
+ * 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 java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ConnectionReleaseMode;
+
+/**
+ * BasicConnectionTests implementation
+ *
+ * @author Steve Ebersole
+ */
+public class BasicConnectionTests {
+	private static final Logger log = LoggerFactory.getLogger( BasicConnectionTests.class );
+
+	private TestingServiceImpl services = new TestingServiceImpl();
+
+	@BeforeClass
+	protected void create() {
+		services.prepare();
+	}
+
+	@AfterClass
+	protected void destroy() {
+		services.release();
+	}
+
+	@Test
+	public void testBasicJdbcUsage() throws SQLException {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+		try {
+			try {
+				logicalConnection.getConnection().prepareStatement( "select count(*) from NON_EXISTENT" ).getResultSet();
+			}
+			catch ( SQLException e ) {
+				// expected outcome
+			}
+
+			Statement stmnt = logicalConnection.getConnection().createStatement();
+			logicalConnection.getJdbcContainer().register( stmnt );
+			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 = logicalConnection.getConnection().prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
+			logicalConnection.getJdbcContainer().register( ps );
+			ps.setLong( 1, 1 );
+			ps.setString( 2, "name" );
+			ps.execute();
+
+			ps = logicalConnection.getConnection().prepareStatement( "select * from SANDBOX_JDBC_TST" );
+			logicalConnection.getJdbcContainer().register( ps );
+			ResultSet rs = ps.executeQuery();
+			logicalConnection.getJdbcContainer().register( rs );
+
+			assertTrue( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+		}
+		finally {
+			logicalConnection.close();
+		}
+
+		assertFalse( logicalConnection.getJdbcContainer().hasRegisteredResources() );
+	}
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/impl/TestingServiceImpl.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,79 @@
+/*
+ * 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 java.sql.SQLException;
+
+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;
+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() {
+		connectionProvider = ConnectionProviderBuilder.buildConnectionProvider();
+		sqlStatementLogger = new SQLStatementLogger( true );
+		jdbcContainerBuilder = new JDBCContainerBuilder() {
+			public JDBCContainer buildJdbcContainer() {
+				return new BasicJDBCContainer();
+			}
+		};
+		exceptionHelper = new ExceptionHelper(
+				new SQLStateConverter(
+						new ViolatedConstraintNameExtracter() {
+							public String extractConstraintName(SQLException e) {
+								return null;
+							}
+						}
+				)
+		);
+	}
+
+	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;
+	}
+}

Added: 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	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/BasicConnectionProxyTest.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,105 @@
+/*
+ * 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.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.testng.Assert.fail;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+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.ConnectionWrapper;
+import org.hibernate.jdbc.impl.LogicalConnectionImpl;
+import org.hibernate.jdbc.impl.TestingServiceImpl;
+
+/**
+ * BasicConnectionProxyTest implementation
+ *
+ * @author Steve Ebersole
+ */
+public class BasicConnectionProxyTest {
+	private static final Logger log = LoggerFactory.getLogger( BasicConnectionProxyTest.class );
+
+	private org.hibernate.jdbc.impl.TestingServiceImpl services = new TestingServiceImpl();
+
+	@BeforeClass
+	protected void create() {
+		services.prepare();
+	}
+
+	@AfterClass
+	protected void destroy() {
+		services.release();
+	}
+
+	@Test
+	public void testBasicJdbcUsage() throws JDBCException {
+		LogicalConnectionImpl logicalConnection = new LogicalConnectionImpl( null, ConnectionReleaseMode.AFTER_TRANSACTION, services );
+		ConnectionProxy proxyHandler = new ConnectionProxy( logicalConnection );
+		Connection proxiedConnection = ( Connection ) Proxy.newProxyInstance(
+				getClass().getClassLoader(),
+				new Class[] { Connection.class, ConnectionWrapper.class },
+				proxyHandler
+		);
+
+		try {
+			try {
+				proxiedConnection.prepareStatement( "select count(*) from NON_EXISTENT" ).executeQuery();
+			}
+			catch ( JDBCException ok ) {
+				// expected outcome
+			}
+
+			Statement stmnt = proxiedConnection.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 = proxiedConnection.prepareStatement( "insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
+			ps.setLong( 1, 1 );
+			ps.setString( 2, "name" );
+			ps.execute();
+
+// statement and resultset proxying not yet implemented
+//			ps = proxiedConnection.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/proxy/TestingServiceImpl.java
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/java/org/hibernate/jdbc/proxy/TestingServiceImpl.java	2007-08-09 19:54:17 UTC (rev 12911)
@@ -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.proxy;
+
+import java.sql.SQLException;
+
+import org.hibernate.jdbc.JDBCServices;
+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;
+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() {
+		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() {
+							public String extractConstraintName(SQLException e) {
+								return null;
+							}
+						}
+				)
+		);
+	}
+
+	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/resources/log4j.properties
===================================================================
--- sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties	                        (rev 0)
+++ sandbox/trunk/jdbc-proxy/src/test/resources/log4j.properties	2007-08-09 19:54:17 UTC (rev 12911)
@@ -0,0 +1,24 @@
+################################################################################
+# 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                                            #
+################################################################################
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+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.logger.org.hibernate=trace
\ No newline at end of file




More information about the hibernate-commits mailing list