mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 08:35:13 +00:00
only create unique constraint for non-pk column
This commit is contained in:
parent
18187f58ed
commit
4a567e04cb
@ -63,7 +63,7 @@ public String[] getSqlCreateStrings(Table table, JdbcEnvironment jdbcEnvironment
|
||||
|
||||
// Try to find out the name of the primary key in case the dialect needs it to create an identity
|
||||
String pkColName = null;
|
||||
if ( hasPrimaryKey && isPrimaryKeyIdentity ) {
|
||||
if ( hasPrimaryKey ) {
|
||||
Column pkColumn = table.getPrimaryKey().getColumns().iterator().next();
|
||||
pkColName = pkColumn.getColumnName().getText( dialect );
|
||||
}
|
||||
@ -104,8 +104,8 @@ public String[] getSqlCreateStrings(Table table, JdbcEnvironment jdbcEnvironment
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( col.isUnique() ) {
|
||||
//only create unique constraint for non-pk column
|
||||
if ( col.isUnique() && !colName.equals( pkColName )) {
|
||||
UniqueKey uk = table.getOrCreateUniqueKey(
|
||||
col.getColumnName().getText( dialect ) + '_' );
|
||||
uk.addColumn( col );
|
||||
|
Loading…
x
Reference in New Issue
Block a user