fix disabling of fk in @ManyToOne associations

This commit is contained in:
Gavin King 2022-01-27 19:44:32 +01:00
parent abe0cc3108
commit 6bfa8d6c27
3 changed files with 5 additions and 4 deletions

View File

@ -84,7 +84,7 @@ public class ManyToOne extends ToOne {
( (Component) property.getValue() ).sortProperties(); ( (Component) property.getValue() ).sortProperties();
} }
// todo : if "none" another option is to create the ForeignKey object still but to set its #disableCreation flag // todo : if "none" another option is to create the ForeignKey object still but to set its #disableCreation flag
if ( !hasFormula() && !"none".equals( getForeignKeyName() ) ) { if ( isForeignKeyEnabled() && !hasFormula() ) {
ForeignKey fk = getTable().createForeignKey( ForeignKey fk = getTable().createForeignKey(
getForeignKeyName(), getForeignKeyName(),
getConstraintColumns(), getConstraintColumns(),

View File

@ -1595,7 +1595,7 @@ public class MappingModelCreationHelper {
} }
else if ( fetchStyle == FetchStyle.JOIN else if ( fetchStyle == FetchStyle.JOIN
|| !lazy || !lazy
|| ( value instanceof OneToOne && value.isNullable() ) || value instanceof OneToOne && value.isNullable()
|| value instanceof ManyToOne && value.isNullable() && ( (ManyToOne) value ).isIgnoreNotFound() ) { || value instanceof ManyToOne && value.isNullable() && ( (ManyToOne) value ).isIgnoreNotFound() ) {
fetchTiming = FetchTiming.IMMEDIATE; fetchTiming = FetchTiming.IMMEDIATE;
} }

View File

@ -369,7 +369,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
} }
} }
if ( (! etype.isNullable() ) && idPropName != null ) { if ( !etype.isNullable() && idPropName != null ) {
String idpath2 = extendPath( path, idPropName ); String idpath2 = extendPath( path, idPropName );
addPropertyPath( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); addPropertyPath( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
initPropertyPaths( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory ); initPropertyPaths( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
@ -397,7 +397,8 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
final String[] columns, final String[] columns,
final String[] columnReaders, final String[] columnReaders,
final String[] columnReaderTemplates, final String[] columnReaderTemplates,
String[] formulaTemplates, final Mapping factory) throws MappingException { final String[] formulaTemplates,
final Mapping factory) throws MappingException {
Type[] types = type.getSubtypes(); Type[] types = type.getSubtypes();
String[] properties = type.getPropertyNames(); String[] properties = type.getPropertyNames();