only create unique constraint for non-pk column
This commit is contained in:
parent
18187f58ed
commit
4a567e04cb
|
@ -63,7 +63,7 @@ public class StandardTableExporter implements Exporter<Table> {
|
||||||
|
|
||||||
// Try to find out the name of the primary key in case the dialect needs it to create an identity
|
// Try to find out the name of the primary key in case the dialect needs it to create an identity
|
||||||
String pkColName = null;
|
String pkColName = null;
|
||||||
if ( hasPrimaryKey && isPrimaryKeyIdentity ) {
|
if ( hasPrimaryKey ) {
|
||||||
Column pkColumn = table.getPrimaryKey().getColumns().iterator().next();
|
Column pkColumn = table.getPrimaryKey().getColumns().iterator().next();
|
||||||
pkColName = pkColumn.getColumnName().getText( dialect );
|
pkColName = pkColumn.getColumnName().getText( dialect );
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ public class StandardTableExporter implements Exporter<Table> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//only create unique constraint for non-pk column
|
||||||
if ( col.isUnique() ) {
|
if ( col.isUnique() && !colName.equals( pkColName )) {
|
||||||
UniqueKey uk = table.getOrCreateUniqueKey(
|
UniqueKey uk = table.getOrCreateUniqueKey(
|
||||||
col.getColumnName().getText( dialect ) + '_' );
|
col.getColumnName().getText( dialect ) + '_' );
|
||||||
uk.addColumn( col );
|
uk.addColumn( col );
|
||||||
|
|
Loading…
Reference in New Issue