mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 08:35:13 +00:00
HHH-16759 - ComponentType.isMutable should return false when component is record; replace method(s) should return original for immutable classes
This commit is contained in:
parent
86ed7abd97
commit
3e8056de8e
@ -26,6 +26,7 @@
|
|||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.generator.Generator;
|
import org.hibernate.generator.Generator;
|
||||||
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.mapping.Component;
|
import org.hibernate.mapping.Component;
|
||||||
@ -49,6 +50,7 @@
|
|||||||
*/
|
*/
|
||||||
public class ComponentType extends AbstractType implements CompositeTypeImplementor, ProcedureParameterExtractionAware {
|
public class ComponentType extends AbstractType implements CompositeTypeImplementor, ProcedureParameterExtractionAware {
|
||||||
private final Class<?> componentClass;
|
private final Class<?> componentClass;
|
||||||
|
private final boolean mutable;
|
||||||
|
|
||||||
private final String[] propertyNames;
|
private final String[] propertyNames;
|
||||||
private final Type[] propertyTypes;
|
private final Type[] propertyTypes;
|
||||||
@ -112,6 +114,7 @@ public ComponentType(Component component, int[] originalPropertyOrder, MetadataB
|
|||||||
else {
|
else {
|
||||||
this.compositeUserType = null;
|
this.compositeUserType = null;
|
||||||
}
|
}
|
||||||
|
this.mutable = !ReflectHelper.isRecord( componentClass ) && ( compositeUserType == null || compositeUserType.isMutable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAggregate() {
|
private boolean isAggregate() {
|
||||||
@ -527,6 +530,9 @@ public Object replace(
|
|||||||
Object owner,
|
Object owner,
|
||||||
Map<Object, Object> copyCache) {
|
Map<Object, Object> copyCache) {
|
||||||
|
|
||||||
|
if ( !isMutable() ) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
if ( original == null ) {
|
if ( original == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -575,6 +581,9 @@ public Object replace(
|
|||||||
Map<Object, Object> copyCache,
|
Map<Object, Object> copyCache,
|
||||||
ForeignKeyDirection foreignKeyDirection) {
|
ForeignKeyDirection foreignKeyDirection) {
|
||||||
|
|
||||||
|
if ( !isMutable() ) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
if ( original == null ) {
|
if ( original == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -623,7 +632,7 @@ public CascadeStyle getCascadeStyle(int i) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
return compositeUserType == null || compositeUserType.isMutable();
|
return mutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user