[hibernate-commits] Hibernate SVN: r21043 - in core/branches/Branch_3_3_2_GA_CP: core/src/main/java/org/hibernate/engine and 5 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jul 25 03:11:31 EDT 2012


Author: stliu
Date: 2012-07-25 03:11:30 -0400 (Wed, 25 Jul 2012)
New Revision: 21043

Modified:
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Settings.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/CollectionEntry.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/sql/Select.java
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
   core/branches/Branch_3_3_2_GA_CP/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java
   core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java
Log:
JBPAPP-6476 HHH-6204 - JoinColumn on non key field fails to populate collection

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -230,7 +230,21 @@
 	 * JNDI initial context class, <tt>Context.INITIAL_CONTEXT_FACTORY</tt>
 	 */
 	public static final String JNDI_CLASS ="hibernate.jndi.class";
+
+
 	/**
+	 * Comma-separated names of the optional files containing SQL DML statements executed
+	 * during the SessionFactory creation.
+	 * File order matters, the statements of a give file are executed before the statements of the
+	 * following files.
+	 *
+	 * These statements are only executed if the schema is created ie if <tt>hibernate.hbm2ddl.auto</tt>
+	 * is set to <tt>create</tt> or <tt>create-drop</tt>.
+	 *
+	 * The default value is <tt>/import.sql</tt>
+	 */
+	public static final String HBM2DDL_IMPORT_FILES = "hibernate.hbm2ddl.import_files";
+	/**
 	 * JNDI provider URL, <tt>Context.PROVIDER_URL</tt>
 	 */
 	public static final String JNDI_URL ="hibernate.jndi.url";
@@ -539,6 +553,7 @@
 
 	private static final Logger log = LoggerFactory.getLogger(Environment.class);
 
+
 	/**
 	 * Issues warnings to the user when any obsolete or renamed property names are used.
 	 *

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Settings.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Settings.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Settings.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -98,6 +98,7 @@
 //	private ComponentTuplizerFactory componentTuplizerFactory; todo : HHH-3517 and HHH-1907
 //	private BytecodeProvider bytecodeProvider;
 	private JdbcSupport jdbcSupport;
+	private String importFiles;
 	/**
 	 * Package protected constructor
 	 */
@@ -114,6 +115,14 @@
 //		return formatSql;
 //	}
 
+	public String getImportFiles() {
+		return importFiles;
+	}
+
+	public void setImportFiles(String importFiles) {
+		this.importFiles = importFiles;
+	}
+
 	public SQLStatementLogger getSqlStatementLogger() {
 		return sqlStatementLogger;
 	}

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/SettingsFactory.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/SettingsFactory.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -323,7 +323,7 @@
 			settings.setAutoCreateSchema(true);
 			settings.setAutoDropSchema(true);
 		}
