Skip to content

Commit

Permalink
HHH-8092 Configuration#generateSchemaUpdateScript does not create unique
Browse files Browse the repository at this point in the history
constraints
  • Loading branch information
brmeyer committed Mar 21, 2013
1 parent 467daa2 commit b5457f3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
Expand Up @@ -1186,6 +1186,21 @@ public String[] generateSchemaUpdateScript(Dialect dialect, DatabaseMetadata dat
table.isQuoted()
);

Iterator uniqueIter = table.getUniqueKeyIterator();
while ( uniqueIter.hasNext() ) {
final UniqueKey uniqueKey = (UniqueKey) uniqueIter.next();
// Skip if index already exists
if ( tableInfo != null && StringHelper.isNotEmpty( uniqueKey.getName() ) ) {
final IndexMetadata meta = tableInfo.getIndexMetadata( uniqueKey.getName() );
if ( meta != null ) {
continue;
}
}
String constraintString = uniqueKey.sqlCreateString( dialect,
mapping, tableCatalog, tableSchema );
if (constraintString != null) script.add( constraintString );
}

if ( dialect.hasAlterTable() ) {
Iterator subIter = table.getForeignKeyIterator();
while ( subIter.hasNext() ) {
Expand Down

0 comments on commit b5457f3

Please sign in to comment.