[hibernate-commits] Hibernate SVN: r11674 - in branches/Branch_3_2_4_SP1_CP/Hibernate3: src/org/hibernate/engine and 11 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Jun 8 17:57:13 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-06-08 17:57:13 -0400 (Fri, 08 Jun 2007)
New Revision: 11674

Added:
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle10gDialect.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle8iDialect.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9iDialect.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdSuite.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java
Removed:
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.hbm.xml
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java
Modified:
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Dialect.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/DialectFactory.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/OracleDialect.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/PersistenceContext.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/StatefulPersistenceContext.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/CollectionLoadContext.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/EntityLoadContext.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/LoadContexts.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/event/def/DefaultFlushEntityEventListener.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/AbstractScrollableResults.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/IteratorImpl.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/AllTests.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/Name.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java
   branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java
Log:
seeded 3.2.4.sp1.cp branch

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Dialect.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Dialect.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Dialect.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -197,6 +197,7 @@
 		registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
 		registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
 		registerHibernateType( Types.CLOB, Hibernate.CLOB.getName() );
+		registerHibernateType( Types.REAL, Hibernate.FLOAT.getName() );
 	}
 
 	/**

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/DialectFactory.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/DialectFactory.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/DialectFactory.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -114,21 +114,26 @@
 		// TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
 		MAPPERS.put( "HSQL Database Engine", new VersionInsensitiveMapper( "org.hibernate.dialect.HSQLDialect" ) );
 		MAPPERS.put( "DB2/NT", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+		MAPPERS.put( "DB2/LINUX", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
 		MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.hibernate.dialect.MySQLDialect" ) );
 		MAPPERS.put( "PostgreSQL", new VersionInsensitiveMapper( "org.hibernate.dialect.PostgreSQLDialect" ) );
 		MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
 		MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
 		MAPPERS.put( "Sybase SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
+		MAPPERS.put( "Adaptive Server Enterprise", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
 		MAPPERS.put( "Informix Dynamic Server", new VersionInsensitiveMapper( "org.hibernate.dialect.InformixDialect" ) );
 		MAPPERS.put( "Apache Derby", new VersionInsensitiveMapper( "org.hibernate.dialect.DerbyDialect" ) );
-		
+
 		MAPPERS.put(
 		        "Oracle",
 		        new DatabaseDialectMapper() {
 			        public String getDialectClass(int majorVersion) {
-			            return majorVersion > 8
-			                    ? "org.hibernate.dialect.Oracle9Dialect"
-				                : "org.hibernate.dialect.OracleDialect";
+						switch ( majorVersion ) {
+							case 8: return Oracle8iDialect.class.getName();
+							case 9: return Oracle9iDialect.class.getName();
+							case 10: return Oracle10gDialect.class.getName();
+							default: throw new HibernateException( "unknown Oracle major version [" + majorVersion + "]" );
+						}
 			        }
 		        }
 		);

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle10gDialect.java (from rev 11673, branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle10gDialect.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle10gDialect.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle10gDialect.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,26 @@
+//$Id$
+package org.hibernate.dialect;
+
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.ANSIJoinFragment;
+
+
+/**
+ * A dialect specifically for use with Oracle 10g.
+ * <p/>
+ * The main difference between this dialect and {@link Oracle9iDialect}
+ * is the use of "ANSI join syntax" here...
+ *
+ * @author Steve Ebersole
+ */
+public class Oracle10gDialect extends Oracle9iDialect {
+
+	public Oracle10gDialect() {
+		super();
+	}
+
+	public JoinFragment createOuterJoinFragment() {
+		return new ANSIJoinFragment();
+	}
+
+}
\ No newline at end of file

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle8iDialect.java (from rev 11673, branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle8iDialect.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle8iDialect.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle8iDialect.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,431 @@
+//$Id$
+package org.hibernate.dialect;
+
+import java.sql.Types;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.sql.CallableStatement;
+
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.DecodeCaseFragment;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.OracleJoinFragment;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.NvlFunction;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.JDBCExceptionHelper;
+
+/**
+ * A dialect for Oracle 8i.
+ *
+ * @author Steve Ebersole
+ */
+public class Oracle8iDialect extends Dialect {
+
+	public Oracle8iDialect() {
+		super();
+		registerCharacterTypeMappings();
+		registerNumericTypeMappings();
+		registerDateTimeTypeMappings();
+		registerLargeObjectTypeMappings();
+
+		registerReverseHibernateTypeMappings();
+
+		registerFunctions();
+
+		registerDefaultProperties();
+	}
+
+	protected void registerCharacterTypeMappings() {
+		registerColumnType( Types.CHAR, "char(1)" );
+		registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
+		registerColumnType( Types.VARCHAR, "long" );
+	}
+
+	protected void registerNumericTypeMappings() {
+		registerColumnType( Types.BIT, "number(1,0)" );
+		registerColumnType( Types.BIGINT, "number(19,0)" );
+		registerColumnType( Types.SMALLINT, "number(5,0)" );
+		registerColumnType( Types.TINYINT, "number(3,0)" );
+		registerColumnType( Types.INTEGER, "number(10,0)" );
+
+		registerColumnType( Types.FLOAT, "float" );
+		registerColumnType( Types.DOUBLE, "double precision" );
+		registerColumnType( Types.NUMERIC, "number($p,$s)" );
+		registerColumnType( Types.DECIMAL, "number($p,$s)" );
+	}
+
+	protected void registerDateTimeTypeMappings() {
+		registerColumnType( Types.TIMESTAMP, "date" );
+	}
+
+	protected void registerLargeObjectTypeMappings() {
+		registerColumnType( Types.VARBINARY, 2000, "raw($l)" );
+		registerColumnType( Types.VARBINARY, "long raw" );
+
+		registerColumnType( Types.BLOB, "blob" );
+		registerColumnType( Types.CLOB, "clob" );
+	}
+
+	protected void registerReverseHibernateTypeMappings() {
+	}
+
+	protected void registerFunctions() {
+		registerFunction( "abs", new StandardSQLFunction("abs") );
+		registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+		registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+		registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+		registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+		registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+		registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
+		registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+		registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+		registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+		registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
+		registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
+		registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+		registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+		registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
+		registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
+
+		registerFunction( "round", new StandardSQLFunction("round") );
+		registerFunction( "trunc", new StandardSQLFunction("trunc") );
+		registerFunction( "ceil", new StandardSQLFunction("ceil") );
+		registerFunction( "floor", new StandardSQLFunction("floor") );
+
+		registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
+		registerFunction( "initcap", new StandardSQLFunction("initcap") );
+		registerFunction( "lower", new StandardSQLFunction("lower") );
+		registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
+		registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
+		registerFunction( "soundex", new StandardSQLFunction("soundex") );
+		registerFunction( "upper", new StandardSQLFunction("upper") );
+		registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+		registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
+
+		registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
+		registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.TIMESTAMP) );
+
+		registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
+		registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
+		registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
+
+		registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+		registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
+		registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
+		registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
+		registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
+
+		registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
+		registerFunction( "rownum", new NoArgSQLFunction("rownum", Hibernate.LONG, false) );
+
+		// Multi-param string dialect functions...
+		registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
+		registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.INTEGER) );
+		registerFunction( "instrb", new StandardSQLFunction("instrb", Hibernate.INTEGER) );
+		registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
+		registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
+		registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
+		registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
+		registerFunction( "substrb", new StandardSQLFunction("substrb", Hibernate.STRING) );
+		registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
+
+		registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
+		registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
+		registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "vsize(?1)*8" ) );
+		registerFunction( "coalesce", new NvlFunction() );
+
+		// Multi-param numeric dialect functions...
+		registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.FLOAT) );
+		registerFunction( "log", new StandardSQLFunction("log", Hibernate.INTEGER) );
+		registerFunction( "mod", new StandardSQLFunction("mod", Hibernate.INTEGER) );
+		registerFunction( "nvl", new StandardSQLFunction("nvl") );
+		registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
+		registerFunction( "power", new StandardSQLFunction("power", Hibernate.FLOAT) );
+
+		// Multi-param date dialect functions...
+		registerFunction( "add_months", new StandardSQLFunction("add_months", Hibernate.DATE) );
+		registerFunction( "months_between", new StandardSQLFunction("months_between", Hibernate.FLOAT) );
+		registerFunction( "next_day", new StandardSQLFunction("next_day", Hibernate.DATE) );
+
+		registerFunction( "str", new StandardSQLFunction("to_char", Hibernate.STRING) );
+	}
+
+	protected void registerDefaultProperties() {
+		getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
+		getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
+		// Oracle driver reports to support getGeneratedKeys(), but they only
+		// support the version taking an array of the names of the columns to
+		// be returned (via its RETURNING clause).  No other driver seems to
+		// support this overloaded version.
+		getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" );
+	}
+
+
+	// features which change between 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	/**
+	 * Support for the oracle proprietary join syntax...
+	 *
+	 * @return The orqacle join fragment
+	 */
+	public JoinFragment createOuterJoinFragment() {
+		return new OracleJoinFragment();
+	}
+
+	/**
+	 * Map case support to the Oracle DECODE function.  Oracle did not
+	 * add support for CASE until 9i.
+	 *
+	 * @return The oracle CASE -> DECODE fragment
+	 */
+	public CaseFragment createCaseFragment() {
+		return new DecodeCaseFragment();
+	}
+
+	public String getLimitString(String sql, boolean hasOffset) {
+		sql = sql.trim();
+		boolean isForUpdate = false;
+		if ( sql.toLowerCase().endsWith(" for update") ) {
+			sql = sql.substring( 0, sql.length()-11 );
+			isForUpdate = true;
+		}
+
+		StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
+		if (hasOffset) {
+			pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
+		}
+		else {
+			pagingSelect.append("select * from ( ");
+		}
+		pagingSelect.append(sql);
+		if (hasOffset) {
+			pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
+		}
+		else {
+			pagingSelect.append(" ) where rownum <= ?");
+		}
+
+		if ( isForUpdate ) {
+			pagingSelect.append( " for update" );
+		}
+
+		return pagingSelect.toString();
+	}
+
+	/**
+	 * Allows access to the basic {@link Dialect#getSelectClauseNullString}
+	 * implementation...
+	 *
+	 * @param sqlType The {@link java.sql.Types} mapping type code
+	 * @return The appropriate select cluse fragment
+	 */
+	public String getBasicSelectClauseNullString(int sqlType) {
+		return super.getSelectClauseNullString( sqlType );
+	}
+
+	public String getSelectClauseNullString(int sqlType) {
+		switch(sqlType) {
+			case Types.VARCHAR:
+			case Types.CHAR:
+				return "to_char(null)";
+			case Types.DATE:
+			case Types.TIMESTAMP:
+			case Types.TIME:
+				return "to_date(null)";
+			default:
+				return "to_number(null)";
+		}
+	}
+
+	public String getCurrentTimestampSelectString() {
+		return "select sysdate from dual";
+	}
+
+	public String getCurrentTimestampSQLFunctionName() {
+		return "sysdate";
+	}
+
+
+	// features which remain constant across 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~
+
+	public String getAddColumnString() {
+		return "add";
+	}
+
+	public String getSequenceNextValString(String sequenceName) {
+		return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
+	}
+
+	public String getSelectSequenceNextValString(String sequenceName) {
+		return sequenceName + ".nextval";
+	}
+
+	public String getCreateSequenceString(String sequenceName) {
+		return "create sequence " + sequenceName; //starts with 1, implicitly
+	}
+
+	public String getDropSequenceString(String sequenceName) {
+		return "drop sequence " + sequenceName;
+	}
+
+	public String getCascadeConstraintsString() {
+		return " cascade constraints";
+	}
+
+	public boolean dropConstraints() {
+		return false;
+	}
+
+	public String getForUpdateNowaitString() {
+		return " for update nowait";
+	}
+
+	public boolean supportsSequences() {
+		return true;
+	}
+
+	public boolean supportsPooledSequences() {
+		return true;
+	}
+
+	public boolean supportsLimit() {
+		return true;
+	}
+
+	public String getForUpdateString(String aliases) {
+		return getForUpdateString() + " of " + aliases;
+	}
+
+	public String getForUpdateNowaitString(String aliases) {
+		return getForUpdateString() + " of " + aliases + " nowait";
+	}
+
+	public boolean bindLimitParametersInReverseOrder() {
+		return true;
+	}
+
+	public boolean useMaxForLimit() {
+		return true;
+	}
+
+	public boolean forUpdateOfColumns() {
+		return true;
+	}
+
+	public String getQuerySequencesString() {
+		return "select sequence_name from user_sequences";
+	}
+
+	public String getSelectGUIDString() {
+		return "select rawtohex(sys_guid()) from dual";
+	}
+
+	public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+        return EXTRACTER;
+	}
+
+	private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+
+		/**
+		 * Extract the name of the violated constraint from the given SQLException.
+		 *
+		 * @param sqle The exception that was the result of the constraint violation.
+		 * @return The extracted constraint name.
+		 */
+		public String extractConstraintName(SQLException sqle) {
+			int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
+			if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
+				return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
+			}
+			else if ( errorCode == 1400 ) {
+				// simple nullability constraint
+				return null;
+			}
+			else {
+				return null;
+			}
+		}
+
+	};
+
+	// not final-static to avoid possible classcast exceptions if using different oracle drivers.
+	int oracletypes_cursor_value = 0;
+	public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col) throws SQLException {
+		if(oracletypes_cursor_value==0) {
+			try {
+				Class types = ReflectHelper.classForName("oracle.jdbc.driver.OracleTypes");
+				oracletypes_cursor_value = types.getField("CURSOR").getInt(types.newInstance());
+			} catch (Exception se) {
+				throw new HibernateException("Problem while trying to load or access OracleTypes.CURSOR value",se);
+			}
+		}
+		//	register the type of the out param - an Oracle specific type
+		statement.registerOutParameter(col, oracletypes_cursor_value);
+		col++;
+		return col;
+	}
+
+	public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+		ps.execute();
+		return ( ResultSet ) ps.getObject( 1 );
+	}
+
+	public boolean supportsUnionAll() {
+		return true;
+	}
+
+	public boolean supportsCommentOn() {
+		return true;
+	}
+
+	public boolean supportsTemporaryTables() {
+		return true;
+	}
+
+	public String generateTemporaryTableName(String baseTableName) {
+		String name = super.generateTemporaryTableName(baseTableName);
+		return name.length() > 30 ? name.substring( 1, 30 ) : name;
+	}
+
+	public String getCreateTemporaryTableString() {
+		return "create global temporary table";
+	}
+
+	public String getCreateTemporaryTablePostfix() {
+		return "on commit delete rows";
+	}
+
+	public boolean dropTemporaryTableAfterUse() {
+		return false;
+	}
+
+	public boolean supportsCurrentTimestampSelection() {
+		return true;
+	}
+
+	public boolean isCurrentTimestampSelectStringCallable() {
+		return false;
+	}
+
+
+	// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	public boolean supportsEmptyInList() {
+		return false;
+	}
+
+	public boolean supportsExistsInSelect() {
+		return false;
+	}
+
+}
\ No newline at end of file

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -6,6 +6,9 @@
 import java.sql.SQLException;
 import java.sql.Types;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.hibernate.Hibernate;
 import org.hibernate.HibernateException;
 import org.hibernate.cfg.Environment;