-
+		settings.setImportFiles( properties.getProperty( Environment.HBM2DDL_IMPORT_FILES ) );
 		EntityMode defaultEntityMode = EntityMode.parse( properties.getProperty( Environment.DEFAULT_ENTITY_MODE ) );
 		log.info( "Default entity-mode: " + defaultEntityMode );
 		settings.setDefaultEntityMode( defaultEntityMode );

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/CollectionEntry.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/CollectionEntry.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/CollectionEntry.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -183,7 +183,9 @@
 	}
 
 	public void preFlush(PersistentCollection collection) throws HibernateException {
-		
+		if(loadedKey == null && collection.getKey() !=null){
+			loadedKey = collection.getKey();
+		}
 		boolean nonMutableChange = collection.isDirty() && 
 				getLoadedPersister()!=null && 
 				!getLoadedPersister().isMutable();

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -53,6 +53,7 @@
 import org.hibernate.proxy.HibernateProxy;
 import org.hibernate.proxy.LazyInitializer;
 import org.hibernate.tuple.ElementWrapper;
+import org.hibernate.type.CollectionType;
 import org.hibernate.util.IdentityMap;
 import org.hibernate.util.MarkerObject;
 import org.slf4j.Logger;
@@ -693,7 +694,64 @@
 	/**
 	 * Get the entity that owns this persistent collection
 	 */
-	public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException {
+	public Object getCollectionOwner( Serializable key, CollectionPersister collectionPersister) throws MappingException {
+		// todo : we really just need to add a split in the notions of:
+		//		1) collection key
+		//		2) collection owner key
+		// these 2 are not always the same.  Same is true in the case of ToOne associations with property-ref...
+		final EntityPersister ownerPersister = collectionPersister.getOwnerEntityPersister();
+		if ( ownerPersister.getIdentifierType().getReturnedClass().isInstance( key ) ) {
+			return getEntity( new EntityKey( key, collectionPersister.getOwnerEntityPersister(), session.getEntityMode() ) );
+		}
+
+		// we have a property-ref type mapping for the collection key.  But that could show up a few ways here...
+		//
+		//		1) The incoming key could be the entity itself...
+		if ( ownerPersister.isInstance( key, session.getEntityMode() ) ) {
+			final Serializable owenerId = ownerPersister.getIdentifier( key, session.getEntityMode() );
+			if ( owenerId == null ) {
+				return null;
+			}
+			return getEntity( new EntityKey(  owenerId, ownerPersister, session.getEntityMode() ) );
+		}
+
+		final CollectionType collectionType = collectionPersister.getCollectionType();
+
+		//		2) The incoming key is most likely the collection key which we need to resolve to the owner key
+		//			find the corresponding owner instance
+		//			a) try by EntityUniqueKey
+		if ( collectionType.getLHSPropertyName() != null ) {
+			Object owner = getEntity(
+					new EntityUniqueKey(
+							ownerPersister.getEntityName(),
+							collectionType.getLHSPropertyName(),
+							key,
+							collectionPersister.getKeyType(),
+							session.getEntityMode(),
+							session.getFactory()
+					)
+			);
+			if ( owner != null ) {
+				return owner;
+			}
+
+			//		b) try by EntityKey, which means we need to resolve owner-key -> collection-key
+			//			IMPL NOTE : yes if we get here this impl is very non-performant, but PersistenceContext
+			//					was never designed to handle this case; adding that capability for real means splitting
+			//					the notions of:
+			//						1) collection key
+			//						2) collection owner key
+			// 					these 2 are not always the same (same is true in the case of ToOne associations with
+			// 					property-ref).  That would require changes to (at least) CollectionEntry and quite
+			//					probably changes to how the sql for collection initializers are generated
+			//
+			//			We could also possibly see if the referenced property is a natural id since we already have caching
+			//			in place of natural id snapshots.  BUt really its better to just do it the right way ^^ if we start
+			// 			going that route
+			final Serializable ownerId = ownerPersister.getIdByUniqueKey( key, collectionType.getLHSPropertyName(), session );
+			return getEntity( new EntityKey( ownerId, ownerPersister, session.getEntityMode() ));
+		}
+
 		return getEntity( new EntityKey( key, collectionPersister.getOwnerEntityPersister(), session.getEntityMode() ) );
 	}
 

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -174,6 +174,7 @@
 	private final Type[] subclassPropertyTypeClosure;
 	private final String[][] subclassPropertyFormulaTemplateClosure;
 	private final String[][] subclassPropertyColumnNameClosure;
+	private final String[][] subclassPropertyColumnReaderTemplateClosure;
 	private final FetchMode[] subclassPropertyFetchModeClosure;
 	private final boolean[] subclassPropertyNullabilityClosure;
 	private final boolean[] propertyDefinedOnSubclass;
@@ -592,6 +593,7 @@
 		ArrayList templates = new ArrayList();
 		ArrayList propColumns = new ArrayList();
 		ArrayList joinedFetchesList = new ArrayList();
+		ArrayList propColumnReaderTemplates = new ArrayList();
 		ArrayList cascades = new ArrayList();
 		ArrayList definedBySubclass = new ArrayList();
 		ArrayList propColumnNumbers = new ArrayList();
@@ -612,6 +614,7 @@
 			Iterator colIter = prop.getColumnIterator();
 			String[] cols = new String[prop.getColumnSpan()];
 			String[] forms = new String[prop.getColumnSpan()];
+			String[] readerTemplates = new String[prop.getColumnSpan()];
 			int[] colnos = new int[prop.getColumnSpan()];
 			int[] formnos = new int[prop.getColumnSpan()];
 			int l = 0;
@@ -633,6 +636,7 @@
 					colnos[l] = columns.size(); //before add :-)
 					formnos[l] = -1;
 					columns.add( colName );
+					readerTemplates[l] = colName;
 					cols[l] = colName;
 					aliases.add( thing.getAlias( factory.getDialect(), prop.getValue().getTable() ) );
 					columnsLazy.add( lazy );
@@ -642,6 +646,7 @@
 			}
 			propColumns.add( cols );
 			templates.add( forms );
+			propColumnReaderTemplates.add( readerTemplates );
 			propColumnNumbers.add( colnos );
 			propFormulaNumbers.add( formnos );
 
@@ -663,6 +668,7 @@
 		subclassPropertyTypeClosure = ArrayHelper.toTypeArray( types );
 		subclassPropertyNullabilityClosure = ArrayHelper.toBooleanArray( propNullables );
 		subclassPropertyFormulaTemplateClosure = ArrayHelper.to2DStringArray( templates );
+		subclassPropertyColumnReaderTemplateClosure = ArrayHelper.to2DStringArray( propColumnReaderTemplates );
 		subclassPropertyColumnNameClosure = ArrayHelper.to2DStringArray( propColumns );
 		subclassPropertyColumnNumberClosure = ArrayHelper.to2DIntArray( propColumnNumbers );
 		subclassPropertyFormulaNumberClosure = ArrayHelper.to2DIntArray( propFormulaNumbers );
@@ -1073,6 +1079,106 @@
 
 	}
 
+	@Override
+	public Serializable getIdByUniqueKey(Serializable key, String uniquePropertyName, SessionImplementor session) throws HibernateException {
+		if ( log.isTraceEnabled() ) {
+			log.trace( String.format( "resolving unique key [%s] to identifier for entity [%s]",
+					key,
+					getEntityName() ) );
+		}
+
+		int propertyIndex = getSubclassPropertyIndex( uniquePropertyName );
+		if ( propertyIndex < 0 ) {
+			throw new HibernateException(
+					"Could not determine Type for property [" + uniquePropertyName + "] on entity [" + getEntityName() + "]"
+			);
+		}
+		Type propertyType = getSubclassPropertyType( propertyIndex );
+
+		try {
+			String selectString = generateIdByUniqueKeySelectString( uniquePropertyName );
+			PreparedStatement ps = session.getBatcher()
+					.prepareStatement( selectString );
+			try {
+				propertyType.nullSafeSet( ps, key, 1, session );
+				ResultSet rs = ps.executeQuery();
+				try {
+					//if there is no resulting row, return null
+					if ( !rs.next() ) {
+						return null;
+					}
+					return (Serializable) getIdentifierType().nullSafeGet( rs, getIdentifierAliases(), session, null );
+				}
+				finally {
+					rs.close();
+				}
+			}
+			finally {
+				ps.close();
+			}
+		}
+		catch ( SQLException e ) {
+			throw getFactory().getSQLExceptionConverter().convert(
+					e,
+					String.format(
+							"could not resolve unique property [%s] to identifier for entity [%s]",
+							uniquePropertyName,
+							getEntityName()
+					),
+					getSQLSnapshotSelectString()
+			);
+		}
+
+	}
+
+	protected String generateIdByUniqueKeySelectString(String uniquePropertyName) {
+		Select select = new Select( getFactory().getDialect() );
+
+		if ( getFactory().getSettings().isCommentsEnabled() ) {
+			select.setComment( "resolve id by unique property [" + getEntityName() + "." + uniquePropertyName + "]" );
+		}
+
+		final String rooAlias = getRootAlias();
+
+		select.setFromClause( fromTableFragment( rooAlias ) + fromJoinFragment( rooAlias, true, false ) );
+
+		SelectFragment selectFragment = new SelectFragment();
+		selectFragment.addColumns( rooAlias, getIdentifierColumnNames(), getIdentifierAliases() );
+		select.setSelectClause( selectFragment );
+
+		StringBuilder whereClauseBuffer = new StringBuilder();
+		final int uniquePropertyIndex = getSubclassPropertyIndex( uniquePropertyName );
+		final String uniquePropertyTableAlias = generateTableAlias(
+				rooAlias,
+				getSubclassPropertyTableNumber( uniquePropertyIndex )
+		);
+		String sep = "";
+		for ( String columnTemplate : getSubclassPropertyColumnReaderTemplateClosure()[uniquePropertyIndex] ) {
+			if ( columnTemplate == null ) {
+				continue;
+			}
+			final String columnReference = StringHelper.replace( columnTemplate, Template.TEMPLATE, uniquePropertyTableAlias );
+			whereClauseBuffer.append( sep ).append( columnReference ).append( "=?" );
+			sep = " and ";
+		}
+		for ( String formulaTemplate : getSubclassPropertyFormulaTemplateClosure()[uniquePropertyIndex] ) {
+			if ( formulaTemplate == null ) {
+				continue;
+			}
+			final String formulaReference = StringHelper.replace( formulaTemplate, Template.TEMPLATE, uniquePropertyTableAlias );
+			whereClauseBuffer.append( sep ).append( formulaReference ).append( "=?" );
+			sep = " and ";
+		}
+		whereClauseBuffer.append( whereJoinFragment( rooAlias, true, false ) );
+
+		select.setWhereClause( whereClauseBuffer.toString() );
+
+		return select.setOuterJoins( "", "" ).toStatementString();
+	}
+
+
+
+
 	/**
 	 * Generate the SQL that selects the version number by id
 	 */
