mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-27 14:30:16 +00:00
HHH-17290 Embeddable with a primitive field cannot be set to null
This commit is contained in:
parent
583015100b
commit
e5b2298b76
@ -881,8 +881,7 @@ private static AnnotatedColumns buildImplicitColumn(
|
|||||||
// }
|
// }
|
||||||
//not following the spec but more clean
|
//not following the spec but more clean
|
||||||
if ( nullability != Nullability.FORCED_NULL
|
if ( nullability != Nullability.FORCED_NULL
|
||||||
&& inferredData.getClassOrElement().isPrimitive()
|
&& !PropertyBinder.isOptional( inferredData.getProperty(), propertyHolder ) ) {
|
||||||
&& !inferredData.getProperty().isArray() ) {
|
|
||||||
column.setNullable( false );
|
column.setNullable( false );
|
||||||
}
|
}
|
||||||
final String propertyName = inferredData.getPropertyName();
|
final String propertyName = inferredData.getPropertyName();
|
||||||
|
@ -451,7 +451,7 @@ private void handleMutability(Property property) {
|
|||||||
|
|
||||||
private void handleOptional(Property property) {
|
private void handleOptional(Property property) {
|
||||||
if ( this.property != null ) {
|
if ( this.property != null ) {
|
||||||
property.setOptional( !isId && isOptional( this.property ) );
|
property.setOptional( !isId && isOptional( this.property, this.holder ) );
|
||||||
if ( property.isOptional() ) {
|
if ( property.isOptional() ) {
|
||||||
final OptionalDeterminationSecondPass secondPass = persistentClasses -> {
|
final OptionalDeterminationSecondPass secondPass = persistentClasses -> {
|
||||||
// Defer determining whether a property and its columns are nullable,
|
// Defer determining whether a property and its columns are nullable,
|
||||||
@ -1200,10 +1200,12 @@ private static boolean isExplicitlyOptional(XProperty property) {
|
|||||||
* Should this property be considered optional, taking into
|
* Should this property be considered optional, taking into
|
||||||
* account whether it is primitive?
|
* account whether it is primitive?
|
||||||
*/
|
*/
|
||||||
private static boolean isOptional(XProperty property) {
|
public static boolean isOptional(XProperty property, PropertyHolder propertyHolder) {
|
||||||
return property.isAnnotationPresent( Basic.class )
|
return property.isAnnotationPresent( Basic.class )
|
||||||
? property.getAnnotation( Basic.class ).optional()
|
? property.getAnnotation( Basic.class ).optional()
|
||||||
: property.isArray() || !property.getClassOrElementClass().isPrimitive();
|
: property.isArray()
|
||||||
|
|| propertyHolder != null && propertyHolder.isComponent()
|
||||||
|
|| !property.getClassOrElementClass().isPrimitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLazy(XProperty property) {
|
private static boolean isLazy(XProperty property) {
|
||||||
|
@ -533,7 +533,7 @@ public Object replace(
|
|||||||
Object owner,
|
Object owner,
|
||||||
Map<Object, Object> copyCache) {
|
Map<Object, Object> copyCache) {
|
||||||
|
|
||||||
if ( original == null && target == null ) {
|
if ( original == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( compositeUserType != null ) {
|
if ( compositeUserType != null ) {
|
||||||
@ -570,7 +570,7 @@ public Object replace(
|
|||||||
Map<Object, Object> copyCache,
|
Map<Object, Object> copyCache,
|
||||||
ForeignKeyDirection foreignKeyDirection) {
|
ForeignKeyDirection foreignKeyDirection) {
|
||||||
|
|
||||||
if ( original == null && target == null ) {
|
if ( original == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( compositeUserType != null ) {
|
if ( compositeUserType != null ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user