@@ -21,12 +24,17 @@
 
 /**
  * An SQL dialect for Oracle 9 (uses ANSI-style syntax where possible).
+ *
+ * @deprecated Use either Oracle9iDialect or Oracle10gDialect instead
  * @author Gavin King, David Channon
  */
 public class Oracle9Dialect extends Dialect {
 
+	private static final Log log = LogFactory.getLog( Oracle9Dialect.class );
+
 	public Oracle9Dialect() {
 		super();
+		log.warn( "The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead" );
 		registerColumnType( Types.BIT, "number(1,0)" );
 		registerColumnType( Types.BIGINT, "number(19,0)" );
 		registerColumnType( Types.SMALLINT, "number(5,0)" );

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9iDialect.java (from rev 11673, branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9iDialect.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9iDialect.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/Oracle9iDialect.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,77 @@
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.ANSICaseFragment;
+
+/**
+ * A dialect for Oracle 9i databases.
+ * <p/>
+ * Unlike the older (deprecated) {@Link Oracl9Dialect), this version specifies
+ * to not use "ANSI join syntax" because 9i does not seem to properly
+ * handle it in all cases.
+ *
+ * @author Steve Ebersole
+ */
+public class Oracle9iDialect extends Oracle8iDialect {
+	protected void registerCharacterTypeMappings() {
+		registerColumnType( Types.CHAR, "char(1 char)" );
+		registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" );
+		registerColumnType( Types.VARCHAR, "long" );
+	}
+
+	protected void registerDateTimeTypeMappings() {
+		registerColumnType( Types.DATE, "date" );
+		registerColumnType( Types.TIME, "date" );
+		registerColumnType( Types.TIMESTAMP, "timestamp" );
+	}
+
+	public CaseFragment createCaseFragment() {
+		// Oracle did add support for ANSI CASE statements in 9i
+		return new ANSICaseFragment();
+	}
+
+	public String getLimitString(String sql, boolean hasOffset) {
+		sql = sql.trim();
+		boolean isForUpdate = false;
+		if ( sql.toLowerCase().endsWith(" for update") ) {
+			sql = sql.substring( 0, sql.length()-11 );
+			isForUpdate = true;
+		}
+
+		StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
+		if (hasOffset) {
+			pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
+		}
+		else {
+			pagingSelect.append("select * from ( ");
+		}
+		pagingSelect.append(sql);
+		if (hasOffset) {
+			pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
+		}
+		else {
+			pagingSelect.append(" ) where rownum <= ?");
+		}
+
+		if ( isForUpdate ) {
+			pagingSelect.append( " for update" );
+		}
+
+		return pagingSelect.toString();
+	}
+
+	public String getSelectClauseNullString(int sqlType) {
+		return getBasicSelectClauseNullString( sqlType );
+	}
+
+	public String getCurrentTimestampSelectString() {
+		return "select systimestamp from dual";
+	}
+
+	public String getCurrentTimestampSQLFunctionName() {
+		// the standard SQL function name is current_timestamp...
+		return "current_timestamp";
+	}
+}
\ No newline at end of file

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/OracleDialect.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/OracleDialect.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/dialect/OracleDialect.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -3,6 +3,9 @@
 
 import java.sql.Types;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.hibernate.sql.CaseFragment;
 import org.hibernate.sql.DecodeCaseFragment;
 import org.hibernate.sql.JoinFragment;
@@ -10,12 +13,17 @@
 
 /**
  * An SQL dialect for Oracle, compatible with Oracle 8.
+ *
+ * @deprecated Use Oracle8iDialect instead.
  * @author Gavin King
  */
 public class OracleDialect extends Oracle9Dialect {
 
+	private static final Log log = LogFactory.getLog( OracleDialect.class );
+
 	public OracleDialect() {
 		super();
+		log.warn( "The OracleDialect dialect has been deprecated; use Oracle8iDialect instead" );
 		// Oracle8 and previous define only a "DATE" type which
 		//      is used to represent all aspects of date/time
 		registerColumnType( Types.TIMESTAMP, "date" );

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/PersistenceContext.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/PersistenceContext.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/PersistenceContext.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -83,6 +83,11 @@
 
 	public Object[] getCachedDatabaseSnapshot(EntityKey key);
 
+	/**
+	 * Get the values of the natural id fields as known to the underlying 
+	 * database, or null if the entity has no natural id or there is no 
+	 * corresponding row.
+	 */
 	public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister)
 	throws HibernateException;
 
@@ -437,4 +442,4 @@
 	public void setReadOnly(Object entity, boolean readOnly);
 
 	void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId);
-}
\ No newline at end of file
+}

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/StatefulPersistenceContext.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/StatefulPersistenceContext.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/StatefulPersistenceContext.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -203,6 +203,9 @@
 			batchFetchQueue.clear();
 		}
 		hasNonReadOnlyEntities = false;
