mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 08:35:13 +00:00
HHH-9798 - Fix Unique constraint of @JoinColumn in @JoinTable not generated
This commit is contained in:
parent
fdd7fb8080
commit
fff9a16a22
@ -17,7 +17,9 @@
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Constraint;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UniqueKey;
|
||||
import org.hibernate.tool.schema.spi.Exporter;
|
||||
|
||||
/**
|
||||
@ -105,6 +107,16 @@ public String[] getSqlCreateStrings(Table table, Metadata metadata) {
|
||||
|
||||
}
|
||||
|
||||
if ( col.isUnique() ) {
|
||||
String keyName = Constraint.generateName( "UK_", table, col );
|
||||
UniqueKey uk = table.getOrCreateUniqueKey( keyName );
|
||||
uk.addColumn( col );
|
||||
buf.append(
|
||||
dialect.getUniqueDelegate()
|
||||
.getColumnDefinitionUniquenessFragment( col )
|
||||
);
|
||||
}
|
||||
|
||||
if ( col.getCheckConstraint() != null && dialect.supportsColumnCheck() ) {
|
||||
buf.append( " check (" )
|
||||
.append( col.getCheckConstraint() )
|
||||
|
Loading…
x
Reference in New Issue
Block a user