HHH-10396 - Fix In a @OneToMany association with @JoinColum the @ForeignKey is not taken into consideration when generating the association database schema

This commit is contained in:
Andrea Boriero 2015-12-01 16:46:25 +00:00
parent 14c97f0b5b
commit cb0729b59f
1 changed files with 11 additions and 1 deletions

View File

@ -1097,7 +1097,6 @@ public abstract class CollectionBinder {
key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() );
key.setCascadeDeleteEnabled( cascadeDeleteEnabled );
collValue.setKey( key );
if ( property != null ) {
final ForeignKey fk = property.getAnnotation( ForeignKey.class );
if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) {
@ -1124,6 +1123,17 @@ public abstract class CollectionBinder {
}
}
else {
final JoinColumn joinColumnAnn = property.getAnnotation( JoinColumn.class );
if ( joinColumnAnn != null ) {
if ( joinColumnAnn.foreignKey().value() == ConstraintMode.NO_CONSTRAINT ) {
key.setForeignKeyName( "none" );
}
else {
key.setForeignKeyName( StringHelper.nullIfEmpty( joinColumnAnn.foreignKey().name() ) );
}
}
}
}
}
}