HHH-12842 - Pass OneToOne constrained to determine nullability of type
(cherry picked from commit 662f6b2b53
)
This commit is contained in:
parent
d6bc53235a
commit
f21e8c64c3
|
@ -71,7 +71,8 @@ public class OneToOne extends ToOne {
|
|||
isLazy(),
|
||||
isUnwrapProxy(),
|
||||
entityName,
|
||||
propertyName
|
||||
propertyName,
|
||||
constrained
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -83,7 +84,8 @@ public class OneToOne extends ToOne {
|
|||
isLazy(),
|
||||
isUnwrapProxy(),
|
||||
entityName,
|
||||
propertyName
|
||||
propertyName,
|
||||
constrained
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,10 @@ public class OneToOneType extends EntityType {
|
|||
private final ForeignKeyDirection foreignKeyType;
|
||||
private final String propertyName;
|
||||
private final String entityName;
|
||||
private final boolean constrained;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #OneToOneType(TypeFactory.TypeScope, String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String)}
|
||||
* @deprecated Use {@link #OneToOneType(TypeFactory.TypeScope, String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String, boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -47,6 +48,11 @@ public class OneToOneType extends EntityType {
|
|||
this( scope, referencedEntityName, foreignKeyType, uniqueKeyPropertyName == null, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #OneToOneType(TypeFactory.TypeScope, String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String, boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public OneToOneType(
|
||||
TypeFactory.TypeScope scope,
|
||||
String referencedEntityName,
|
||||
|
@ -57,10 +63,25 @@ public class OneToOneType extends EntityType {
|
|||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName) {
|
||||
this( scope, referencedEntityName, foreignKeyType, referenceToPrimaryKey, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName, foreignKeyType != ForeignKeyDirection.TO_PARENT );
|
||||
}
|
||||
|
||||
public OneToOneType(
|
||||
TypeFactory.TypeScope scope,
|
||||
String referencedEntityName,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
boolean referenceToPrimaryKey,
|
||||
String uniqueKeyPropertyName,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName,
|
||||
boolean constrained) {
|
||||
super( scope, referencedEntityName, referenceToPrimaryKey, uniqueKeyPropertyName, !lazy, unwrapProxy );
|
||||
this.foreignKeyType = foreignKeyType;
|
||||
this.propertyName = propertyName;
|
||||
this.entityName = entityName;
|
||||
this.constrained = constrained;
|
||||
}
|
||||
|
||||
public OneToOneType(OneToOneType original, String superTypeEntityName) {
|
||||
|
@ -68,6 +89,7 @@ public class OneToOneType extends EntityType {
|
|||
this.foreignKeyType = original.foreignKeyType;
|
||||
this.propertyName = original.propertyName;
|
||||
this.entityName = original.entityName;
|
||||
this.constrained = original.constrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,8 +177,8 @@ public class OneToOneType extends EntityType {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNullable() {
|
||||
return foreignKeyType==ForeignKeyDirection.TO_PARENT;
|
||||
public boolean isNullable() {
|
||||
return !constrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,9 +25,10 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|||
* @author Gavin King
|
||||
*/
|
||||
public class SpecialOneToOneType extends OneToOneType {
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #SpecialOneToOneType(org.hibernate.type.TypeFactory.TypeScope, String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String)} instead.
|
||||
* @deprecated Use {@link SpecialOneToOneType#SpecialOneToOneType(TypeFactory.TypeScope, String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String, boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SpecialOneToOneType(
|
||||
|
@ -41,7 +42,36 @@ public class SpecialOneToOneType extends OneToOneType {
|
|||
String propertyName) {
|
||||
this( scope, referencedEntityName, foreignKeyType, uniqueKeyPropertyName == null, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpecialOneToOneType#SpecialOneToOneType(TypeFactory.TypeScope, String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String, boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SpecialOneToOneType(
|
||||
TypeFactory.TypeScope scope,
|
||||
String referencedEntityName,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
boolean referenceToPrimaryKey,
|
||||
String uniqueKeyPropertyName,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName) {
|
||||
this (
|
||||
scope,
|
||||
referencedEntityName,
|
||||
foreignKeyType,
|
||||
referenceToPrimaryKey,
|
||||
uniqueKeyPropertyName,
|
||||
lazy,
|
||||
unwrapProxy,
|
||||
entityName,
|
||||
propertyName,
|
||||
foreignKeyType != ForeignKeyDirection.TO_PARENT
|
||||
);
|
||||
}
|
||||
|
||||
public SpecialOneToOneType(
|
||||
TypeFactory.TypeScope scope,
|
||||
String referencedEntityName,
|
||||
|
@ -51,7 +81,8 @@ public class SpecialOneToOneType extends OneToOneType {
|
|||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName) {
|
||||
String propertyName,
|
||||
boolean constrained) {
|
||||
super(
|
||||
scope,
|
||||
referencedEntityName,
|
||||
|
@ -61,7 +92,8 @@ public class SpecialOneToOneType extends OneToOneType {
|
|||
lazy,
|
||||
unwrapProxy,
|
||||
entityName,
|
||||
propertyName
|
||||
propertyName,
|
||||
constrained
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,11 @@ public final class TypeFactory implements Serializable {
|
|||
|
||||
// one-to-one type builders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link TypeFactory#oneToOne(String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String, boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public EntityType oneToOne(
|
||||
String persistentClass,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
|
@ -209,9 +214,39 @@ public final class TypeFactory implements Serializable {
|
|||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName) {
|
||||
return oneToOne( persistentClass, foreignKeyType, referenceToPrimaryKey, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName, foreignKeyType != ForeignKeyDirection.TO_PARENT );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link TypeFactory#specialOneToOne(String, ForeignKeyDirection, boolean, String, boolean, boolean, String, String, boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public EntityType specialOneToOne(
|
||||
String persistentClass,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
boolean referenceToPrimaryKey,
|
||||
String uniqueKeyPropertyName,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName) {
|
||||
return specialOneToOne( persistentClass, foreignKeyType, referenceToPrimaryKey, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName, foreignKeyType != ForeignKeyDirection.TO_PARENT );
|
||||
}
|
||||
|
||||
public EntityType oneToOne(
|
||||
String persistentClass,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
boolean referenceToPrimaryKey,
|
||||
String uniqueKeyPropertyName,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName,
|
||||
boolean constrained) {
|
||||
return new OneToOneType(
|
||||
typeScope, persistentClass, foreignKeyType, referenceToPrimaryKey,
|
||||
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName
|
||||
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName, constrained
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -223,10 +258,12 @@ public final class TypeFactory implements Serializable {
|
|||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String entityName,
|
||||
String propertyName) {
|
||||
String propertyName,
|
||||
boolean constrained) {
|
||||
return new SpecialOneToOneType(
|
||||
typeScope, persistentClass, foreignKeyType, referenceToPrimaryKey,
|
||||
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName
|
||||
uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName,
|
||||
constrained
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue