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 ef4db6c855
commit bf92137880
1 changed files with 11 additions and 1 deletions

View File

@ -1092,7 +1092,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() ) ) {
@ -1119,6 +1118,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() ) );
}
}
}
}
}
}