+		if ( loadContexts != null ) {
+			loadContexts.cleanup();
+		}
 	}
 	
 	public boolean hasNonReadOnlyEntities() {

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/CollectionLoadContext.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/CollectionLoadContext.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/CollectionLoadContext.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -2,7 +2,6 @@
 
 import java.sql.ResultSet;
 import java.io.Serializable;
-import java.util.Map;
 import java.util.List;
 import java.util.Iterator;
 import java.util.ArrayList;
@@ -127,7 +126,7 @@
 			collection.beforeInitialize( persister, -1 );
 			collection.beginRead();
 			localLoadingCollectionKeys.add( collectionKey );
-			loadContexts.registerLoadingCollectionEntry( collectionKey, new LoadingCollectionEntry( resultSet, persister, key, collection ) );
+			loadContexts.registerLoadingCollectionXRef( collectionKey, new LoadingCollectionEntry( resultSet, persister, key, collection ) );
 			return collection;
 		}
 		else {
@@ -153,8 +152,7 @@
 	 */
 	public void endLoadingCollections(CollectionPersister persister) {
 		SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
-		if ( loadContexts.getLoadingCollectionEntryMap() == null
-				|| loadContexts.getLoadingCollectionEntryMap().isEmpty()
+		if ( !loadContexts.hasLoadingCollectionEntries()
 				|| localLoadingCollectionKeys.isEmpty() ) {
 			return;
 		}
@@ -166,12 +164,14 @@
 		// in a temp collection.  the temp collection is then used to "drive"
 		// the #endRead processing.
 		List matches = null;
-		Iterator iter = loadContexts.getLoadingCollectionEntryMap().entrySet().iterator();
+		Iterator iter = localLoadingCollectionKeys.iterator();
 		while ( iter.hasNext() ) {
-			final Map.Entry mapEntry = ( Map.Entry ) iter.next();
-			final CollectionKey collectionKey = ( CollectionKey ) mapEntry.getKey();
-			final LoadingCollectionEntry lce = ( LoadingCollectionEntry ) mapEntry.getValue();
-			if ( localLoadingCollectionKeys.contains( collectionKey ) && lce.getResultSet() == resultSet && lce.getPersister() == persister) {
+			final CollectionKey collectionKey = (CollectionKey) iter.next();
+			final LoadingCollectionEntry lce = loadContexts.locateLoadingCollectionEntry( collectionKey );
+			if ( lce == null) {
+				log.warn( "In CollectionLoadContext#endLoadingCollections, localLoadingCollectionKeys contained [" + collectionKey + "], but no LoadingCollectionEntry was found in loadContexts" );
+			}
+			else if ( lce.getResultSet() == resultSet && lce.getPersister() == persister ) {
 				if ( matches == null ) {
 					matches = new ArrayList();
 				}
@@ -185,11 +185,23 @@
 				if ( log.isTraceEnabled() ) {
 					log.trace( "removing collection load entry [" + lce + "]" );
 				}
+
+				// todo : i'd much rather have this done from #endLoadingCollection(CollectionPersister,LoadingCollectionEntry)...
+				loadContexts.unregisterLoadingCollectionXRef( collectionKey );
 				iter.remove();
 			}
 		}
 
 		endLoadingCollections( persister, matches );
+		if ( localLoadingCollectionKeys.isEmpty() ) {
+			// todo : hack!!!
+			// NOTE : here we cleanup the load context when we have no more local
+			// LCE entries.  This "works" for the time being because really
+			// only the collection load contexts are implemented.  Long term,
+			// this cleanup should become part of the "close result set"
+			// processing from the (sandbox/jdbc) jdbc-container code.
+			loadContexts.cleanup( resultSet );
+		}
 	}
 
 	private void endLoadingCollections(CollectionPersister persister, List matchedCollectionEntries) {
@@ -314,9 +326,9 @@
 
 	void cleanup() {
 		if ( !localLoadingCollectionKeys.isEmpty() ) {
-			log.warn( "On CollectionLoadContext#clear, loadingCollections contained [" + localLoadingCollectionKeys.size() + "] entries" );
+			log.warn( "On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [" + localLoadingCollectionKeys.size() + "] entries" );
 		}
-		loadContexts.cleanupCollectionEntries( localLoadingCollectionKeys );
+		loadContexts.cleanupCollectionXRefs( localLoadingCollectionKeys );
 		localLoadingCollectionKeys.clear();
 	}
 

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/EntityLoadContext.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/EntityLoadContext.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/EntityLoadContext.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -30,4 +30,10 @@
 		}
 		hydratingEntities.clear();
 	}
+
+
+	public String toString() {
+		return super.toString() + "<rs=" + resultSet + ">";
+	}
+
 }

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/LoadContexts.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/LoadContexts.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/engine/loading/LoadContexts.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -63,7 +63,80 @@
 		return persistenceContext;
 	}
 
