Introduce `VirtualIdEmbeddable` and `IdClassEmbeddable` + instantiators
- Clean up Component Type, removing as many calls to its tuplizer as possible atm - Clean up ManagedMappingType, EntityPersister, etc - mainly work around getting and setting value(s) Still need to - integrate embedded forms. `VirtualIdEmbeddable` does not really need it as it can use the id-mapping itself as the embedded form. But `IdClassEmbedded` should really be integrated - integrate `VirtualKeyEmbeddable` and `VirtualKeyEmbedded` for use as inverse composite fks - share `#finishInit` handling for `EmbeddableMappingType`, `VirtualIdEmbeddable` and `IdClassEmbeddable` - ability to use the containing composite owner as the parent of a composite (legacy behavior is to always use the "first" entity - clean up ComponentType, esp wrt its use of ComponentTuplizer
This commit is contained in:
parent
eb5afb0427
commit
b23c2f48c1
|
@ -133,7 +133,7 @@ public class PersistentArrayHolder<E> extends AbstractPersistentCollection<E> {
|
||||||
public void initializeEmptyCollection(CollectionPersister persister) {
|
public void initializeEmptyCollection(CollectionPersister persister) {
|
||||||
assert array == null;
|
assert array == null;
|
||||||
array = Array.newInstance( persister.getElementClass(), 0 );
|
array = Array.newInstance( persister.getElementClass(), 0 );
|
||||||
persister.getAttributeMapping().getPropertyAccess().getSetter().set( getOwner(), array, getSession().getFactory() );
|
persister.getAttributeMapping().getPropertyAccess().getSetter().set( getOwner(), array );
|
||||||
endRead();
|
endRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public class PersistentArrayHolder<E> extends AbstractPersistentCollection<E> {
|
||||||
Array.set( array, i, loadingState.get( i ) );
|
Array.set( array, i, loadingState.get( i ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attributeMapping.getPropertyAccess().getSetter().set( getOwner(), array, getSession().getFactory() );
|
attributeMapping.getPropertyAccess().getSetter().set( getOwner(), array );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class DefaultLoadEventListener implements LoadEventListener {
|
||||||
final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
|
final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
|
||||||
|
|
||||||
final Object dependent = dependentIdType.instantiate();
|
final Object dependent = dependentIdType.instantiate();
|
||||||
dependentIdType.getPartMappingType().setPropertyValues(
|
dependentIdType.getPartMappingType().setValues(
|
||||||
dependent,
|
dependent,
|
||||||
new Object[] { parent }
|
new Object[] { parent }
|
||||||
);
|
);
|
||||||
|
|
|
@ -515,7 +515,7 @@ public class Component extends SimpleValue implements MetaAttributable {
|
||||||
@Override
|
@Override
|
||||||
public void execute(SharedSessionContractImplementor session, Object incomingObject, Object injectionContext) {
|
public void execute(SharedSessionContractImplementor session, Object incomingObject, Object injectionContext) {
|
||||||
final Object generatedValue = subGenerator.generate( session, incomingObject );
|
final Object generatedValue = subGenerator.generate( session, incomingObject );
|
||||||
injector.set( injectionContext, generatedValue, session.getFactory() );
|
injector.set( injectionContext, generatedValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,8 @@ import java.lang.reflect.ParameterizedType;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
|
import org.hibernate.PropertyNotFoundException;
|
||||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||||
import org.hibernate.internal.HEMLogging;
|
import org.hibernate.internal.HEMLogging;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
|
@ -26,6 +28,8 @@ import org.hibernate.mapping.Value;
|
||||||
import org.hibernate.metamodel.AttributeClassification;
|
import org.hibernate.metamodel.AttributeClassification;
|
||||||
import org.hibernate.metamodel.UnsupportedMappingException;
|
import org.hibernate.metamodel.UnsupportedMappingException;
|
||||||
import org.hibernate.metamodel.RepresentationMode;
|
import org.hibernate.metamodel.RepresentationMode;
|
||||||
|
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||||
|
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||||
import org.hibernate.metamodel.model.domain.AbstractIdentifiableType;
|
import org.hibernate.metamodel.model.domain.AbstractIdentifiableType;
|
||||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||||
|
@ -608,23 +612,31 @@ public class AttributeFactory {
|
||||||
|
|
||||||
|
|
||||||
private static final MemberResolver virtualIdentifierMemberResolver = (attributeContext, metadataContext) -> {
|
private static final MemberResolver virtualIdentifierMemberResolver = (attributeContext, metadataContext) -> {
|
||||||
final AbstractIdentifiableType identifiableType = (AbstractIdentifiableType) attributeContext.getOwnerType();
|
final AbstractIdentifiableType<?> identifiableType = (AbstractIdentifiableType<?>) attributeContext.getOwnerType();
|
||||||
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType, metadataContext );
|
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType, metadataContext );
|
||||||
if ( !entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
if ( !entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
||||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||||
}
|
}
|
||||||
|
|
||||||
org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
|
org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
|
||||||
if ( !(type instanceof EmbeddedComponentType) ) {
|
if ( !(type instanceof EmbeddedComponentType) ) {
|
||||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||||
}
|
}
|
||||||
|
|
||||||
final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
|
|
||||||
final String attributeName = attributeContext.getPropertyMapping().getName();
|
final String attributeName = attributeContext.getPropertyMapping().getName();
|
||||||
|
final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
|
||||||
|
final EmbeddableValuedModelPart embeddedPart = ( (CompositeTypeImplementor) componentType ).getMappingModelPart();
|
||||||
|
assert embeddedPart != null;
|
||||||
|
final EmbeddableMappingType embeddable = embeddedPart.getEmbeddableTypeDescriptor();
|
||||||
|
final AttributeMapping attributeMapping = embeddable.findAttributeMapping( attributeName );
|
||||||
|
if ( attributeMapping == null ) {
|
||||||
|
throw new PropertyNotFoundException(
|
||||||
|
"Unable to locate property named " + attributeName + " on " + embeddable.getJavaTypeDescriptor().getJavaTypeClass().getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final Getter getter = componentType.getComponentTuplizer()
|
final Getter getter = attributeMapping.getPropertyAccess().getGetter();
|
||||||
.getGetter( componentType.getPropertyIndex( attributeName ) );
|
return getter instanceof PropertyAccessMapImpl.GetterImpl
|
||||||
|
|
||||||
return PropertyAccessMapImpl.GetterImpl.class.isInstance( getter )
|
|
||||||
? new MapMember( attributeName, attributeContext.getPropertyMapping().getType().getReturnedClass() )
|
? new MapMember( attributeName, attributeContext.getPropertyMapping().getType().getReturnedClass() )
|
||||||
: getter.getMember();
|
: getter.getMember();
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class EmbeddableInstantiatorDynamicMap
|
||||||
|
|
||||||
if ( valuesAccess != null ) {
|
if ( valuesAccess != null ) {
|
||||||
final EmbeddableMappingType mappingType = runtimeDescriptorAccess.get();
|
final EmbeddableMappingType mappingType = runtimeDescriptorAccess.get();
|
||||||
mappingType.setPropertyValues( dataMap, valuesAccess.get() );
|
mappingType.setValues( dataMap, valuesAccess.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataMap;
|
return dataMap;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EmbeddableInstantiatorPojoOptimized extends AbstractPojoInstantiato
|
||||||
public Object instantiate(Supplier<Object[]> valuesAccess, SessionFactoryImplementor sessionFactory) {
|
public Object instantiate(Supplier<Object[]> valuesAccess, SessionFactoryImplementor sessionFactory) {
|
||||||
final Object embeddable = instantiationOptimizer.newInstance();
|
final Object embeddable = instantiationOptimizer.newInstance();
|
||||||
final EmbeddableMappingType embeddableMapping = embeddableMappingAccess.get();
|
final EmbeddableMappingType embeddableMapping = embeddableMappingAccess.get();
|
||||||
embeddableMapping.setPropertyValues( embeddable, valuesAccess.get() );
|
embeddableMapping.setValues( embeddable, valuesAccess.get() );
|
||||||
return embeddable;
|
return embeddable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class EmbeddableInstantiatorPojoStandard extends AbstractPojoInstantiator
|
||||||
// A possible alternative could be to initialize the resolved values for primitive fields to their default value,
|
// A possible alternative could be to initialize the resolved values for primitive fields to their default value,
|
||||||
// but that might cause unexpected outcomes for Hibernate 5 users that use createEmptyCompositesEnabled when updating.
|
// but that might cause unexpected outcomes for Hibernate 5 users that use createEmptyCompositesEnabled when updating.
|
||||||
// You can see the need for this by running EmptyCompositeEquivalentToNullTest
|
// You can see the need for this by running EmptyCompositeEquivalentToNullTest
|
||||||
embeddableMappingAccess.get().setPropertyValues( instance, valuesAccess.get() );
|
embeddableMappingAccess.get().setValues( instance, valuesAccess.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -39,23 +39,12 @@ public interface AttributeMapping extends ModelPart, ValueMapping, Fetchable, Pr
|
||||||
/**
|
/**
|
||||||
* Convenient access to getting the value for this attribute from the "owner"
|
* Convenient access to getting the value for this attribute from the "owner"
|
||||||
*/
|
*/
|
||||||
default Object getValue(Object container, SharedSessionContractImplementor session) {
|
default Object getValue(Object container) {
|
||||||
return getValue( container, session.getSessionFactory() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenient access to getting the value for this attribute from the "owner"
|
|
||||||
*/
|
|
||||||
default Object getValue(Object container, SessionFactoryImplementor sessionFactory) {
|
|
||||||
return getPropertyAccess().getGetter().get( container );
|
return getPropertyAccess().getGetter().get( container );
|
||||||
}
|
}
|
||||||
|
|
||||||
default void setValue(Object container, Object value, SharedSessionContractImplementor session) {
|
default void setValue(Object container, Object value) {
|
||||||
setValue( container, value, session.getSessionFactory() );
|
getPropertyAccess().getSetter().set( container, value );
|
||||||
}
|
|
||||||
|
|
||||||
default void setValue(Object container, Object value, SessionFactoryImplementor sessionFactory) {
|
|
||||||
getPropertyAccess().getSetter().set( container, value, sessionFactory );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,9 +64,17 @@ public interface ManagedMappingType extends MappingType, FetchableContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] getPropertyValues(Object compositeInstance);
|
Object[] getValues(Object instance);
|
||||||
|
|
||||||
void setPropertyValues(Object compositeInstance, Object[] resolvedValues);
|
default Object getValue(Object instance, int position) {
|
||||||
|
return getAttributeMapping( position ).getValue( instance );
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValues(Object instance, Object[] resolvedValues);
|
||||||
|
|
||||||
|
default void setValue(Object instance, int position, Object value) {
|
||||||
|
getAttributeMapping( position ).setValue( instance, value );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo (6.0) : consider dropping this in favor of a form passing the ManagedMappingType
|
* @todo (6.0) : consider dropping this in favor of a form passing the ManagedMappingType
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
*/
|
||||||
|
package org.hibernate.metamodel.mapping.internal;
|
||||||
|
|
||||||
|
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
|
import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl;
|
||||||
|
import org.hibernate.property.access.spi.Getter;
|
||||||
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base support for EmbeddableMappingType implementations
|
||||||
|
*/
|
||||||
|
public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType {
|
||||||
|
protected final SessionFactoryImplementor sessionFactory;
|
||||||
|
|
||||||
|
public AbstractEmbeddableMapping(MappingModelCreationProcess creationProcess) {
|
||||||
|
this( creationProcess.getCreationContext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractEmbeddableMapping(RuntimeModelCreationContext creationContext) {
|
||||||
|
this( creationContext.getSessionFactory() );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractEmbeddableMapping(SessionFactoryImplementor sessionFactory) {
|
||||||
|
this.sessionFactory = sessionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavaType<?> getMappedJavaTypeDescriptor() {
|
||||||
|
return getRepresentationStrategy().getMappedJavaTypeDescriptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getValues(Object compositeInstance) {
|
||||||
|
if ( compositeInstance == PropertyAccessStrategyBackRefImpl.UNKNOWN ) {
|
||||||
|
return new Object[getNumberOfAttributeMappings()];
|
||||||
|
}
|
||||||
|
|
||||||
|
final ReflectionOptimizer optimizer = getRepresentationStrategy().getReflectionOptimizer();
|
||||||
|
if ( optimizer != null && optimizer.getAccessOptimizer() != null ) {
|
||||||
|
return optimizer.getAccessOptimizer().getPropertyValues( compositeInstance );
|
||||||
|
}
|
||||||
|
|
||||||
|
final Object[] results = new Object[getNumberOfAttributeMappings()];
|
||||||
|
forEachAttributeMapping( (position, attribute) -> {
|
||||||
|
final Getter getter = attribute.getAttributeMetadataAccess()
|
||||||
|
.resolveAttributeMetadata( null )
|
||||||
|
.getPropertyAccess()
|
||||||
|
.getGetter();
|
||||||
|
results[position] = getter.get( compositeInstance );
|
||||||
|
} );
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValues(Object component, Object[] values) {
|
||||||
|
final ReflectionOptimizer optimizer = getRepresentationStrategy().getReflectionOptimizer();
|
||||||
|
if ( optimizer != null && optimizer.getAccessOptimizer() != null ) {
|
||||||
|
optimizer.getAccessOptimizer().setPropertyValues( component, values );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
forEachAttributeMapping( (position, attribute) -> {
|
||||||
|
attribute.getPropertyAccess().getSetter().set( component, values[position] );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,7 +127,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||||
propertyAccess.getSetter().set( entity, id, session.getFactory() );
|
propertyAccess.getSetter().set( entity, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.function.Function;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
import org.hibernate.SharedSessionContract;
|
import org.hibernate.SharedSessionContract;
|
||||||
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.FetchTiming;
|
import org.hibernate.engine.FetchTiming;
|
||||||
|
@ -50,14 +49,12 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
||||||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||||
import org.hibernate.metamodel.mapping.SelectableMappings;
|
import org.hibernate.metamodel.mapping.SelectableMappings;
|
||||||
import org.hibernate.metamodel.mapping.StateArrayContributorMapping;
|
|
||||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadata;
|
import org.hibernate.metamodel.mapping.StateArrayContributorMetadata;
|
||||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||||
import org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy;
|
import org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy;
|
||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
|
@ -81,9 +78,12 @@ import org.hibernate.type.spi.CompositeTypeImplementor;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* Describes a "normal" embeddable.
|
||||||
|
*
|
||||||
|
* NOTE: At the moment, this class is used to describe some non-normal cases: mainly
|
||||||
|
* composite fks
|
||||||
*/
|
*/
|
||||||
public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, SelectableMappings {
|
public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping implements SelectableMappings {
|
||||||
|
|
||||||
public static EmbeddableMappingTypeImpl from(
|
public static EmbeddableMappingTypeImpl from(
|
||||||
Component bootDescriptor,
|
Component bootDescriptor,
|
||||||
|
@ -150,8 +150,6 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
||||||
private final JavaType<?> embeddableJtd;
|
private final JavaType<?> embeddableJtd;
|
||||||
private final EmbeddableRepresentationStrategy representationStrategy;
|
private final EmbeddableRepresentationStrategy representationStrategy;
|
||||||
|
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
|
||||||
|
|
||||||
private final List<AttributeMapping> attributeMappings = new ArrayList<>();
|
private final List<AttributeMapping> attributeMappings = new ArrayList<>();
|
||||||
private SelectableMappings selectableMappings;
|
private SelectableMappings selectableMappings;
|
||||||
|
|
||||||
|
@ -163,14 +161,13 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
||||||
Component bootDescriptor,
|
Component bootDescriptor,
|
||||||
Function<EmbeddableMappingType, EmbeddableValuedModelPart> embeddedPartBuilder,
|
Function<EmbeddableMappingType, EmbeddableValuedModelPart> embeddedPartBuilder,
|
||||||
RuntimeModelCreationContext creationContext) {
|
RuntimeModelCreationContext creationContext) {
|
||||||
|
super( creationContext );
|
||||||
this.representationStrategy = creationContext
|
this.representationStrategy = creationContext
|
||||||
.getBootstrapContext()
|
.getBootstrapContext()
|
||||||
.getRepresentationStrategySelector()
|
.getRepresentationStrategySelector()
|
||||||
.resolveStrategy( bootDescriptor, () -> this, creationContext );
|
.resolveStrategy( bootDescriptor, () -> this, creationContext );
|
||||||
|
|
||||||
this.embeddableJtd = representationStrategy.getMappedJavaTypeDescriptor();
|
this.embeddableJtd = representationStrategy.getMappedJavaTypeDescriptor();
|
||||||
this.sessionFactory = creationContext.getSessionFactory();
|
|
||||||
|
|
||||||
this.valueMapping = embeddedPartBuilder.apply( this );
|
this.valueMapping = embeddedPartBuilder.apply( this );
|
||||||
|
|
||||||
final ConfigurationService cs = sessionFactory.getServiceRegistry()
|
final ConfigurationService cs = sessionFactory.getServiceRegistry()
|
||||||
|
@ -190,9 +187,10 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
||||||
SelectableMappings selectableMappings,
|
SelectableMappings selectableMappings,
|
||||||
EmbeddableMappingType inverseMappingType,
|
EmbeddableMappingType inverseMappingType,
|
||||||
MappingModelCreationProcess creationProcess) {
|
MappingModelCreationProcess creationProcess) {
|
||||||
|
super( creationProcess );
|
||||||
|
|
||||||
this.embeddableJtd = inverseMappingType.getJavaTypeDescriptor();
|
this.embeddableJtd = inverseMappingType.getJavaTypeDescriptor();
|
||||||
this.representationStrategy = inverseMappingType.getRepresentationStrategy();
|
this.representationStrategy = inverseMappingType.getRepresentationStrategy();
|
||||||
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
|
||||||
this.valueMapping = valueMapping;
|
this.valueMapping = valueMapping;
|
||||||
this.createEmptyCompositesEnabled = inverseMappingType.isCreateEmptyCompositesEnabled();
|
this.createEmptyCompositesEnabled = inverseMappingType.isCreateEmptyCompositesEnabled();
|
||||||
this.selectableMappings = selectableMappings;
|
this.selectableMappings = selectableMappings;
|
||||||
|
@ -787,35 +785,6 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
||||||
visitAttributeMappings( consumer );
|
visitAttributeMappings( consumer );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getPropertyValues(Object compositeInstance) {
|
|
||||||
final Object[] results = new Object[attributeMappings.size()];
|
|
||||||
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
|
||||||
final StateArrayContributorMapping attr = (StateArrayContributorMapping) attributeMappings.get( i );
|
|
||||||
final Getter getter = attr.getAttributeMetadataAccess()
|
|
||||||
.resolveAttributeMetadata( null )
|
|
||||||
.getPropertyAccess()
|
|
||||||
.getGetter();
|
|
||||||
results[ attr.getStateArrayPosition() ] = getter.get( compositeInstance );
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPropertyValues(Object compositeInstance, Object[] resolvedValues) {
|
|
||||||
final ReflectionOptimizer reflectionOptimizer = representationStrategy.getReflectionOptimizer();
|
|
||||||
if ( reflectionOptimizer != null ) {
|
|
||||||
final ReflectionOptimizer.AccessOptimizer accessOptimizer = reflectionOptimizer.getAccessOptimizer();
|
|
||||||
if ( accessOptimizer != null ) {
|
|
||||||
accessOptimizer.setPropertyValues( compositeInstance, resolvedValues );
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
|
||||||
final AttributeMapping attributeMapping = attributeMappings.get( i );
|
|
||||||
attributeMapping.setValue( compositeInstance, resolvedValues[i], sessionFactory );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCreateEmptyCompositesEnabled() {
|
public boolean isCreateEmptyCompositesEnabled() {
|
||||||
return createEmptyCompositesEnabled;
|
return createEmptyCompositesEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||||
propertyAccess.getSetter().set( entity, id, session.getFactory() );
|
propertyAccess.getSetter().set( entity, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -185,7 +185,7 @@ public class GeneratedValuesProcessor {
|
||||||
.resolveAttributeMetadata( entityDescriptor )
|
.resolveAttributeMetadata( entityDescriptor )
|
||||||
.getPropertyAccess()
|
.getPropertyAccess()
|
||||||
.getSetter()
|
.getSetter()
|
||||||
.set( entity, generatedValue, sessionFactory );
|
.set( entity, generatedValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,10 +78,9 @@ import static org.hibernate.internal.util.collections.CollectionHelper.arrayList
|
||||||
import static org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.getStateArrayContributorMetadataAccess;
|
import static org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.getStateArrayContributorMetadataAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmbeddableMappingType implementation describing an
|
* EmbeddableMappingType implementation describing an {@link jakarta.persistence.IdClass}
|
||||||
* {@link jakarta.persistence.IdClass}
|
|
||||||
*/
|
*/
|
||||||
public class IdClassEmbeddable implements IdentifierValueMapper {
|
public class IdClassEmbeddable extends AbstractEmbeddableMapping implements IdentifierValueMapper {
|
||||||
private final NavigableRole navigableRole;
|
private final NavigableRole navigableRole;
|
||||||
private final NonAggregatedIdentifierMapping idMapping;
|
private final NonAggregatedIdentifierMapping idMapping;
|
||||||
private final VirtualIdEmbeddable virtualIdEmbeddable;
|
private final VirtualIdEmbeddable virtualIdEmbeddable;
|
||||||
|
@ -93,8 +92,6 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||||
private final List<SingularAttributeMapping> attributeMappings;
|
private final List<SingularAttributeMapping> attributeMappings;
|
||||||
private SelectableMappings selectableMappings;
|
private SelectableMappings selectableMappings;
|
||||||
|
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
|
||||||
|
|
||||||
public IdClassEmbeddable(
|
public IdClassEmbeddable(
|
||||||
Component idClassSource,
|
Component idClassSource,
|
||||||
RootClass bootEntityDescriptor,
|
RootClass bootEntityDescriptor,
|
||||||
|
@ -104,7 +101,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||||
String[] idColumns,
|
String[] idColumns,
|
||||||
VirtualIdEmbeddable virtualIdEmbeddable,
|
VirtualIdEmbeddable virtualIdEmbeddable,
|
||||||
MappingModelCreationProcess creationProcess) {
|
MappingModelCreationProcess creationProcess) {
|
||||||
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
super( creationProcess );
|
||||||
|
|
||||||
this.navigableRole = idMapping.getNavigableRole().append( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
|
this.navigableRole = idMapping.getNavigableRole().append( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
|
||||||
this.idMapping = idMapping;
|
this.idMapping = idMapping;
|
||||||
|
@ -231,7 +228,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPropertyValues( id, propertyValues );
|
setValues( id, propertyValues );
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +267,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
virtualIdEmbeddable.setPropertyValues( entity, propertyValues );
|
virtualIdEmbeddable.setValues( entity, propertyValues );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,24 +344,6 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getPropertyValues(Object composite) {
|
|
||||||
final Object[] values = new Object[ attributeMappings.size() ];
|
|
||||||
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
|
||||||
final SingularAttributeMapping attributeMapping = attributeMappings.get( i );
|
|
||||||
values[i] = attributeMapping.getPropertyAccess().getGetter().get( composite );
|
|
||||||
}
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPropertyValues(Object composite, Object[] resolvedValues) {
|
|
||||||
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
|
||||||
final SingularAttributeMapping attributeMapping = attributeMappings.get( i );
|
|
||||||
attributeMapping.getPropertyAccess().getSetter().set( composite, resolvedValues[i], sessionFactory );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNumberOfFetchables() {
|
public int getNumberOfFetchables() {
|
||||||
return getNumberOfAttributeMappings();
|
return getNumberOfAttributeMappings();
|
||||||
|
@ -394,7 +373,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||||
@Override
|
@Override
|
||||||
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
|
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
|
||||||
attributeMappings.forEach( (attribute) -> {
|
attributeMappings.forEach( (attribute) -> {
|
||||||
final Object attributeValue = attribute.getValue( domainValue, session );
|
final Object attributeValue = attribute.getValue( domainValue );
|
||||||
attribute.breakDownJdbcValues( attributeValue, valueConsumer, session );
|
attribute.breakDownJdbcValues( attributeValue, valueConsumer, session );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
||||||
propertyValues[i] = o;
|
propertyValues[i] = o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
identifierValueMapper.setPropertyValues( id, propertyValues );
|
identifierValueMapper.setValues( id, propertyValues );
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -325,7 +325,7 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
getEmbeddableTypeDescriptor().setPropertyValues( entity, propertyValues );
|
getEmbeddableTypeDescriptor().setValues( entity, propertyValues );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -62,7 +62,6 @@ import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
import org.hibernate.type.spi.CompositeTypeImplementor;
|
import org.hibernate.type.spi.CompositeTypeImplementor;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
@ -73,20 +72,14 @@ import static org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping.Ide
|
||||||
/**
|
/**
|
||||||
* Embeddable describing the virtual-id aspect of a non-aggregated composite id
|
* Embeddable describing the virtual-id aspect of a non-aggregated composite id
|
||||||
*/
|
*/
|
||||||
public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
public class VirtualIdEmbeddable extends AbstractEmbeddableMapping implements IdentifierValueMapper {
|
||||||
|
|
||||||
private final NavigableRole navigableRole;
|
private final NavigableRole navigableRole;
|
||||||
private final NonAggregatedIdentifierMapping idMapping;
|
private final NonAggregatedIdentifierMapping idMapping;
|
||||||
private final JavaType<?> javaType;
|
|
||||||
|
|
||||||
// private final VirtualIdEmbedded embedded;
|
|
||||||
private final VirtualIdRepresentationStrategy representationStrategy;
|
private final VirtualIdRepresentationStrategy representationStrategy;
|
||||||
|
|
||||||
private final List<SingularAttributeMapping> attributeMappings;
|
private final List<SingularAttributeMapping> attributeMappings;
|
||||||
private SelectableMappings selectableMappings;
|
private SelectableMappings selectableMappings;
|
||||||
|
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
|
||||||
|
|
||||||
public VirtualIdEmbeddable(
|
public VirtualIdEmbeddable(
|
||||||
Component virtualIdSource,
|
Component virtualIdSource,
|
||||||
NonAggregatedIdentifierMapping idMapping,
|
NonAggregatedIdentifierMapping idMapping,
|
||||||
|
@ -94,12 +87,10 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||||
String rootTableExpression,
|
String rootTableExpression,
|
||||||
String[] rootTableKeyColumnNames,
|
String[] rootTableKeyColumnNames,
|
||||||
MappingModelCreationProcess creationProcess) {
|
MappingModelCreationProcess creationProcess) {
|
||||||
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
super( creationProcess );
|
||||||
|
|
||||||
this.navigableRole = idMapping.getNavigableRole();
|
this.navigableRole = idMapping.getNavigableRole();
|
||||||
this.idMapping = idMapping;
|
this.idMapping = idMapping;
|
||||||
this.javaType = identifiedEntityMapping.getJavaTypeDescriptor();
|
|
||||||
|
|
||||||
this.representationStrategy = new VirtualIdRepresentationStrategy( this, identifiedEntityMapping );
|
this.representationStrategy = new VirtualIdRepresentationStrategy( this, identifiedEntityMapping );
|
||||||
|
|
||||||
final CompositeType compositeType = (CompositeType) virtualIdSource.getType();
|
final CompositeType compositeType = (CompositeType) virtualIdSource.getType();
|
||||||
|
@ -158,7 +149,7 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||||
@Override
|
@Override
|
||||||
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
||||||
return representationStrategy.getInstantiator().instantiate(
|
return representationStrategy.getInstantiator().instantiate(
|
||||||
() -> getPropertyValues( entity ),
|
() -> getValues( entity ),
|
||||||
session.getSessionFactory()
|
session.getSessionFactory()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +157,7 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||||
if ( entity != id ) {
|
if ( entity != id ) {
|
||||||
setPropertyValues( entity, getPropertyValues( id ) );
|
setValues( entity, getValues( id ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,11 +175,6 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||||
return idMapping.getPartName();
|
return idMapping.getPartName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaType<?> getMappedJavaTypeDescriptor() {
|
|
||||||
return javaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmbeddableValuedModelPart getEmbeddedValueMapping() {
|
public EmbeddableValuedModelPart getEmbeddedValueMapping() {
|
||||||
return getEmbeddedPart();
|
return getEmbeddedPart();
|
||||||
|
@ -200,21 +186,14 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] getPropertyValues(Object composite) {
|
public AttributeMapping findAttributeMapping(String name) {
|
||||||
final Object[] values = new Object[ attributeMappings.size() ];
|
|
||||||
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
||||||
final SingularAttributeMapping attributeMapping = attributeMappings.get( i );
|
final AttributeMapping attr = attributeMappings.get( i );
|
||||||
values[i] = attributeMapping.getPropertyAccess().getGetter().get( composite );
|
if ( name.equals( attr.getAttributeName() ) ) {
|
||||||
|
return attr;
|
||||||
}
|
}
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPropertyValues(Object composite, Object[] resolvedValues) {
|
|
||||||
for ( int i = 0; i < attributeMappings.size(); i++ ) {
|
|
||||||
final SingularAttributeMapping attributeMapping = attributeMappings.get( i );
|
|
||||||
attributeMapping.getPropertyAccess().getSetter().set( composite, resolvedValues[i], sessionFactory );
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -338,7 +317,7 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||||
@Override
|
@Override
|
||||||
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
|
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
|
||||||
attributeMappings.forEach( (attribute) -> {
|
attributeMappings.forEach( (attribute) -> {
|
||||||
final Object attributeValue = attribute.getValue( domainValue, session );
|
final Object attributeValue = attribute.getValue( domainValue );
|
||||||
attribute.breakDownJdbcValues( attributeValue, valueConsumer, session );
|
attribute.breakDownJdbcValues( attributeValue, valueConsumer, session );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class VirtualIdRepresentationStrategy implements EmbeddableRepresentation
|
||||||
if ( valuesAccess != null ) {
|
if ( valuesAccess != null ) {
|
||||||
final Object[] values = valuesAccess.get();
|
final Object[] values = valuesAccess.get();
|
||||||
if ( values != null ) {
|
if ( values != null ) {
|
||||||
virtualIdEmbeddable.setPropertyValues( instantiated, values );
|
virtualIdEmbeddable.setValues( instantiated, values );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return instantiated;
|
return instantiated;
|
||||||
|
|
|
@ -4890,6 +4890,7 @@ public abstract class AbstractEntityPersister
|
||||||
return proxyJavaTypeDescriptor != null ? proxyJavaTypeDescriptor.getJavaTypeClass() : javaTypeDescriptor.getJavaTypeClass();
|
return proxyJavaTypeDescriptor != null ? proxyJavaTypeDescriptor.getJavaTypeClass() : javaTypeDescriptor.getJavaTypeClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setPropertyValues(Object object, Object[] values) {
|
public void setPropertyValues(Object object, Object[] values) {
|
||||||
if ( accessOptimizer != null ) {
|
if ( accessOptimizer != null ) {
|
||||||
accessOptimizer.setPropertyValues( object, values );
|
accessOptimizer.setPropertyValues( object, values );
|
||||||
|
@ -4902,7 +4903,7 @@ public abstract class AbstractEntityPersister
|
||||||
final Object value = values[stateArrayPosition];
|
final Object value = values[stateArrayPosition];
|
||||||
if ( value != UNFETCHED_PROPERTY ) {
|
if ( value != UNFETCHED_PROPERTY ) {
|
||||||
final Setter setter = attribute.getPropertyAccess().getSetter();
|
final Setter setter = attribute.getPropertyAccess().getSetter();
|
||||||
setter.set( object, value, getFactory() );
|
setter.set( object, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -4915,7 +4916,7 @@ public abstract class AbstractEntityPersister
|
||||||
final Object value = values[stateArrayPosition];
|
final Object value = values[stateArrayPosition];
|
||||||
if ( value != UNFETCHED_PROPERTY ) {
|
if ( value != UNFETCHED_PROPERTY ) {
|
||||||
final Setter setter = attribute.getPropertyAccess().getSetter();
|
final Setter setter = attribute.getPropertyAccess().getSetter();
|
||||||
setter.set( object, value, getFactory() );
|
setter.set( object, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -4925,11 +4926,13 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setPropertyValue(Object object, int i, Object value) {
|
public void setPropertyValue(Object object, int i, Object value) {
|
||||||
final String propertyName = getPropertyNames()[i];
|
final String propertyName = getPropertyNames()[i];
|
||||||
setPropertyValue( object, propertyName, value );
|
setPropertyValue( object, propertyName, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object[] getPropertyValues(Object object) {
|
public Object[] getPropertyValues(Object object) {
|
||||||
if ( accessOptimizer != null ) {
|
if ( accessOptimizer != null ) {
|
||||||
return accessOptimizer.getPropertyValues( object );
|
return accessOptimizer.getPropertyValues( object );
|
||||||
|
@ -5103,8 +5106,7 @@ public abstract class AbstractEntityPersister
|
||||||
if ( versionMapping != null ) {
|
if ( versionMapping != null ) {
|
||||||
versionMapping.getVersionAttribute().getPropertyAccess().getSetter().set(
|
versionMapping.getVersionAttribute().getPropertyAccess().getSetter().set(
|
||||||
entity,
|
entity,
|
||||||
versionMapping.getUnsavedStrategy().getDefaultValue( currentVersion ),
|
versionMapping.getUnsavedStrategy().getDefaultValue( currentVersion )
|
||||||
getFactory()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5284,7 +5286,7 @@ public abstract class AbstractEntityPersister
|
||||||
public void setPropertyValue(Object object, String propertyName, Object value) {
|
public void setPropertyValue(Object object, String propertyName, Object value) {
|
||||||
final AttributeMapping attributeMapping = (AttributeMapping) findSubPart( propertyName, this );
|
final AttributeMapping attributeMapping = (AttributeMapping) findSubPart( propertyName, this );
|
||||||
final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( this );
|
final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( this );
|
||||||
attributeMetadata.getPropertyAccess().getSetter().set( object, value, getFactory() );
|
attributeMetadata.getPropertyAccess().getSetter().set( object, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTableId(String tableName, String[] tables) {
|
public static int getTableId(String tableName, String[] tables) {
|
||||||
|
|
|
@ -788,24 +788,48 @@ public interface EntityPersister
|
||||||
*/
|
*/
|
||||||
Class<?> getConcreteProxyClass();
|
Class<?> getConcreteProxyClass();
|
||||||
|
|
||||||
|
default void setValues(Object object, Object[] values) {
|
||||||
|
setPropertyValues( object, values );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the given values to the mapped properties of the given object
|
* Set the given values to the mapped properties of the given object
|
||||||
|
*
|
||||||
|
* @deprecated as of 6.0. Use {@link #setValues} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
void setPropertyValues(Object object, Object[] values);
|
void setPropertyValues(Object object, Object[] values);
|
||||||
|
|
||||||
|
default void setValue(Object object, int i, Object value) {
|
||||||
|
setPropertyValue( object, i, value );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of a particular property
|
* Set the value of a particular property
|
||||||
|
*
|
||||||
|
* @deprecated as of 6.0. Use {@link #setValue} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
void setPropertyValue(Object object, int i, Object value);
|
void setPropertyValue(Object object, int i, Object value);
|
||||||
|
|
||||||
/**
|
default Object[] getValues(Object object) {
|
||||||
* Return the (loaded) values of the mapped properties of the object (not including backrefs)
|
return getPropertyValues( object );
|
||||||
*/
|
}
|
||||||
Object[] getPropertyValues(Object object);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a particular property
|
* @deprecated as of 6.0. Use {@link #getValues} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
Object[] getPropertyValues(Object object);
|
||||||
|
|
||||||
|
default Object getValue(Object object, int i) {
|
||||||
|
return getValue( object, i );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated as of 6.0. Use {@link #getValue} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
Object getPropertyValue(Object object, int i) throws HibernateException;
|
Object getPropertyValue(Object object, int i) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
@ -61,7 +60,7 @@ public class ChainedPropertyAccessImpl implements PropertyAccess, Getter, Setter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
@ -106,7 +105,7 @@ public class PropertyAccessEmbeddedImpl implements PropertyAccess {
|
||||||
public static final SetterImpl INSTANCE = new SetterImpl();
|
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
@ -104,7 +103,7 @@ public class PropertyAccessMapImpl implements PropertyAccess {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
( (Map) target ).put( propertyName, value );
|
( (Map) target ).put( propertyName, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
@ -135,7 +134,7 @@ public class PropertyAccessStrategyBackRefImpl implements PropertyAccessStrategy
|
||||||
public static final SetterImpl INSTANCE = new SetterImpl();
|
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
// this page intentionally left blank :)
|
// this page intentionally left blank :)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
@ -118,7 +117,7 @@ public class PropertyAccessStrategyIndexBackRefImpl implements PropertyAccessStr
|
||||||
public static final SetterImpl INSTANCE = new SetterImpl();
|
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
// this page intentionally left blank :)
|
// this page intentionally left blank :)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
@ -107,7 +106,7 @@ public class PropertyAccessStrategyNoopImpl implements PropertyAccessStrategy {
|
||||||
public static final SetterImpl INSTANCE = new SetterImpl();
|
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,9 +36,8 @@ public class EnhancedSetterImpl extends SetterFieldImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
|
super.set( target, value );
|
||||||
super.set( target, value, factory );
|
|
||||||
|
|
||||||
// This sets the component relation for dirty tracking purposes
|
// This sets the component relation for dirty tracking purposes
|
||||||
if ( target instanceof CompositeOwner && value instanceof CompositeTracker ) {
|
if ( target instanceof CompositeOwner && value instanceof CompositeTracker ) {
|
||||||
|
|
|
@ -18,16 +18,8 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface Setter extends Serializable {
|
public interface Setter extends Serializable {
|
||||||
/**
|
|
||||||
* Set the property value from the given instance
|
void set(Object target, Object value);
|
||||||
*
|
|
||||||
* @param target The instance upon which to set the given value.
|
|
||||||
* @param value The value to be set on the target.
|
|
||||||
* @param factory The session factory from which this request originated.
|
|
||||||
*
|
|
||||||
* @throws org.hibernate.HibernateException
|
|
||||||
*/
|
|
||||||
void set(Object target, Object value, SessionFactoryImplementor factory);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional operation (may return {@code null})
|
* Optional operation (may return {@code null})
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SetterFieldImpl implements Setter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
try {
|
try {
|
||||||
field.set( target, value );
|
field.set( target, value );
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.hibernate.PropertyAccessException;
|
import org.hibernate.PropertyAccessException;
|
||||||
import org.hibernate.PropertySetterAccessException;
|
import org.hibernate.PropertySetterAccessException;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ public class SetterMethodImpl implements Setter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
public void set(Object target, Object value) {
|
||||||
try {
|
try {
|
||||||
setterMethod.invoke( target, value );
|
setterMethod.invoke( target, value );
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
final Initializer parentInitializer = processingState.resolveInitializer( navigablePath.getParent() );
|
final Initializer parentInitializer = processingState.resolveInitializer( navigablePath.getParent() );
|
||||||
if ( parentInitializer != this ) {
|
if ( parentInitializer != this ) {
|
||||||
( (FetchParentAccess) parentInitializer ).registerResolutionListener( (entity) -> {
|
( (FetchParentAccess) parentInitializer ).registerResolutionListener( (entity) -> {
|
||||||
representationEmbeddable.setPropertyValues( entity, rowState );
|
representationEmbeddable.setValues( entity, rowState );
|
||||||
stateInjected = true;
|
stateInjected = true;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( stateAllNull == FALSE && stateInjected != TRUE ) {
|
else if ( stateAllNull == FALSE && stateInjected != TRUE ) {
|
||||||
// todo (6.0) : i think this is still called for cases where
|
representationEmbeddable.setValues( compositeInstance, rowState );
|
||||||
// we have already done the "ctor injection"
|
|
||||||
representationEmbeddable.setPropertyValues( compositeInstance, rowState );
|
|
||||||
stateInjected = true;
|
stateInjected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,7 +333,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
compositeInstance
|
compositeInstance
|
||||||
);
|
);
|
||||||
|
|
||||||
parentInjectionAccess.getSetter().set( compositeInstance, parent, sessionFactory );
|
parentInjectionAccess.getSetter().set( compositeInstance, parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object determineParentInstance(RowProcessingState processingState) {
|
private Object determineParentInstance(RowProcessingState processingState) {
|
||||||
|
|
|
@ -75,14 +75,11 @@ public class AliasToBeanResultTransformer extends AliasedTupleSubsetResultTransf
|
||||||
|
|
||||||
for ( int i = 0; i < aliases.length; i++ ) {
|
for ( int i = 0; i < aliases.length; i++ ) {
|
||||||
if ( setters[i] != null ) {
|
if ( setters[i] != null ) {
|
||||||
setters[i].set( result, tuple[i], null );
|
setters[i].set( result, tuple[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( InstantiationException e ) {
|
catch ( InstantiationException | IllegalAccessException e ) {
|
||||||
throw new HibernateException( "Could not instantiate resultclass: " + resultClass.getName() );
|
|
||||||
}
|
|
||||||
catch ( IllegalAccessException e ) {
|
|
||||||
throw new HibernateException( "Could not instantiate resultclass: " + resultClass.getName() );
|
throw new HibernateException( "Could not instantiate resultclass: " + resultClass.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public abstract class AbstractComponentTuplizer implements ComponentTuplizer {
|
||||||
|
|
||||||
public void setPropertyValues(Object component, Object[] values) throws HibernateException {
|
public void setPropertyValues(Object component, Object[] values) throws HibernateException {
|
||||||
for ( int i = 0; i < propertySpan; i++ ) {
|
for ( int i = 0; i < propertySpan; i++ ) {
|
||||||
setters[i].set( component, values[i], null );
|
setters[i].set( component, values[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,6 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
return isKey;
|
return isKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentTuplizer getComponentTuplizer() {
|
|
||||||
return componentTuplizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(Mapping mapping) throws MappingException {
|
||||||
int span = 0;
|
int span = 0;
|
||||||
|
@ -382,11 +378,11 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
return getPropertyValue( component, i );
|
return getPropertyValue( component, i );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getPropertyValue(Object component, int i)
|
public Object getPropertyValue(Object component, int i) {
|
||||||
throws HibernateException {
|
|
||||||
if ( component == null ) {
|
if ( component == null ) {
|
||||||
component = new Object[propertySpan];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( component instanceof Object[] ) {
|
if ( component instanceof Object[] ) {
|
||||||
// A few calls to hashCode pass the property values already in an
|
// A few calls to hashCode pass the property values already in an
|
||||||
// Object[] (ex: QueryKey hash codes for cached queries).
|
// Object[] (ex: QueryKey hash codes for cached queries).
|
||||||
|
@ -395,7 +391,9 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
return ( (Object[]) component )[i];
|
return ( (Object[]) component )[i];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return componentTuplizer.getPropertyValue( component, i );
|
return mappingModelPart
|
||||||
|
.getEmbeddableTypeDescriptor()
|
||||||
|
.getValue( component, i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,9 +405,9 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
@Override
|
@Override
|
||||||
public Object[] getPropertyValues(Object component) {
|
public Object[] getPropertyValues(Object component) {
|
||||||
if (component == null) {
|
if (component == null) {
|
||||||
component = new Object[propertySpan];
|
return new Object[propertySpan];
|
||||||
}
|
}
|
||||||
if ( component instanceof Object[] ) {
|
else if ( component instanceof Object[] ) {
|
||||||
// A few calls to hashCode pass the property values already in an
|
// A few calls to hashCode pass the property values already in an
|
||||||
// Object[] (ex: QueryKey hash codes for cached queries).
|
// Object[] (ex: QueryKey hash codes for cached queries).
|
||||||
// It's easiest to just check for the condition here prior to
|
// It's easiest to just check for the condition here prior to
|
||||||
|
@ -417,14 +415,15 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
return (Object[]) component;
|
return (Object[]) component;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return componentTuplizer.getPropertyValues( component );
|
return mappingModelPart
|
||||||
|
.getEmbeddableTypeDescriptor()
|
||||||
|
.getValues( component );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPropertyValues(Object component, Object[] values)
|
public void setPropertyValues(Object component, Object[] values) {
|
||||||
throws HibernateException {
|
mappingModelPart.getEmbeddableTypeDescriptor().setValues( component, values );
|
||||||
componentTuplizer.setPropertyValues( component, values );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -486,7 +485,7 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
//equals()/hashCode() implementations
|
//equals()/hashCode() implementations
|
||||||
final PropertyAccess parentAccess = mappingModelPart().getParentInjectionAttributePropertyAccess();
|
final PropertyAccess parentAccess = mappingModelPart().getParentInjectionAttributePropertyAccess();
|
||||||
if ( parentAccess != null ) {
|
if ( parentAccess != null ) {
|
||||||
parentAccess.getSetter().set( result, parentAccess.getGetter().get( component ), factory );
|
parentAccess.getSetter().set( result, parentAccess.getGetter().get( component ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class PropertyAccessStrategyMapTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
final HashMap<String, String> map = new HashMap<>();
|
final HashMap<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
access.getSetter().set( map, value, null );
|
access.getSetter().set( map, value );
|
||||||
assertEquals( value, map.get( key ) );
|
assertEquals( value, map.get( key ) );
|
||||||
assertEquals( value, access.getGetter().get( map ) );
|
assertEquals( value, access.getGetter().get( map ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class GetterSetterSerializationTest {
|
||||||
|
|
||||||
final Setter setterClone = (Setter) ois.readObject();
|
final Setter setterClone = (Setter) ois.readObject();
|
||||||
final PK pkNew = new PK( 2L );
|
final PK pkNew = new PK( 2L );
|
||||||
setterClone.set( entity, pkNew, null );
|
setterClone.set( entity, pkNew );
|
||||||
|
|
||||||
assertSame( pkNew, getter.get( entity ) );
|
assertSame( pkNew, getter.get( entity ) );
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class GetterSetterSerializationTest {
|
||||||
|
|
||||||
final Setter setterClone = (Setter) ois.readObject();
|
final Setter setterClone = (Setter) ois.readObject();
|
||||||
final PK pkNew = new PK( 2L );
|
final PK pkNew = new PK( 2L );
|
||||||
setterClone.set( entity, pkNew, null );
|
setterClone.set( entity, pkNew );
|
||||||
|
|
||||||
assertSame( pkNew, getter.get( entity ) );
|
assertSame( pkNew, getter.get( entity ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,11 +138,11 @@ public class ComponentPropertyMapper extends AbstractPropertyMapper implements C
|
||||||
|
|
||||||
if ( isAllPropertiesNull( data ) ) {
|
if ( isAllPropertiesNull( data ) ) {
|
||||||
// single property, but default value need not be null, so we'll set it to null anyway
|
// single property, but default value need not be null, so we'll set it to null anyway
|
||||||
setter.set( obj, null, null );
|
setter.set( obj, null );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// set the component
|
// set the component
|
||||||
setter.set( obj, subObj, null );
|
setter.set( obj, subObj );
|
||||||
delegate.mapToEntityFromMap( enversService, subObj, data, primaryKey, versionsReader, revision );
|
delegate.mapToEntityFromMap( enversService, subObj, data, primaryKey, versionsReader, revision );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class SinglePropertyMapper extends AbstractPropertyMapper implements Simp
|
||||||
|
|
||||||
// We only set a null value if the field is not primitive. Otherwise, we leave it intact.
|
// We only set a null value if the field is not primitive. Otherwise, we leave it intact.
|
||||||
if ( value != null || !isPrimitive( setter, propertyData, obj.getClass() ) ) {
|
if ( value != null || !isPrimitive( setter, propertyData, obj.getClass() ) ) {
|
||||||
setter.set( obj, value, null );
|
setter.set( obj, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class EmbeddedIdMapper extends AbstractCompositeIdMapper implements Simpl
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ret ) {
|
if ( ret ) {
|
||||||
setter.set( obj, subObj, null );
|
setter.set( obj, subObj );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class SingleIdMapper extends AbstractIdMapper implements SimpleIdMapperBu
|
||||||
propertyData,
|
propertyData,
|
||||||
getServiceRegistry()
|
getServiceRegistry()
|
||||||
);
|
);
|
||||||
setter.set( obj, value, null );
|
setter.set( obj, value );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class SingleIdMapper extends AbstractIdMapper implements SimpleIdMapperBu
|
||||||
getServiceRegistry()
|
getServiceRegistry()
|
||||||
);
|
);
|
||||||
|
|
||||||
setter.set( objTo, getter.get( objFrom ), null );
|
setter.set( objTo, getter.get( objFrom ) );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,11 +95,11 @@ public class VirtualEntitySingleIdMapper extends SingleIdMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !value.getClass().equals( propertyData.getVirtualReturnClass() ) ) {
|
if ( !value.getClass().equals( propertyData.getVirtualReturnClass() ) ) {
|
||||||
setter.set( objTo, getAssociatedEntityIdMapper().mapToIdFromEntity( value ), null );
|
setter.set( objTo, getAssociatedEntityIdMapper().mapToIdFromEntity( value ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// This means we're setting the object
|
// This means we're setting the object
|
||||||
setter.set( objTo, value, null );
|
setter.set( objTo, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -135,10 +135,10 @@ public class VirtualEntitySingleIdMapper extends SingleIdMapper {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( paramClass != null && paramClass.equals( propertyData.getVirtualReturnClass() ) ) {
|
if ( paramClass != null && paramClass.equals( propertyData.getVirtualReturnClass() ) ) {
|
||||||
setter.set( obj, getAssociatedEntityIdMapper().mapToIdFromEntity( value ), null );
|
setter.set( obj, getAssociatedEntityIdMapper().mapToIdFromEntity( value ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setter.set( obj, value, null );
|
setter.set( obj, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -316,7 +316,7 @@ public abstract class AbstractCollectionMapper<T> extends AbstractPropertyMapper
|
||||||
enversService.getServiceRegistry()
|
enversService.getServiceRegistry()
|
||||||
);
|
);
|
||||||
|
|
||||||
setter.set( obj, collectionProxy, null );
|
setter.set( obj, collectionProxy );
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public abstract class AbstractToOneMapper extends AbstractPropertyMapper {
|
||||||
propertyData,
|
propertyData,
|
||||||
serviceRegistry
|
serviceRegistry
|
||||||
);
|
);
|
||||||
setter.set( targetObject, value, null );
|
setter.set( targetObject, value );
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class DefaultTrackingModifiedEntitiesRevisionInfoGenerator extends Defaul
|
||||||
Set<String> modifiedEntityNames = (Set<String>) modifiedEntityNamesGetter.get( revisionEntity );
|
Set<String> modifiedEntityNames = (Set<String>) modifiedEntityNamesGetter.get( revisionEntity );
|
||||||
if ( modifiedEntityNames == null ) {
|
if ( modifiedEntityNames == null ) {
|
||||||
modifiedEntityNames = new HashSet<>();
|
modifiedEntityNames = new HashSet<>();
|
||||||
modifiedEntityNamesSetter.set( revisionEntity, modifiedEntityNames, null );
|
modifiedEntityNamesSetter.set( revisionEntity, modifiedEntityNames );
|
||||||
}
|
}
|
||||||
modifiedEntityNames.add( entityName );
|
modifiedEntityNames.add( entityName );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class RevisionTimestampValueResolver {
|
||||||
|
|
||||||
public void resolveNow(Object object) {
|
public void resolveNow(Object object) {
|
||||||
if ( timestampData.isTimestampDate() ) {
|
if ( timestampData.isTimestampDate() ) {
|
||||||
revisionTimestampSetter.set( object, new Date(), null );
|
revisionTimestampSetter.set( object, new Date() );
|
||||||
}
|
}
|
||||||
else if ( timestampData.isTimestampLocalDateTime() ) {
|
else if ( timestampData.isTimestampLocalDateTime() ) {
|
||||||
revisionTimestampSetter.set(object, LocalDateTime.now(), null );
|
revisionTimestampSetter.set(object, LocalDateTime.now() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
revisionTimestampSetter.set( object, System.currentTimeMillis(), null );
|
revisionTimestampSetter.set( object, System.currentTimeMillis() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue