Author: stliu
Date: 2010-09-28 02:15:52 -0400 (Tue, 28 Sep 2010)
New Revision: 20730
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Configuration.java
Log:
JBPAPP-5022 Include new feature (Create index on schema update) in HHH-1012 into next EAP
5 release.
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Configuration.java
===================================================================
---
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Configuration.java 2010-09-27
22:09:02 UTC (rev 20729)
+++
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Configuration.java 2010-09-28
06:15:52 UTC (rev 20730)
@@ -111,6 +111,7 @@
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.JACCConfiguration;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
+import org.hibernate.tool.hbm2ddl.IndexMetadata;
import org.hibernate.tool.hbm2ddl.TableMetadata;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
import org.hibernate.type.SerializationException;
@@ -1066,27 +1067,26 @@
}
}
}
-
- }
-
- /*//broken, 'cos we don't generate these with names in SchemaExport
- subIter = table.getIndexIterator();
- while ( subIter.hasNext() ) {
- Index index = (Index) subIter.next();
- if ( !index.isForeignKey() || !dialect.hasImplicitIndexForForeignKey() ) {
- if ( tableInfo==null || tableInfo.getIndexMetadata( index.getFilterName() ) == null
) {
- script.add( index.sqlCreateString(dialect, mapping) );
+ Iterator subIter = table.getIndexIterator();
+ while ( subIter.hasNext() ) {
+ final Index index = (Index) subIter.next();
+ // Skip if index already exists
+ if ( tableInfo != null && StringHelper.isNotEmpty( index.getName() ) ) {
+ final IndexMetadata meta = tableInfo.getIndexMetadata( index.getName() );
+ if ( meta != null ) {
+ continue;
+ }
}
+ script.add(
+ index.sqlCreateString(
+ dialect,
+ mapping,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
}
}
- //broken, 'cos we don't generate these with names in SchemaExport
- subIter = table.getUniqueKeyIterator();
- while ( subIter.hasNext() ) {
- UniqueKey uk = (UniqueKey) subIter.next();
- if ( tableInfo==null || tableInfo.getIndexMetadata( uk.getFilterName() ) == null ) {
- script.add( uk.sqlCreateString(dialect, mapping) );
- }
- }*/
}
iter = iterateGenerators( dialect );