@@ -1513,6 +1619,10 @@
 		return subclassPropertyColumnNameClosure;
 	}
 
+	public String[][] getSubclassPropertyColumnReaderTemplateClosure() {
+		return subclassPropertyColumnReaderTemplateClosure;
+	}
+
 	protected String[] getSubclassPropertyNameClosure() {
 		return subclassPropertyNameClosure;
 	}

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -477,6 +477,8 @@
 	public Object[] getDatabaseSnapshot(Serializable id, SessionImplementor session)
 	throws HibernateException;
 
+	public Serializable getIdByUniqueKey(Serializable key, String uniquePropertyName, SessionImplementor session);
+
 	/**
 	 * Get the current version of the object, or return null if there is no row for
 	 * the given identifier. In the case of unversioned data, return any object

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/sql/Select.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/sql/Select.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/sql/Select.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -98,6 +98,11 @@
 		return dialect.transformSelectString( buf.toString() );
 	}
 
+	public Select setSelectClause(SelectFragment selectFragment) {
+		setSelectClause( selectFragment.toFragmentString().substring( 2 ) );
+		return this;
+	}
+
 	/**
 	 * Sets the fromClause.
 	 * @param fromClause The fromClause to set

Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -67,12 +67,12 @@
 public class SchemaExport {
 
 	private static final Logger log = LoggerFactory.getLogger( SchemaExport.class );
-
+	private static final String DEFAULT_IMPORT_FILE = "/import.sql";
 	private ConnectionHelper connectionHelper;
 	private String[] dropSQL;
 	private String[] createSQL;
 	private String outputFile = null;
-	private String importFile = "/import.sql";
+	private String importFiles = "/import.sql";
 	private Dialect dialect;
 	private String delimiter;
 	private final List exceptions = new ArrayList();
@@ -104,6 +104,7 @@
 		createSQL = cfg.generateSchemaCreationScript( dialect );
 		sqlStatementLogger = settings.getSqlStatementLogger();
 		formatter = ( sqlStatementLogger.isFormatSql() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
+		importFiles = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILES, cfg.getProperties(), DEFAULT_IMPORT_FILE );
 	}
 
 	/**
@@ -128,8 +129,10 @@
 		createSQL = cfg.generateSchemaCreationScript( dialect );
 
 		formatter = ( PropertiesHelper.getBoolean( Environment.FORMAT_SQL, props ) ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
+		importFiles =  PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILES, props, DEFAULT_IMPORT_FILE );
 	}
 
+
 	/**
 	 * Create a schema exporter for the given Configuration, using the supplied connection for connectivity.
 	 *
@@ -143,6 +146,7 @@
 		dropSQL = cfg.generateDropSchemaScript( dialect );
 		createSQL = cfg.generateSchemaCreationScript( dialect );
 		formatter = ( PropertiesHelper.getBoolean( Environment.FORMAT_SQL, cfg.getProperties() ) ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
+		this.importFiles = PropertiesHelper.getString( Environment.HBM2DDL_IMPORT_FILES, cfg.getProperties(), DEFAULT_IMPORT_FILE );
 	}
 
 	/**
@@ -163,7 +167,7 @@
 	 * @return this
 	 */
 	public SchemaExport setImportFile(String filename) {
-		importFile = filename;
+		importFiles = filename;
 		return this;
 	}
 
