HHH-15060 - Associations with @NotFound should always be left joined when de-referenced in HQL/Criteria
- `@NotFound` no longer exports a physical foreign-key
This commit is contained in:
parent
5febc70134
commit
1f84125e44
|
@ -3462,10 +3462,20 @@ public final class AnnotationBinder {
|
||||||
JoinColumns joinColumns,
|
JoinColumns joinColumns,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
final boolean noConstraintByDefault = context.getBuildingOptions().isNoConstraintByDefault();
|
final boolean noConstraintByDefault = context.getBuildingOptions().isNoConstraintByDefault();
|
||||||
if ( ( joinColumn != null && ( joinColumn.foreignKey().value() == ConstraintMode.NO_CONSTRAINT
|
|
||||||
|| joinColumn.foreignKey().value() == ConstraintMode.PROVIDER_DEFAULT && noConstraintByDefault ) )
|
final NotFound notFoundAnn= property.getAnnotation( NotFound.class );
|
||||||
|| ( joinColumns != null && ( joinColumns.foreignKey().value() == ConstraintMode.NO_CONSTRAINT
|
if ( notFoundAnn != null ) {
|
||||||
|| joinColumns.foreignKey().value() == ConstraintMode.PROVIDER_DEFAULT && noConstraintByDefault ) ) ) {
|
// supersedes all others
|
||||||
|
value.setForeignKeyName( "none" );
|
||||||
|
}
|
||||||
|
else if ( joinColumn != null && (
|
||||||
|
joinColumn.foreignKey().value() == ConstraintMode.NO_CONSTRAINT
|
||||||
|
|| ( joinColumn.foreignKey().value() == ConstraintMode.PROVIDER_DEFAULT && noConstraintByDefault ) ) ) {
|
||||||
|
value.setForeignKeyName( "none" );
|
||||||
|
}
|
||||||
|
else if ( joinColumns != null && (
|
||||||
|
joinColumns.foreignKey().value() == ConstraintMode.NO_CONSTRAINT
|
||||||
|
|| ( joinColumns.foreignKey().value() == ConstraintMode.PROVIDER_DEFAULT && noConstraintByDefault ) ) ) {
|
||||||
value.setForeignKeyName( "none" );
|
value.setForeignKeyName( "none" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class NotFoundLogicalOneToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
|
// @JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
|
||||||
@NotFound(action = NotFoundAction.IGNORE)
|
@NotFound(action = NotFoundAction.IGNORE)
|
||||||
public Currency getCurrency() {
|
public Currency getCurrency() {
|
||||||
return currency;
|
return currency;
|
||||||
|
|
Loading…
Reference in New Issue