+	private SessionImplementor getSession() {
+		return getPersistenceContext().getSession();
+	}
+
+	private EntityMode getEntityMode() {
+		return getSession().getEntityMode();
+	}
+
+
+	// cleanup code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ 	/**
+	 * Release internal state associated with the given result set.
+	 * <p/>
+	 * This should be called when we are done with processing said result set,
+	 * ideally as the result set is being closed.
+	 *
+	 * @param resultSet The result set for which it is ok to release
+	 * associated resources.
+	 */
+	public void cleanup(ResultSet resultSet) {
+		if ( collectionLoadContexts != null ) {
+			CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) collectionLoadContexts.remove( resultSet );
+			collectionLoadContext.cleanup();
+		}
+		if ( entityLoadContexts != null ) {
+			EntityLoadContext entityLoadContext = ( EntityLoadContext ) entityLoadContexts.remove( resultSet );
+			entityLoadContext.cleanup();
+		}
+	}
+
 	/**
+	 * Release internal state associated with *all* result sets.
+	 * <p/>
+	 * This is intended as a "failsafe" process to make sure we get everything
+	 * cleaned up and released.
+	 */
+	public void cleanup() {
+		if ( collectionLoadContexts != null ) {
+			Iterator itr = collectionLoadContexts.values().iterator();
+			while ( itr.hasNext() ) {
+				CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next();
+				log.warn( "fail-safe cleanup (collections) : " + collectionLoadContext );
+				collectionLoadContext.cleanup();
+			}
+			collectionLoadContexts.clear();
+		}
+		if ( entityLoadContexts != null ) {
+			Iterator itr = entityLoadContexts.values().iterator();
+			while ( itr.hasNext() ) {
+				EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next();
+				log.warn( "fail-safe cleanup (entities) : " + entityLoadContext );
+				entityLoadContext.cleanup();
+			}
+			entityLoadContexts.clear();
+		}
+	}
+
+
+	// Collection load contexts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	/**
+	 * Do we currently have any internal entries corresponding to loading
+	 * collections?
+	 *
+	 * @return True if we currently hold state pertaining to loading collections;
+	 * false otherwise.
+	 */
+	public boolean hasLoadingCollectionEntries() {
+		return ( xrefLoadingCollectionEntries != null && !xrefLoadingCollectionEntries.isEmpty() );
+	}
+
+
+	/**
 	 * Get the {@link CollectionLoadContext} associated with the given
 	 * {@link ResultSet}, creating one if needed.
 	 *
@@ -113,7 +186,60 @@
 		}
 	}
 
+
+
+
+	// loading collection xrefs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 	/**
+	 * Register a loading collection xref.
+	 * <p/>
+	 * This xref map is used because sometimes a collection is in process of
+	 * being loaded from one result set, but needs to be accessed from the
+	 * context of another "nested" result set processing.
+	 * <p/>
+	 * Implementation note: package protected, as this is meant solely for use
+	 * by {@link CollectionLoadContext} to be able to locate collections
+	 * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
+	 *
+	 * @param entryKey The xref collection key
+	 * @param entry The corresponding loading collection entry
+	 */
+	void registerLoadingCollectionXRef(CollectionKey entryKey, LoadingCollectionEntry entry) {
+		if ( xrefLoadingCollectionEntries == null ) {
+			xrefLoadingCollectionEntries = new HashMap();
+		}
+		xrefLoadingCollectionEntries.put( entryKey, entry );
+	}
+
+	/**
+	 * The inverse of {@link #registerLoadingCollectionXRef}.  Here, we are done
+	 * processing the said collection entry, so we remove it from the
+	 * load context.
+	 * <p/>
+	 * The idea here is that other loading collections can now reference said
+	 * collection directly from the {@link PersistenceContext} because it
+	 * has completed its load cycle.
+	 * <p/>
+	 * Implementation note: package protected, as this is meant solely for use
+	 * by {@link CollectionLoadContext} to be able to locate collections
+	 * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
+	 *
+	 * @param key The key of the collection we are done processing.
+	 */
+	void unregisterLoadingCollectionXRef(CollectionKey key) {
+		if ( !hasLoadingCollectionEntries() ) {
+			return;
+		}
+		xrefLoadingCollectionEntries.remove(key);
+	 }
+
+	/*package*/Map getLoadingCollectionXRefs() {
+ 		return xrefLoadingCollectionEntries;
+ 	}
+
+
+	/**
 	 * Locate the LoadingCollectionEntry within *any* of the tracked
 	 * {@link CollectionLoadContext}s.
 	 * <p/>
@@ -143,18 +269,7 @@
 		return rtn;
 	}
 
-	/*package*/void registerLoadingCollectionEntry(CollectionKey entryKey, LoadingCollectionEntry entry) {
-		if ( xrefLoadingCollectionEntries == null ) {
-			xrefLoadingCollectionEntries = new HashMap();
-		}
-		xrefLoadingCollectionEntries.put( entryKey, entry );
-	}
-
-	/*package*/Map getLoadingCollectionEntryMap() {
-		return xrefLoadingCollectionEntries;
-	}
-
-	/*package*/void cleanupCollectionEntries(Set entryKeys) {
+	/*package*/void cleanupCollectionXRefs(Set entryKeys) {
 		Iterator itr = entryKeys.iterator();
 		while ( itr.hasNext() ) {
 			final CollectionKey entryKey = ( CollectionKey ) itr.next();
@@ -162,6 +277,10 @@
 		}
 	}
 
+
+	// Entity load contexts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+	// 	* currently, not yet used...
+
 	public EntityLoadContext getEntityLoadContext(ResultSet resultSet) {
 		EntityLoadContext context = null;
 		if ( entityLoadContexts == null ) {
@@ -177,23 +296,4 @@
 		return context;
 	}
 
-	public void cleanup(ResultSet resultSet) {
-		if ( collectionLoadContexts != null ) {
-			CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) collectionLoadContexts.remove( resultSet );
-			collectionLoadContext.cleanup();
-		}
-		if ( entityLoadContexts != null ) {
-			EntityLoadContext entityLoadContext = ( EntityLoadContext ) entityLoadContexts.remove( resultSet );
-			entityLoadContext.cleanup();
-		}
-	}
-
-	private SessionImplementor getSession() {
-		return getPersistenceContext().getSession();
-	}
-
-	private EntityMode getEntityMode() {
-		return getSession().getEntityMode();
-	}
-
 }

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/event/def/DefaultFlushEntityEventListener.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/event/def/DefaultFlushEntityEventListener.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/event/def/DefaultFlushEntityEventListener.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -74,16 +74,23 @@
 	        EntityMode entityMode,
 	        SessionImplementor session) {
 		if ( persister.hasNaturalIdentifier() ) {
-			if ( loaded == null ) {
-				loaded = session.getPersistenceContext().getNaturalIdSnapshot( identifier, persister );
-			}
+ 			Object[] snapshot = null;			
 			Type[] types = persister.getPropertyTypes();
 			int[] props = persister.getNaturalIdentifierProperties();
 			boolean[] updateable = persister.getPropertyUpdateability();
 			for ( int i=0; i<props.length; i++ ) {
 				int prop = props[i];
 				if ( !updateable[prop] ) {
-					if ( !types[prop].isEqual( current[prop], loaded[prop], entityMode ) ) {
+ 					Object loadedVal;
+ 					if ( loaded == null ) {
+ 						if ( snapshot == null) {
+ 							snapshot = session.getPersistenceContext().getNaturalIdSnapshot( identifier, persister );
+ 						}
+ 						loadedVal = snapshot[i];
+ 					} else {
+ 						loadedVal = loaded[prop];
+ 					}
+ 					if ( !types[prop].isEqual( current[prop], loadedVal, entityMode ) ) {						
 						throw new HibernateException(
 								"immutable natural identifier of an instance of " +
 								persister.getEntityName() +

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/AbstractScrollableResults.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/AbstractScrollableResults.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/AbstractScrollableResults.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -13,6 +13,9 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.hibernate.Hibernate;
 import org.hibernate.HibernateException;
 import org.hibernate.MappingException;
@@ -31,6 +34,8 @@
  */
 public abstract class AbstractScrollableResults implements ScrollableResults {
 
+	private static final Log log = LogFactory.getLog( AbstractScrollableResults.class );
+
 	private final ResultSet resultSet;
 	private final PreparedStatement ps;
 	private final SessionImplementor session;
@@ -91,7 +96,7 @@
 	public final void close() throws HibernateException {
 		try {
 			// not absolutely necessary, but does help with aggressive release
-			session.getBatcher().closeQueryStatement(ps, resultSet);
+			session.getBatcher().closeQueryStatement( ps, resultSet );
 		}
 		catch (SQLException sqle) {
 			throw JDBCExceptionHelper.convert(
@@ -100,6 +105,15 @@
 					"could not close results"
 				);
 		}
+		finally {
+			try {
+				session.getPersistenceContext().getLoadContexts().cleanup( resultSet );
+			}
+			catch( Throwable ignore ) {
+				// ignore this error for now
+				log.trace( "exception trying to cleanup load context : " + ignore.getMessage() );
+			}
+		}
 	}
 
 	public final Object[] get() throws HibernateException {

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/IteratorImpl.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/IteratorImpl.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/src/org/hibernate/impl/IteratorImpl.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -76,6 +76,15 @@
 				        "Unable to close iterator"
 					);
 			}
+			finally {
+				try {
+					session.getPersistenceContext().getLoadContexts().cleanup( rs );
+				}
+				catch( Throwable ignore ) {
+					// ignore this error for now
+					log.trace( "exception trying to cleanup load context : " + ignore.getMessage() );
+				}
+			}
 		}
 	}
 

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/AllTests.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/AllTests.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -49,6 +49,7 @@
 import org.hibernate.test.idclass.IdClassTest;
 import org.hibernate.test.idprops.IdentifierPropertyReferencesTest;
 import org.hibernate.test.immutable.ImmutableTest;
+import org.hibernate.test.insertordering.InsertOrderingTest;
 import org.hibernate.test.instrument.buildtime.InstrumentTest;
 import org.hibernate.test.instrument.runtime.CGLIBInstrumentationTest;
 import org.hibernate.test.instrument.runtime.JavassistInstrumentationTest;
@@ -91,7 +92,7 @@
 import org.hibernate.test.mapping.ValueVisitorTest;
 import org.hibernate.test.mappingexception.MappingExceptionTest;
 import org.hibernate.test.mixed.MixedTest;
-import org.hibernate.test.naturalid.NaturalIdTest;
+import org.hibernate.test.naturalid.NaturalIdSuite;
 import org.hibernate.test.ondelete.OnDeleteTest;
 import org.hibernate.test.onetomany.OneToManyTest;
 import org.hibernate.test.onetoone.OneToOneSuite;
@@ -104,6 +105,7 @@
 import org.hibernate.test.proxy.ProxyTest;
 import org.hibernate.test.querycache.QueryCacheTest;
 import org.hibernate.test.readonly.ReadOnlyTest;
+import org.hibernate.test.reattachment.ReattachmentSuite;
 import org.hibernate.test.rowid.RowIdTest;
 import org.hibernate.test.sorted.SortTest;
 import org.hibernate.test.sql.NativeSqlSupportSuite;
@@ -129,8 +131,6 @@
 import org.hibernate.test.version.db.DbVersionTest;
 import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
 import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.insertordering.InsertOrderingTest;
-import org.hibernate.test.reattachment.ReattachmentSuite;
 
 /**
  * @author Gavin King
@@ -194,7 +194,7 @@
 		public static Test unfilteredSuite() {
 			TestSuite suite = new TestSuite("New tests suite");
 			suite.addTest( OpsSuite.suite() );
-			suite.addTest( NaturalIdTest.suite() );
+			suite.addTest( NaturalIdSuite.suite() );
 			suite.addTest( ComponentSuite.suite() );
 			suite.addTest( ProxyTest.suite() );
 			suite.addTest( VersionTest.suite() );

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -45,6 +45,7 @@
 		SQLExceptionConverter converter = getDialect().buildSQLExceptionConverter();
 
 		Session session = openSession();
+		session.beginTransaction();
 		Connection connection = session.connection();
 
 		// Attempt to insert some bad values into the T_MEMBERSHIP table that should
@@ -76,6 +77,7 @@
 			}
 		}
 
+		session.getTransaction().rollback();
 		session.close();
 	}
 
@@ -85,10 +87,10 @@
 		Session session = openSession();
 		Connection connection = session.connection();
 
-        // prepare a query against a non-existent table
+        // prepare/execute a query against a non-existent table
 		PreparedStatement ps = null;
 		try {
-			ps = connection.prepareStatement("SELECT user_id, user_name FROM tbl_user");
+			ps = connection.prepareStatement("SELECT user_id, user_name FROM tbl_no_there");
 			ps.executeQuery();
 
 			fail("SQL compilation should have failed");

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -13,6 +13,8 @@
 import java.util.Map;
 
 import junit.framework.Test;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import org.hibernate.Hibernate;
 import org.hibernate.HibernateException;
@@ -27,6 +29,7 @@
 import org.hibernate.dialect.DB2Dialect;
 import org.hibernate.dialect.HSQLDialect;
 import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.dialect.Oracle8iDialect;
 import org.hibernate.dialect.Oracle9Dialect;
 import org.hibernate.dialect.PostgreSQLDialect;
 import org.hibernate.dialect.SQLServerDialect;
@@ -50,9 +53,6 @@
 import org.hibernate.type.Type;
 import org.hibernate.util.StringHelper;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 /**
  * Tests the integration of the new AST parser into the loading of query results using
  * the Hibernate persisters and loaders.
@@ -961,10 +961,7 @@
 
 	private Human genSimpleHuman(String fName, String lName) {
 		Human h = new Human();
-		h.setName( new Name() );
-		h.getName().setFirst( fName );
-		h.getName().setLast( lName );
-		h.getName().setInitial('X');
+		h.setName( new Name( fName, 'X', lName ) );
 
 		return h;
 	}
@@ -1156,7 +1153,7 @@
 			String dateStr1 = (String) session.createQuery("select str(current_date) from Animal").uniqueResult();
 			String dateStr2 = (String) session.createQuery("select str(year(current_date))||'-'||str(month(current_date))||'-'||str(day(current_date)) from Animal").uniqueResult();
 			System.out.println(dateStr1 + '=' + dateStr2);
-			if ( ! ( getDialect() instanceof Oracle9Dialect ) ) { //Oracle renders the name of the month :(
+			if ( ! ( getDialect() instanceof Oracle9Dialect || getDialect() instanceof Oracle8iDialect ) ) { //Oracle renders the name of the month :(
 				String[] dp1 = StringHelper.split("-", dateStr1);
 				String[] dp2 = StringHelper.split("-", dateStr2);
 				for (int i=0; i<3; i++) {
@@ -1241,17 +1238,11 @@
 		Transaction txn = session.beginTransaction();
 
 		Human human = new Human();
-		human.setName( new Name() );
-		human.getName().setFirst( "Steve" );
-		human.getName().setInitial( 'L' );
-		human.getName().setLast( "Ebersole" );
+		human.setName( new Name( "Steve", 'L', "Ebersole" ) );
 		session.save( human );
 
 		Human friend = new Human();
-		friend.setName( new Name() );
-		friend.getName().setFirst( "John" );
-		friend.getName().setInitial( 'Q' );
-		friend.getName().setLast( "Doe" );
+		friend.setName( new Name( "John", 'Q', "Doe" ) );
 		friend.setBodyWeight( 11.0f );
 		session.save( friend );
 

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -17,7 +17,10 @@
 import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
 import org.hibernate.persister.entity.EntityPersister;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+
 /**
  * Tests execution of bulk UPDATE/DELETE statements through the new AST parser.
  *
@@ -25,6 +28,8 @@
  */
 public class BulkManipulationTest extends FunctionalTestCase {
 
+	private static final Log log = LogFactory.getLog( BulkManipulationTest.class );
+
 	public BulkManipulationTest(String name) {
 		super( name );
 	}
@@ -59,7 +64,7 @@
 			fail( "no exception thrown" );
 		}
 		catch( QueryException e ) {
-			System.out.println( "Caught expected error type : " + e.getMessage() );
+			log.debug( "Caught expected error type : " + e.getMessage() );
 		}
 
 		t.commit();
@@ -75,7 +80,7 @@
 			fail( "no exception thrown" );
 		}
 		catch( QueryException e ) {
-			System.out.println( "Caught expected error type : " + e.getMessage() );
+			log.debug( "Caught expected error type : " + e.getMessage() );
 		}
 
 		t.commit();
@@ -600,10 +605,7 @@
 		Transaction t = s.beginTransaction();
 
 		Human human = new Human();
-		human.setName( new Name() );
-		human.getName().setFirst("Stevee");
-		human.getName().setInitial('X');
-		human.getName().setLast("Ebersole");
+		human.setName( new Name( "Stevee", 'X', "Ebersole" ) );
 
 		s.save( human );
 		s.flush();
@@ -654,14 +656,10 @@
 		Transaction t = s.beginTransaction();
 
 		Human human = new Human();
-		human.setName( new Name() );
-		human.getName().setFirst( "Steve" );
-		human.getName().setInitial('E');
+		human.setName( new Name( "Steve", 'E', null ) );
 
 		Human mother = new Human();
-		mother.setName( new Name() );
-		mother.getName().setFirst( "Jane" );
-		mother.getName().setInitial('E');
+		mother.setName( new Name( "Jane", 'E', null ) );
 		human.setMother( mother );
 
 		s.save( human );
@@ -676,7 +674,7 @@
 			fail( "update allowed across implicit join" );
 		}
 		catch( QueryException e ) {
-			System.out.println( "TEST (OK) : " + e.getMessage() );
+			log.debug( "TEST (OK) : " + e.getMessage() );
 			// expected condition
 		}
 

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/HQLTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/HQLTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -14,10 +14,10 @@
 
 import org.hibernate.Hibernate;
 import org.hibernate.QueryException;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
 import org.hibernate.dialect.DB2Dialect;
 import org.hibernate.dialect.HSQLDialect;
 import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.dialect.Oracle8iDialect;
 import org.hibernate.dialect.Oracle9Dialect;
 import org.hibernate.dialect.PostgreSQLDialect;
 import org.hibernate.dialect.SybaseDialect;
@@ -33,9 +33,10 @@
 import org.hibernate.hql.ast.QueryTranslatorImpl;
 import org.hibernate.hql.ast.tree.ConstructorNode;
 import org.hibernate.hql.ast.tree.DotNode;
+import org.hibernate.hql.ast.tree.FromReferenceNode;
 import org.hibernate.hql.ast.tree.IndexNode;
 import org.hibernate.hql.ast.tree.SelectClause;
-import org.hibernate.hql.ast.tree.FromReferenceNode;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
 
 /**
  * Tests cases where the AST based query translator and the 'classic' query translator generate identical SQL.
@@ -671,6 +672,7 @@
 
 	public void testGroupByFunction() {
 		if ( getDialect() instanceof Oracle9Dialect ) return;
+		if ( getDialect() instanceof Oracle8iDialect ) return; // the new hiearchy...
 		if ( getDialect() instanceof PostgreSQLDialect ) return;
 		assertTranslation( "select count(*) from Human h group by year(h.birthdate)" );
 		assertTranslation( "select count(*) from Human h group by trunc( sqrt(h.bodyWeight*4)/2 )" );
@@ -846,6 +848,10 @@
 	// Second set of examples....
 
 	public void testClassProperty() throws Exception {
+		// This test causes failures on theta-join dialects because the SQL is different.
+		// The queries are semantically the same however.
+		if ( getDialect() instanceof Oracle9Dialect ) return;
+		if ( getDialect() instanceof Oracle8iDialect ) return;
 		assertTranslation( "from Animal a where a.mother.class = Reptile" );
 	}
 
@@ -1120,6 +1126,8 @@
 		// This test causes failures on theta-join dialects because the SQL is different.  The old parser
 		// duplicates the condition, whereas the new parser does not.  The queries are semantically the
 		// same however.
+		if ( getDialect() instanceof Oracle9Dialect ) return;
+		if ( getDialect() instanceof Oracle8iDialect ) return;
 		assertTranslation( "select an.mother.bodyWeight from Animal an join an.mother m where an.mother.bodyWeight > 10" );
 		assertTranslation( "select an.mother.bodyWeight from Animal an where an.mother.bodyWeight > 10" );
 		//assertTranslation("select an.mother from Animal an where an.mother.bodyWeight is not null");

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/Name.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/Name.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/hql/Name.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -6,17 +6,21 @@
  */
 public class Name {
 	private String first;
-	private char initial;
+	private Character initial;
 	private String last;
 	
 	protected Name() {}
 	
-	public Name(String first, char initial, String last) {
+	public Name(String first, Character initial, String last) {
 		this.first = first;
 		this.initial = initial;
 		this.last = last;
 	}
 
+	public Name(String first, char initial, String last) {
+		this( first, new Character( initial ), last );
+	}
+
 	public String getFirst() {
 		return first;
 	}
@@ -25,11 +29,11 @@
 		this.first = first;
 	}
 
-	public char getInitial() {
+	public Character getInitial() {
 		return initial;
 	}
 
-	public void setInitial(char initial) {
+	public void setInitial(Character initial) {
 		this.initial = initial;
 	}
 

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -45,10 +45,12 @@
 import org.hibernate.criterion.Order;
 import org.hibernate.dialect.DB2Dialect;
 import org.hibernate.dialect.DerbyDialect;
+import org.hibernate.dialect.Dialect;
 import org.hibernate.dialect.HSQLDialect;
 import org.hibernate.dialect.InterbaseDialect;
 import org.hibernate.dialect.MckoiDialect;
 import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.dialect.Oracle8iDialect;
 import org.hibernate.dialect.Oracle9Dialect;
 import org.hibernate.dialect.OracleDialect;
 import org.hibernate.dialect.PointbaseDialect;
@@ -56,7 +58,6 @@
 import org.hibernate.dialect.SAPDBDialect;
 import org.hibernate.dialect.SybaseDialect;
 import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.dialect.Dialect;
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.jmx.HibernateService;
 import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -2135,7 +2136,7 @@
 			s.find("select count(*) from Baz as baz where 1 in indices(baz.fooArray)");
 			s.find("select count(*) from Bar as bar where 'abc' in elements(bar.baz.fooArray)");
 			s.find("select count(*) from Bar as bar where 1 in indices(bar.baz.fooArray)");
-			if ( !(getDialect() instanceof DB2Dialect) &&  !(getDialect() instanceof Oracle9Dialect)  ) {
+			if ( !(getDialect() instanceof DB2Dialect) &&  !(getDialect() instanceof Oracle9Dialect) && !(getDialect() instanceof Oracle8iDialect ) ) {
 				s.find("select count(*) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)");
 				s.find("select max( elements(bar.baz.fooArray) ) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)");
 			}

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdSuite.java (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdSuite.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdSuite.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdSuite.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,21 @@
+package org.hibernate.test.naturalid;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.naturalid.immutable.ImmutableNaturalIdTest;
+import org.hibernate.test.naturalid.mutable.MutableNaturalIdTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class NaturalIdSuite {
+	public static Test suite() {
+		TestSuite suite = new TestSuite( "natural ids" );
+		suite.addTest( MutableNaturalIdTest.suite() );
+		suite.addTest( ImmutableNaturalIdTest.suite() );
+		return suite;
+	}
+}

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,248 +0,0 @@
-//$Id$
-package org.hibernate.test.naturalid;
-
-import java.lang.reflect.Field;
-
-import junit.framework.Test;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * @author Gavin King
- */
-public class NaturalIdTest extends FunctionalTestCase {
-	
-	public NaturalIdTest(String str) {
-		super(str);
-	}
-
-	public String[] getMappings() {
-		return new String[] { "naturalid/User.hbm.xml" };
-	}
-
-	public void configure(Configuration cfg) {
-		cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
-		cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
-		cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
-	}
-
-	public static Test suite() {
-		return new FunctionalTestClassTestSuite( NaturalIdTest.class );
-	}
-	
-	public void testNaturalIdCheck() throws Exception {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		
-		User u = new User("gavin", "hb", "secret");
-		s.persist(u);
-		Field name = u.getClass().getDeclaredField("name");
-		name.setAccessible(true);
-		name.set(u, "Gavin");
-		try {
-			s.flush();
-			fail();
-		}
-		catch (HibernateException he) {}
-		name.set(u, "gavin");
-		s.delete(u);
-		t.commit();
-		s.close();
-	}
-	
-	public void testNonexistentNaturalIdCache() {
-		getSessions().getStatistics().clear();
-
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		
-		Object nullUser = s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNull(nullUser);
-	
-		t.commit();
-		s.close();
-	
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
-		
-		s = openSession();
-		t = s.beginTransaction();
-		
-		User u = new User("gavin", "hb", "secret");
-		s.persist(u);
-		
-		t.commit();
-		s.close();
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNotNull(u);
-		
-		t.commit();
-		s.close();
-
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			).setCacheable(true)
-			.uniqueResult();
-		
-		s.delete(u);
-		
-		t.commit();
-		s.close();
-		
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
-
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		nullUser = s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNull(nullUser);
-	
-		t.commit();
-		s.close();
-	
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
-		
-	}
-
-	public void testNaturalIdCache() {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		
-		User u = new User("gavin", "hb", "secret");
-		s.persist(u);
-		
-		t.commit();
-		s.close();
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNotNull(u);
-		
-		t.commit();
-		s.close();
-
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
-		
-		s = openSession();
-		t = s.beginTransaction();
-		
-		User v = new User("xam", "hb", "foobar");
-		s.persist(v);
-		
-		t.commit();
-		s.close();
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			).setCacheable(true)
-			.uniqueResult();
-		
-		assertNotNull(u);
-		
-		t.commit();
-		s.close();
-		
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
-
-		s = openSession();
-		t = s.beginTransaction();
-		s.createQuery("delete User").executeUpdate();
-		t.commit();
-		s.close();
-	}
-
-	public void testQuerying() throws Exception {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-
-		User u = new User("emmanuel", "hb", "bh");
-		s.persist(u);
-
-		t.commit();
-		s.close();
-
-		s = openSession();
-		t = s.beginTransaction();
-
-		u = (User) s.createQuery( "from User u where u.name = :name" )
-			.setParameter( "name", "emmanuel" ).uniqueResult();
-		assertEquals( "emmanuel", u.getName() );
-		s.delete( u );
-
-		t.commit();
-		s.close();
-	}
-}
-

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.hbm.xml
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.hbm.xml	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.hbm.xml	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC 
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
-  This mapping illustrates use of <natural-id>.
-  
--->
-
-<hibernate-mapping 
-	package="org.hibernate.test.naturalid"
-	default-access="field">
-	
-	<class name="User" table="SystemUserInfo">
-		<id name="id">
-			<generator class="increment"/>
-		</id>
-		<natural-id>
-			<property name="name"/>
-			<property name="org"/>
-		</natural-id>
-		<property name="password"/>
-	</class>
-	
-</hibernate-mapping>
\ No newline at end of file

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/User.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,34 +0,0 @@
-//$Id$
-package org.hibernate.test.naturalid;
-
-/**
- * @author Gavin King
- */
-public class User {
-	
-	private Long id;
-	private String name;
-	private String org;
-	private String password;
-	
-	User() {}
-
-	public User(String name, String org, String password) {
-		this.name = name;
-		this.org = org;
-		this.password = password;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	public String getOrg() {
-		return org;
-	}
-	
-}

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable)

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,57 +0,0 @@
-package org.hibernate.test.naturalid.immutable;
-
-import junit.framework.Test;
-
-import org.hibernate.Session;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * {@inheritDoc}
- *
- * @author Steve Ebersole
- */
-public class ImmutableNaturalIdTest extends FunctionalTestCase {
-	public ImmutableNaturalIdTest(String string) {
-		super( string );
-	}
-
-	public String[] getMappings() {
-		return new String[] { "naturalid/immutable/User.hbm.xml" };
-	}
-
-	public static Test suite() {
-		return new FunctionalTestClassTestSuite( ImmutableNaturalIdTest.class );
-	}
-
-	public void testUpdate() {
-		// prepare some test data...
-		Session session = openSession();
-    	session.beginTransaction();
-	  	User user = new User();
-    	user.setUserName( "steve" );
-    	user.setEmail( "steve at hibernate.org" );
-    	user.setFirstName( "Steve" );
-    	user.setInitial( null);
-    	user.setLastName( "Ebersole" );
-    	user.setPassword( "brewhaha" );
-		session.save( user );
-    	session.getTransaction().commit();
-    	session.close();
-
-		// 'user' is now a detached entity, so lets change a property and reattch...
-		user.setPassword( "homebrew" );
-		session = openSession();
-		session.beginTransaction();
-		session.update( user );
-		session.getTransaction().commit();
-		session.close();
-
-		// clean up
-		session = openSession();
-		session.beginTransaction();
-		session.delete( user );
-		session.getTransaction().commit();
-		session.close();
-	}
-}

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,57 @@
+package org.hibernate.test.naturalid.immutable;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ImmutableNaturalIdTest extends FunctionalTestCase {
+	public ImmutableNaturalIdTest(String string) {
+		super( string );
+	}
+
+	public String[] getMappings() {
+		return new String[] { "naturalid/immutable/User.hbm.xml" };
+	}
+
+	public static Test suite() {
+		return new FunctionalTestClassTestSuite( ImmutableNaturalIdTest.class );
+	}
+
+	public void testUpdate() {
+		// prepare some test data...
+		Session session = openSession();
+    	session.beginTransaction();
+	  	User user = new User();
+    	user.setUserName( "steve" );
+    	user.setEmail( "steve at hibernate.org" );
+    	user.setFirstName( "Steve" );
+    	user.setInitial( null);
+    	user.setLastName( "Ebersole" );
+    	user.setPassword( "brewhaha" );
+		session.save( user );
+    	session.getTransaction().commit();
+    	session.close();
+
+		// 'user' is now a detached entity, so lets change a property and reattch...
+		user.setPassword( "homebrew" );
+		session = openSession();
+		session.beginTransaction();
+		session.update( user );
+		session.getTransaction().commit();
+		session.close();
+
+		// clean up
+		session = openSession();
+		session.beginTransaction();
+		session.delete( user );
+		session.getTransaction().commit();
+		session.close();
+	}
+}

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.test.naturalid.immutable">
-
-	<class name="User" table="IMM_NAT_ID_USER" lazy="true">
-        <comment>Users may bid for or sell auction items.</comment>
-        <id name="myUserId" type="java.lang.Integer">
-            <generator class="increment"/>
-        </id>
-        <natural-id mutable="false">
-            <property name="userName" length="10"/>
-        </natural-id>
-        <version name="version"/>
-        <property name="password" not-null="true" length="15" column="`password`"/>
-        <property name="email"/>
-        <property name="firstName" length="50" not-null="true"/>
-        <property name="initial" column="`initial`"/>
-        <property name="lastName" length="50" not-null="true"/>
-    </class>
-
-</hibernate-mapping>
\ No newline at end of file

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.hbm.xml	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.naturalid.immutable">
+
+	<class name="User" table="IMM_NAT_ID_USER" lazy="true">
+        <comment>Users may bid for or sell auction items.</comment>
+        <id name="myUserId" type="java.lang.Integer">
+            <generator class="increment"/>
+        </id>
+        <natural-id mutable="false">
+            <property name="userName" length="10"/>
+        </natural-id>
+        <version name="version"/>
+        <property name="password" not-null="true" length="15" column="`password`"/>
+        <property name="email"/>
+        <property name="firstName" length="50" not-null="true"/>
+        <property name="initial" column="`initial`"/>
+        <property name="lastName" length="50" not-null="true"/>
+    </class>
+
+</hibernate-mapping>
\ No newline at end of file

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,86 +0,0 @@
-package org.hibernate.test.naturalid.immutable;
-
-/**
- * {@inheritDoc}
- *
- * @author Steve Ebersole
- */
-public class User implements java.io.Serializable {
-
-	private Integer myUserId;
-	private Integer version;
-	private String userName;
-	private String password;
-	private String email;
-	private String firstName;
-	private Character initial;
-	private String lastName;
-
-	public User() {
-	}
-
-	public Integer getMyUserId() {
-		return this.myUserId;
-	}
-
-	public void setMyUserId(Integer myUserId) {
-		this.myUserId = myUserId;
-	}
-
-	public String getUserName() {
-		return this.userName;
-	}
-
-	public void setUserName(String userName) {
-		this.userName = userName;
-	}
-
-	public String getPassword() {
-		return this.password;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	public String getEmail() {
-		return this.email;
-	}
-
-	public void setEmail(String email) {
-		this.email = email;
-	}
-
-	public String getFirstName() {
-		return this.firstName;
-	}
-
-	public void setFirstName(String firstName) {
-		this.firstName = firstName;
-	}
-
-	public Character getInitial() {
-		return this.initial;
-	}
-
-	public void setInitial(Character initial) {
-		this.initial = initial;
-	}
-
-	public String getLastName() {
-		return this.lastName;
-	}
-
-	public void setLastName(String lastName) {
-		this.lastName = lastName;
-	}
-
-	public Integer getVersion() {
-		return this.version;
-	}
-
-	public void setVersion(Integer version) {
-		this.version = version;
-	}
-
-}

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/immutable/User.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,86 @@
+package org.hibernate.test.naturalid.immutable;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class User implements java.io.Serializable {
+
+	private Integer myUserId;
+	private Integer version;
+	private String userName;
+	private String password;
+	private String email;
+	private String firstName;
+	private Character initial;
+	private String lastName;
+
+	public User() {
+	}
+
+	public Integer getMyUserId() {
+		return this.myUserId;
+	}
+
+	public void setMyUserId(Integer myUserId) {
+		this.myUserId = myUserId;
+	}
+
+	public String getUserName() {
+		return this.userName;
+	}
+
+	public void setUserName(String userName) {
+		this.userName = userName;
+	}
+
+	public String getPassword() {
+		return this.password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getEmail() {
+		return this.email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public String getFirstName() {
+		return this.firstName;
+	}
+
+	public void setFirstName(String firstName) {
+		this.firstName = firstName;
+	}
+
+	public Character getInitial() {
+		return this.initial;
+	}
+
+	public void setInitial(Character initial) {
+		this.initial = initial;
+	}
+
+	public String getLastName() {
+		return this.lastName;
+	}
+
+	public void setLastName(String lastName) {
+		this.lastName = lastName;
+	}
+
+	public Integer getVersion() {
+		return this.version;
+	}
+
+	public void setVersion(Integer version) {
+		this.version = version;
+	}
+
+}

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable)

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,287 +0,0 @@
-//$Id$
-package org.hibernate.test.naturalid.mutable;
-
-import java.lang.reflect.Field;
-
-import junit.framework.Test;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * @author Gavin King
- */
-public class MutableNaturalIdTest extends FunctionalTestCase {
-	
-	public MutableNaturalIdTest(String str) {
-		super(str);
-	}
-
-	public String[] getMappings() {
-		return new String[] { "naturalid/mutable/User.hbm.xml" };
-	}
-
-	public void configure(Configuration cfg) {
-		cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
-		cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
-		cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
-	}
-
-	public static Test suite() {
-		return new FunctionalTestClassTestSuite( MutableNaturalIdTest.class );
-	}
-
-	public void testReattachmentNaturalIdCheck() throws Throwable {
-		Session s = openSession();
-		s.beginTransaction();
-		User u = new User( "gavin", "hb", "secret" );
-		s.persist( u );
-		s.getTransaction().commit();
-		s.close();
-
-		Field name = u.getClass().getDeclaredField("name");
-		name.setAccessible(true);
-		name.set(u, "Gavin");
-		s = openSession();
-		s.beginTransaction();
-		try {
-			s.update( u );
-			s.getTransaction().commit();
-		}
-		catch( HibernateException expected ) {
-			s.getTransaction().rollback();
-		}
-		catch( Throwable t ) {
-			try {
-				s.getTransaction().rollback();
-			}
-			catch ( Throwable ignore ) {
-			}
-			throw t;
-		}
-		finally {
-			s.close();
-		}
-
-		s = openSession();
-		s.beginTransaction();
-		s.delete( u );
-		s.getTransaction().commit();
-		s.close();
-	}
-	
-	public void testNaturalIdCheck() throws Exception {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		
-		User u = new User("gavin", "hb", "secret");
-		s.persist(u);
-		Field name = u.getClass().getDeclaredField("name");
-		name.setAccessible(true);
-		name.set(u, "Gavin");
-		try {
-			s.flush();
-			fail();
-		}
-		catch (HibernateException he) {}
-		name.set(u, "gavin");
-		s.delete(u);
-		t.commit();
-		s.close();
-	}
-	
-	public void testNonexistentNaturalIdCache() {
-		getSessions().getStatistics().clear();
-
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		
-		Object nullUser = s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNull(nullUser);
-	
-		t.commit();
-		s.close();
-	
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
-		
-		s = openSession();
-		t = s.beginTransaction();
-		
-		User u = new User("gavin", "hb", "secret");
-		s.persist(u);
-		
-		t.commit();
-		s.close();
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNotNull(u);
-		
-		t.commit();
-		s.close();
-
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			).setCacheable(true)
-			.uniqueResult();
-		
-		s.delete(u);
-		
-		t.commit();
-		s.close();
-		
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
-
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		nullUser = s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNull(nullUser);
-	
-		t.commit();
-		s.close();
-	
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
-		
-	}
-
-	public void testNaturalIdCache() {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-		
-		User u = new User("gavin", "hb", "secret");
-		s.persist(u);
-		
-		t.commit();
-		s.close();
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria(User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			)
-			.setCacheable(true)
-			.uniqueResult();
-		
-		assertNotNull(u);
-		
-		t.commit();
-		s.close();
-
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
-		
-		s = openSession();
-		t = s.beginTransaction();
-		
-		User v = new User("xam", "hb", "foobar");
-		s.persist(v);
-		
-		t.commit();
-		s.close();
-		
-		getSessions().getStatistics().clear();
-
-		s = openSession();
-		t = s.beginTransaction();
-		
-		u = (User) s.createCriteria( User.class)
-			.add( Restrictions.naturalId()
-				.set("name", "gavin")
-				.set("org", "hb") 
-			).setCacheable(true)
-			.uniqueResult();
-		
-		assertNotNull(u);
-		
-		t.commit();
-		s.close();
-		
-		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
-		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
-
-		s = openSession();
-		t = s.beginTransaction();
-		s.createQuery("delete User").executeUpdate();
-		t.commit();
-		s.close();
-	}
-
-	public void testQuerying() throws Exception {
-		Session s = openSession();
-		Transaction t = s.beginTransaction();
-
-		User u = new User("emmanuel", "hb", "bh");
-		s.persist(u);
-
-		t.commit();
-		s.close();
-
-		s = openSession();
-		t = s.beginTransaction();
-
-		u = (User) s.createQuery( "from User u where u.name = :name" )
-			.setParameter( "name", "emmanuel" ).uniqueResult();
-		assertEquals( "emmanuel", u.getName() );
-		s.delete( u );
-
-		t.commit();
-		s.close();
-	}
-}
-

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,287 @@
+//$Id$
+package org.hibernate.test.naturalid.mutable;
+
+import java.lang.reflect.Field;
+
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class MutableNaturalIdTest extends FunctionalTestCase {
+	
+	public MutableNaturalIdTest(String str) {
+		super(str);
+	}
+
+	public String[] getMappings() {
+		return new String[] { "naturalid/mutable/User.hbm.xml" };
+	}
+
+	public void configure(Configuration cfg) {
+		cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
+		cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
+		cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+	}
+
+	public static Test suite() {
+		return new FunctionalTestClassTestSuite( MutableNaturalIdTest.class );
+	}
+
+	public void testReattachmentNaturalIdCheck() throws Throwable {
+		Session s = openSession();
+		s.beginTransaction();
+		User u = new User( "gavin", "hb", "secret" );
+		s.persist( u );
+		s.getTransaction().commit();
+		s.close();
+
+		Field name = u.getClass().getDeclaredField("name");
+		name.setAccessible(true);
+		name.set(u, "Gavin");
+		s = openSession();
+		s.beginTransaction();
+		try {
+			s.update( u );
+			s.getTransaction().commit();
+		}
+		catch( HibernateException expected ) {
+			s.getTransaction().rollback();
+		}
+		catch( Throwable t ) {
+			try {
+				s.getTransaction().rollback();
+			}
+			catch ( Throwable ignore ) {
+			}
+			throw t;
+		}
+		finally {
+			s.close();
+		}
+
+		s = openSession();
+		s.beginTransaction();
+		s.delete( u );
+		s.getTransaction().commit();
+		s.close();
+	}
+	
+	public void testNaturalIdCheck() throws Exception {
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+		
+		User u = new User("gavin", "hb", "secret");
+		s.persist(u);
+		Field name = u.getClass().getDeclaredField("name");
+		name.setAccessible(true);
+		name.set(u, "Gavin");
+		try {
+			s.flush();
+			fail();
+		}
+		catch (HibernateException he) {}
+		name.set(u, "gavin");
+		s.delete(u);
+		t.commit();
+		s.close();
+	}
+	
+	public void testNonexistentNaturalIdCache() {
+		getSessions().getStatistics().clear();
+
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+		
+		Object nullUser = s.createCriteria(User.class)
+			.add( Restrictions.naturalId()
+				.set("name", "gavin")
+				.set("org", "hb") 
+			)
+			.setCacheable(true)
+			.uniqueResult();
+		
+		assertNull(nullUser);
+	
+		t.commit();
+		s.close();
+	
+		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
+		
+		s = openSession();
+		t = s.beginTransaction();
+		
+		User u = new User("gavin", "hb", "secret");
+		s.persist(u);
+		
+		t.commit();
+		s.close();
+		
+		getSessions().getStatistics().clear();
+
+		s = openSession();
+		t = s.beginTransaction();
+		
+		u = (User) s.createCriteria(User.class)
+			.add( Restrictions.naturalId()
+				.set("name", "gavin")
+				.set("org", "hb") 
+			)
+			.setCacheable(true)
+			.uniqueResult();
+		
+		assertNotNull(u);
+		
+		t.commit();
+		s.close();
+
+		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
+		
+		getSessions().getStatistics().clear();
+
+		s = openSession();
+		t = s.beginTransaction();
+		
+		u = (User) s.createCriteria(User.class)
+			.add( Restrictions.naturalId()
+				.set("name", "gavin")
+				.set("org", "hb") 
+			).setCacheable(true)
+			.uniqueResult();
+		
+		s.delete(u);
+		
+		t.commit();
+		s.close();
+		
+		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
+		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
+
+		getSessions().getStatistics().clear();
+
+		s = openSession();
+		t = s.beginTransaction();
+		
+		nullUser = s.createCriteria(User.class)
+			.add( Restrictions.naturalId()
+				.set("name", "gavin")
+				.set("org", "hb") 
+			)
+			.setCacheable(true)
+			.uniqueResult();
+		
+		assertNull(nullUser);
+	
+		t.commit();
+		s.close();
+	
+		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
+		
+	}
+
+	public void testNaturalIdCache() {
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+		
+		User u = new User("gavin", "hb", "secret");
+		s.persist(u);
+		
+		t.commit();
+		s.close();
+		
+		getSessions().getStatistics().clear();
+
+		s = openSession();
+		t = s.beginTransaction();
+		
+		u = (User) s.createCriteria(User.class)
+			.add( Restrictions.naturalId()
+				.set("name", "gavin")
+				.set("org", "hb") 
+			)
+			.setCacheable(true)
+			.uniqueResult();
+		
+		assertNotNull(u);
+		
+		t.commit();
+		s.close();
+
+		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+		assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
+		
+		s = openSession();
+		t = s.beginTransaction();
+		
+		User v = new User("xam", "hb", "foobar");
+		s.persist(v);
+		
+		t.commit();
+		s.close();
+		
+		getSessions().getStatistics().clear();
+
+		s = openSession();
+		t = s.beginTransaction();
+		
+		u = (User) s.createCriteria( User.class)
+			.add( Restrictions.naturalId()
+				.set("name", "gavin")
+				.set("org", "hb") 
+			).setCacheable(true)
+			.uniqueResult();
+		
+		assertNotNull(u);
+		
+		t.commit();
+		s.close();
+		
+		assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
+		assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
+
+		s = openSession();
+		t = s.beginTransaction();
+		s.createQuery("delete User").executeUpdate();
+		t.commit();
+		s.close();
+	}
+
+	public void testQuerying() throws Exception {
+		Session s = openSession();
+		Transaction t = s.beginTransaction();
+
+		User u = new User("emmanuel", "hb", "bh");
+		s.persist(u);
+
+		t.commit();
+		s.close();
+
+		s = openSession();
+		t = s.beginTransaction();
+
+		u = (User) s.createQuery( "from User u where u.name = :name" )
+			.setParameter( "name", "emmanuel" ).uniqueResult();
+		assertEquals( "emmanuel", u.getName() );
+		s.delete( u );
+
+		t.commit();
+		s.close();
+	}
+}
+

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC 
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
-  This mapping illustrates use of <natural-id>.
-  
--->
-
-<hibernate-mapping 
-	package="org.hibernate.test.naturalid"
-	default-access="field">
-	
-	<class name="org.hibernate.test.naturalid.mutable.User" table="SystemUserInfo">
-		<id name="id">
-			<generator class="increment"/>
-		</id>
-		<natural-id>
-			<property name="name"/>
-			<property name="org"/>
-		</natural-id>
-		<property name="password"/>
-	</class>
-	
-</hibernate-mapping>
\ No newline at end of file

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.hbm.xml	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+  This mapping illustrates use of <natural-id>.
+  
+-->
+
+<hibernate-mapping 
+	package="org.hibernate.test.naturalid"
+	default-access="field">
+	
+	<class name="org.hibernate.test.naturalid.mutable.User" table="SystemUserInfo">
+		<id name="id">
+			<generator class="increment"/>
+		</id>
+		<natural-id>
+			<property name="name"/>
+			<property name="org"/>
+		</natural-id>
+		<property name="password"/>
+	</class>
+	
+</hibernate-mapping>
\ No newline at end of file

Deleted: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -1,34 +0,0 @@
-//$Id$
-package org.hibernate.test.naturalid.mutable;
-
-/**
- * @author Gavin King
- */
-public class User {
-	
-	private Long id;
-	private String name;
-	private String org;
-	private String password;
-	
-	User() {}
-
-	public User(String name, String org, String password) {
-		this.name = name;
-		this.org = org;
-		this.password = password;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	public String getOrg() {
-		return org;
-	}
-	
-}

Copied: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java (from rev 11673, branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java)
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java	                        (rev 0)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/naturalid/mutable/User.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -0,0 +1,34 @@
+//$Id$
+package org.hibernate.test.naturalid.mutable;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+	
+	private Long id;
+	private String name;
+	private String org;
+	private String password;
+	
+	User() {}
+
+	public User(String name, String org, String password) {
+		this.name = name;
+		this.org = org;
+		this.password = password;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getOrg() {
+		return org;
+	}
+	
+}

Modified: branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java
===================================================================
--- branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java	2007-06-08 20:48:56 UTC (rev 11673)
+++ branches/Branch_3_2_4_SP1_CP/Hibernate3/test/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java	2007-06-08 21:57:13 UTC (rev 11674)
@@ -99,6 +99,7 @@
 		//      throwing a sql exception because the SQL gets passed
 		//      "un-processed"...
 		Session s = openSession();
+		s.beginTransaction();
 		try {
 			String sql = "select {org.*} " +
 			             "from organization org";
@@ -109,6 +110,7 @@
 			// expected behavior
 		}
 		finally {
+			s.getTransaction().rollback();
 			s.close();
 		}
 	}




More information about the hibernate-commits mailing list