@@ -234,11 +238,11 @@
 		try {
 
 			try {
-				InputStream stream = ConfigHelper.getResourceAsStream( importFile );
+				InputStream stream = ConfigHelper.getUserResourceAsStream( importFiles );
 				importFileReader = new InputStreamReader( stream );
 			}
 			catch ( HibernateException e ) {
-				log.debug( "import file not found: " + importFile );
+				log.debug( "import file not found: " + importFiles );
 			}
 
 			if ( outputFile != null ) {
@@ -306,7 +310,7 @@
 
 	private void importScript(Reader importFileReader, Statement statement)
 			throws IOException {
-		log.info( "Executing import script: " + importFile );
+		log.info( "Executing import script: " + importFiles );
 		BufferedReader reader = new BufferedReader( importFileReader );
 		long lineNo = 0;
 		for ( String sql = reader.readLine(); sql != null; sql = reader.readLine() ) {
@@ -470,6 +474,11 @@
 				cfg.setProperties( props );
 			}
 
+			if (importFile != null) {
+				cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, importFile );
+			}
+
+
 			SchemaExport se = new SchemaExport( cfg )
 					.setHaltOnError( halt )
 					.setOutputFile( outFile )

Modified: core/branches/Branch_3_3_2_GA_CP/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -288,13 +288,17 @@
 	}
 
 	protected void runSchemaGeneration() {
-		SchemaExport export = new SchemaExport( cfg );
-		export.create( true, true );
+		if ( recreateSchema() ) {
+			SchemaExport export = new SchemaExport( cfg );
+			export.create( true, true );
+		}
 	}
 
 	protected void runSchemaDrop() {
-		SchemaExport export = new SchemaExport( cfg );
-		export.drop( true, true );
+		if ( recreateSchema() ) {
+			SchemaExport export = new SchemaExport( cfg );
+			export.drop( true, true );
+		}
 	}
 
 	private void reportSkip(Skip skip) {

Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java	2012-07-22 13:46:43 UTC (rev 21042)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java	2012-07-25 07:11:30 UTC (rev 21043)
@@ -69,6 +69,11 @@
 		return factory;
 	}
 
+	@Override
+	public Serializable getIdByUniqueKey(Serializable key, String uniquePropertyName, SessionImplementor session) {
+		throw new UnsupportedOperationException( "not supported" );
+	}
+
 	public Class getMappedClass() {
 		return Custom.class;
 	}



More information about the hibernate-commits mailing list