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) {
|
||||
assert array == null;
|
||||
array = Array.newInstance( persister.getElementClass(), 0 );
|
||||
persister.getAttributeMapping().getPropertyAccess().getSetter().set( getOwner(), array, getSession().getFactory() );
|
||||
persister.getAttributeMapping().getPropertyAccess().getSetter().set( getOwner(), array );
|
||||
endRead();
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class PersistentArrayHolder<E> extends AbstractPersistentCollection<E> {
|
|||
Array.set( array, i, loadingState.get( i ) );
|
||||
}
|
||||
}
|
||||
attributeMapping.getPropertyAccess().getSetter().set( getOwner(), array, getSession().getFactory() );
|
||||
attributeMapping.getPropertyAccess().getSetter().set( getOwner(), array );
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
|
|
|
@ -176,7 +176,7 @@ public class DefaultLoadEventListener implements LoadEventListener {
|
|||
final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
|
||||
|
||||
final Object dependent = dependentIdType.instantiate();
|
||||
dependentIdType.getPartMappingType().setPropertyValues(
|
||||
dependentIdType.getPartMappingType().setValues(
|
||||
dependent,
|
||||
new Object[] { parent }
|
||||
);
|
||||
|
|
|
@ -515,7 +515,7 @@ public class Component extends SimpleValue implements MetaAttributable {
|
|||
@Override
|
||||
public void execute(SharedSessionContractImplementor session, Object incomingObject, Object injectionContext) {
|
||||
final Object generatedValue = subGenerator.generate( session, incomingObject );
|
||||
injector.set( injectionContext, generatedValue, session.getFactory() );
|
||||
injector.set( injectionContext, generatedValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,8 @@ import java.lang.reflect.ParameterizedType;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.PropertyNotFoundException;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.HEMLogging;
|
||||
import org.hibernate.mapping.Collection;
|
||||
|
@ -26,6 +28,8 @@ import org.hibernate.mapping.Value;
|
|||
import org.hibernate.metamodel.AttributeClassification;
|
||||
import org.hibernate.metamodel.UnsupportedMappingException;
|
||||
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.model.domain.AbstractIdentifiableType;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
|
@ -608,23 +612,31 @@ public class AttributeFactory {
|
|||
|
||||
|
||||
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 );
|
||||
if ( !entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||
}
|
||||
|
||||
org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
|
||||
if ( !(type instanceof EmbeddedComponentType) ) {
|
||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||
}
|
||||
|
||||
final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
|
||||
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()
|
||||
.getGetter( componentType.getPropertyIndex( attributeName ) );
|
||||
|
||||
return PropertyAccessMapImpl.GetterImpl.class.isInstance( getter )
|
||||
final Getter getter = attributeMapping.getPropertyAccess().getGetter();
|
||||
return getter instanceof PropertyAccessMapImpl.GetterImpl
|
||||
? new MapMember( attributeName, attributeContext.getPropertyMapping().getType().getReturnedClass() )
|
||||
: getter.getMember();
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ public class EmbeddableInstantiatorDynamicMap
|
|||
|
||||
if ( valuesAccess != null ) {
|
||||
final EmbeddableMappingType mappingType = runtimeDescriptorAccess.get();
|
||||
mappingType.setPropertyValues( dataMap, valuesAccess.get() );
|
||||
mappingType.setValues( dataMap, valuesAccess.get() );
|
||||
}
|
||||
|
||||
return dataMap;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class EmbeddableInstantiatorPojoOptimized extends AbstractPojoInstantiato
|
|||
public Object instantiate(Supplier<Object[]> valuesAccess, SessionFactoryImplementor sessionFactory) {
|
||||
final Object embeddable = instantiationOptimizer.newInstance();
|
||||
final EmbeddableMappingType embeddableMapping = embeddableMappingAccess.get();
|
||||
embeddableMapping.setPropertyValues( embeddable, valuesAccess.get() );
|
||||
embeddableMapping.setValues( embeddable, valuesAccess.get() );
|
||||
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,
|
||||
// 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
|
||||
embeddableMappingAccess.get().setPropertyValues( instance, valuesAccess.get() );
|
||||
embeddableMappingAccess.get().setValues( instance, valuesAccess.get() );
|
||||
}
|
||||
|
||||
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"
|
||||
*/
|
||||
default Object getValue(Object container, SharedSessionContractImplementor session) {
|
||||
return getValue( container, session.getSessionFactory() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient access to getting the value for this attribute from the "owner"
|
||||
*/
|
||||
default Object getValue(Object container, SessionFactoryImplementor sessionFactory) {
|
||||
default Object getValue(Object container) {
|
||||
return getPropertyAccess().getGetter().get( container );
|
||||
}
|
||||
|
||||
default void setValue(Object container, Object value, SharedSessionContractImplementor session) {
|
||||
setValue( container, value, session.getSessionFactory() );
|
||||
}
|
||||
|
||||
default void setValue(Object container, Object value, SessionFactoryImplementor sessionFactory) {
|
||||
getPropertyAccess().getSetter().set( container, value, sessionFactory );
|
||||
default void setValue(Object container, Object value) {
|
||||
getPropertyAccess().getSetter().set( container, value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||
propertyAccess.getSetter().set( entity, id, session.getFactory() );
|
||||
propertyAccess.getSetter().set( entity, id );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.function.Function;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.SharedSessionContract;
|
||||
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
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.SelectableMapping;
|
||||
import org.hibernate.metamodel.mapping.SelectableMappings;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMapping;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadata;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
|
@ -81,9 +78,12 @@ import org.hibernate.type.spi.CompositeTypeImplementor;
|
|||
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(
|
||||
Component bootDescriptor,
|
||||
|
@ -150,8 +150,6 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
|||
private final JavaType<?> embeddableJtd;
|
||||
private final EmbeddableRepresentationStrategy representationStrategy;
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
|
||||
private final List<AttributeMapping> attributeMappings = new ArrayList<>();
|
||||
private SelectableMappings selectableMappings;
|
||||
|
||||
|
@ -163,14 +161,13 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
|||
Component bootDescriptor,
|
||||
Function<EmbeddableMappingType, EmbeddableValuedModelPart> embeddedPartBuilder,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
super( creationContext );
|
||||
this.representationStrategy = creationContext
|
||||
.getBootstrapContext()
|
||||
.getRepresentationStrategySelector()
|
||||
.resolveStrategy( bootDescriptor, () -> this, creationContext );
|
||||
|
||||
this.embeddableJtd = representationStrategy.getMappedJavaTypeDescriptor();
|
||||
this.sessionFactory = creationContext.getSessionFactory();
|
||||
|
||||
this.valueMapping = embeddedPartBuilder.apply( this );
|
||||
|
||||
final ConfigurationService cs = sessionFactory.getServiceRegistry()
|
||||
|
@ -190,9 +187,10 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
|||
SelectableMappings selectableMappings,
|
||||
EmbeddableMappingType inverseMappingType,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
super( creationProcess );
|
||||
|
||||
this.embeddableJtd = inverseMappingType.getJavaTypeDescriptor();
|
||||
this.representationStrategy = inverseMappingType.getRepresentationStrategy();
|
||||
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
this.valueMapping = valueMapping;
|
||||
this.createEmptyCompositesEnabled = inverseMappingType.isCreateEmptyCompositesEnabled();
|
||||
this.selectableMappings = selectableMappings;
|
||||
|
@ -787,35 +785,6 @@ public class EmbeddableMappingTypeImpl implements EmbeddableMappingType, Selecta
|
|||
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() {
|
||||
return createEmptyCompositesEnabled;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class EmbeddedIdentifierMappingImpl
|
|||
|
||||
@Override
|
||||
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||
propertyAccess.getSetter().set( entity, id, session.getFactory() );
|
||||
propertyAccess.getSetter().set( entity, id );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -185,7 +185,7 @@ public class GeneratedValuesProcessor {
|
|||
.resolveAttributeMetadata( entityDescriptor )
|
||||
.getPropertyAccess()
|
||||
.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;
|
||||
|
||||
/**
|
||||
* EmbeddableMappingType implementation describing an
|
||||
* {@link jakarta.persistence.IdClass}
|
||||
* EmbeddableMappingType implementation describing an {@link jakarta.persistence.IdClass}
|
||||
*/
|
||||
public class IdClassEmbeddable implements IdentifierValueMapper {
|
||||
public class IdClassEmbeddable extends AbstractEmbeddableMapping implements IdentifierValueMapper {
|
||||
private final NavigableRole navigableRole;
|
||||
private final NonAggregatedIdentifierMapping idMapping;
|
||||
private final VirtualIdEmbeddable virtualIdEmbeddable;
|
||||
|
@ -93,8 +92,6 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
|||
private final List<SingularAttributeMapping> attributeMappings;
|
||||
private SelectableMappings selectableMappings;
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
|
||||
public IdClassEmbeddable(
|
||||
Component idClassSource,
|
||||
RootClass bootEntityDescriptor,
|
||||
|
@ -104,7 +101,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
|||
String[] idColumns,
|
||||
VirtualIdEmbeddable virtualIdEmbeddable,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
super( creationProcess );
|
||||
|
||||
this.navigableRole = idMapping.getNavigableRole().append( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
|
||||
this.idMapping = idMapping;
|
||||
|
@ -231,7 +228,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
|||
}
|
||||
}
|
||||
|
||||
setPropertyValues( id, propertyValues );
|
||||
setValues( id, propertyValues );
|
||||
|
||||
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
|
||||
public int getNumberOfFetchables() {
|
||||
return getNumberOfAttributeMappings();
|
||||
|
@ -394,7 +373,7 @@ public class IdClassEmbeddable implements IdentifierValueMapper {
|
|||
@Override
|
||||
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
|
||||
attributeMappings.forEach( (attribute) -> {
|
||||
final Object attributeValue = attribute.getValue( domainValue, session );
|
||||
final Object attributeValue = attribute.getValue( domainValue );
|
||||
attribute.breakDownJdbcValues( attributeValue, valueConsumer, session );
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
|||
propertyValues[i] = o;
|
||||
}
|
||||
}
|
||||
identifierValueMapper.setPropertyValues( id, propertyValues );
|
||||
identifierValueMapper.setValues( id, propertyValues );
|
||||
return id;
|
||||
}
|
||||
else {
|
||||
|
@ -325,7 +325,7 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
|||
}
|
||||
}
|
||||
);
|
||||
getEmbeddableTypeDescriptor().setPropertyValues( entity, propertyValues );
|
||||
getEmbeddableTypeDescriptor().setValues( entity, propertyValues );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,7 +62,6 @@ import org.hibernate.type.CompositeType;
|
|||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
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.spi.CompositeTypeImplementor;
|
||||
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
|
||||
*/
|
||||
public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
||||
|
||||
public class VirtualIdEmbeddable extends AbstractEmbeddableMapping implements IdentifierValueMapper {
|
||||
private final NavigableRole navigableRole;
|
||||
private final NonAggregatedIdentifierMapping idMapping;
|
||||
private final JavaType<?> javaType;
|
||||
|
||||
// private final VirtualIdEmbedded embedded;
|
||||
private final VirtualIdRepresentationStrategy representationStrategy;
|
||||
|
||||
private final List<SingularAttributeMapping> attributeMappings;
|
||||
private SelectableMappings selectableMappings;
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
|
||||
public VirtualIdEmbeddable(
|
||||
Component virtualIdSource,
|
||||
NonAggregatedIdentifierMapping idMapping,
|
||||
|
@ -94,12 +87,10 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
|||
String rootTableExpression,
|
||||
String[] rootTableKeyColumnNames,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
super( creationProcess );
|
||||
|
||||
this.navigableRole = idMapping.getNavigableRole();
|
||||
this.idMapping = idMapping;
|
||||
this.javaType = identifiedEntityMapping.getJavaTypeDescriptor();
|
||||
|
||||
this.representationStrategy = new VirtualIdRepresentationStrategy( this, identifiedEntityMapping );
|
||||
|
||||
final CompositeType compositeType = (CompositeType) virtualIdSource.getType();
|
||||
|
@ -158,7 +149,7 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
|||
@Override
|
||||
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
||||
return representationStrategy.getInstantiator().instantiate(
|
||||
() -> getPropertyValues( entity ),
|
||||
() -> getValues( entity ),
|
||||
session.getSessionFactory()
|
||||
);
|
||||
}
|
||||
|
@ -166,7 +157,7 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
|||
@Override
|
||||
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||
if ( entity != id ) {
|
||||
setPropertyValues( entity, getPropertyValues( id ) );
|
||||
setValues( entity, getValues( id ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,11 +175,6 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
|||
return idMapping.getPartName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType<?> getMappedJavaTypeDescriptor() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmbeddableValuedModelPart getEmbeddedValueMapping() {
|
||||
return getEmbeddedPart();
|
||||
|
@ -200,21 +186,14 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getPropertyValues(Object composite) {
|
||||
final Object[] values = new Object[ attributeMappings.size() ];
|
||||
public AttributeMapping findAttributeMapping(String name) {
|
||||
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 );
|
||||
final AttributeMapping attr = attributeMappings.get( i );
|
||||
if ( name.equals( attr.getAttributeName() ) ) {
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -338,7 +317,7 @@ public class VirtualIdEmbeddable implements IdentifierValueMapper {
|
|||
@Override
|
||||
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
|
||||
attributeMappings.forEach( (attribute) -> {
|
||||
final Object attributeValue = attribute.getValue( domainValue, session );
|
||||
final Object attributeValue = attribute.getValue( domainValue );
|
||||
attribute.breakDownJdbcValues( attributeValue, valueConsumer, session );
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class VirtualIdRepresentationStrategy implements EmbeddableRepresentation
|
|||
if ( valuesAccess != null ) {
|
||||
final Object[] values = valuesAccess.get();
|
||||
if ( values != null ) {
|
||||
virtualIdEmbeddable.setPropertyValues( instantiated, values );
|
||||
virtualIdEmbeddable.setValues( instantiated, values );
|
||||
}
|
||||
}
|
||||
return instantiated;
|
||||
|
|
|
@ -4890,6 +4890,7 @@ public abstract class AbstractEntityPersister
|
|||
return proxyJavaTypeDescriptor != null ? proxyJavaTypeDescriptor.getJavaTypeClass() : javaTypeDescriptor.getJavaTypeClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyValues(Object object, Object[] values) {
|
||||
if ( accessOptimizer != null ) {
|
||||
accessOptimizer.setPropertyValues( object, values );
|
||||
|
@ -4902,7 +4903,7 @@ public abstract class AbstractEntityPersister
|
|||
final Object value = values[stateArrayPosition];
|
||||
if ( value != UNFETCHED_PROPERTY ) {
|
||||
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];
|
||||
if ( value != UNFETCHED_PROPERTY ) {
|
||||
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) {
|
||||
final String propertyName = getPropertyNames()[i];
|
||||
setPropertyValue( object, propertyName, value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getPropertyValues(Object object) {
|
||||
if ( accessOptimizer != null ) {
|
||||
return accessOptimizer.getPropertyValues( object );
|
||||
|
@ -5103,8 +5106,7 @@ public abstract class AbstractEntityPersister
|
|||
if ( versionMapping != null ) {
|
||||
versionMapping.getVersionAttribute().getPropertyAccess().getSetter().set(
|
||||
entity,
|
||||
versionMapping.getUnsavedStrategy().getDefaultValue( currentVersion ),
|
||||
getFactory()
|
||||
versionMapping.getUnsavedStrategy().getDefaultValue( currentVersion )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5284,7 +5286,7 @@ public abstract class AbstractEntityPersister
|
|||
public void setPropertyValue(Object object, String propertyName, Object value) {
|
||||
final AttributeMapping attributeMapping = (AttributeMapping) findSubPart( propertyName, 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) {
|
||||
|
|
|
@ -788,24 +788,48 @@ public interface EntityPersister
|
|||
*/
|
||||
Class<?> getConcreteProxyClass();
|
||||
|
||||
default void setValues(Object object, Object[] values) {
|
||||
setPropertyValues( object, values );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
default void setValue(Object object, int i, Object value) {
|
||||
setPropertyValue( object, i, value );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Return the (loaded) values of the mapped properties of the object (not including backrefs)
|
||||
*/
|
||||
Object[] getPropertyValues(Object object);
|
||||
default Object[] getValues(Object object) {
|
||||
return getPropertyValues( 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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -61,7 +60,7 @@ public class ChainedPropertyAccessImpl implements PropertyAccess, Getter, Setter
|
|||
}
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -106,7 +105,7 @@ public class PropertyAccessEmbeddedImpl implements PropertyAccess {
|
|||
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -104,7 +103,7 @@ public class PropertyAccessMapImpl implements PropertyAccess {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
( (Map) target ).put( propertyName, value );
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -135,7 +134,7 @@ public class PropertyAccessStrategyBackRefImpl implements PropertyAccessStrategy
|
|||
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
// this page intentionally left blank :)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -118,7 +117,7 @@ public class PropertyAccessStrategyIndexBackRefImpl implements PropertyAccessStr
|
|||
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
// this page intentionally left blank :)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -107,7 +106,7 @@ public class PropertyAccessStrategyNoopImpl implements PropertyAccessStrategy {
|
|||
public static final SetterImpl INSTANCE = new SetterImpl();
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,9 +36,8 @@ public class EnhancedSetterImpl extends SetterFieldImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
|
||||
super.set( target, value, factory );
|
||||
public void set(Object target, Object value) {
|
||||
super.set( target, value );
|
||||
|
||||
// This sets the component relation for dirty tracking purposes
|
||||
if ( target instanceof CompositeOwner && value instanceof CompositeTracker ) {
|
||||
|
|
|
@ -18,16 +18,8 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Setter extends Serializable {
|
||||
/**
|
||||
* Set the property value from the given instance
|
||||
*
|
||||
* @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);
|
||||
|
||||
void set(Object target, Object value);
|
||||
|
||||
/**
|
||||
* Optional operation (may return {@code null})
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SetterFieldImpl implements Setter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
try {
|
||||
field.set( target, value );
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.lang.reflect.Method;
|
|||
|
||||
import org.hibernate.PropertyAccessException;
|
||||
import org.hibernate.PropertySetterAccessException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
|
||||
|
@ -39,7 +38,7 @@ public class SetterMethodImpl implements Setter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void set(Object target, Object value, SessionFactoryImplementor factory) {
|
||||
public void set(Object target, Object value) {
|
||||
try {
|
||||
setterMethod.invoke( target, value );
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
|||
final Initializer parentInitializer = processingState.resolveInitializer( navigablePath.getParent() );
|
||||
if ( parentInitializer != this ) {
|
||||
( (FetchParentAccess) parentInitializer ).registerResolutionListener( (entity) -> {
|
||||
representationEmbeddable.setPropertyValues( entity, rowState );
|
||||
representationEmbeddable.setValues( entity, rowState );
|
||||
stateInjected = true;
|
||||
} );
|
||||
}
|
||||
|
@ -188,9 +188,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
|||
}
|
||||
}
|
||||
else if ( stateAllNull == FALSE && stateInjected != TRUE ) {
|
||||
// todo (6.0) : i think this is still called for cases where
|
||||
// we have already done the "ctor injection"
|
||||
representationEmbeddable.setPropertyValues( compositeInstance, rowState );
|
||||
representationEmbeddable.setValues( compositeInstance, rowState );
|
||||
stateInjected = true;
|
||||
}
|
||||
}
|
||||
|
@ -335,7 +333,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
|||
compositeInstance
|
||||
);
|
||||
|
||||
parentInjectionAccess.getSetter().set( compositeInstance, parent, sessionFactory );
|
||||
parentInjectionAccess.getSetter().set( compositeInstance, parent );
|
||||
}
|
||||
|
||||
private Object determineParentInstance(RowProcessingState processingState) {
|
||||
|
|
|
@ -75,14 +75,11 @@ public class AliasToBeanResultTransformer extends AliasedTupleSubsetResultTransf
|
|||
|
||||
for ( int i = 0; i < aliases.length; i++ ) {
|
||||
if ( setters[i] != null ) {
|
||||
setters[i].set( result, tuple[i], null );
|
||||
setters[i].set( result, tuple[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( InstantiationException e ) {
|
||||
throw new HibernateException( "Could not instantiate resultclass: " + resultClass.getName() );
|
||||
}
|
||||
catch ( IllegalAccessException e ) {
|
||||
catch ( InstantiationException | IllegalAccessException e ) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
||||
public ComponentTuplizer getComponentTuplizer() {
|
||||
return componentTuplizer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
||||
int span = 0;
|
||||
|
@ -382,11 +378,11 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
|||
return getPropertyValue( component, i );
|
||||
}
|
||||
|
||||
public Object getPropertyValue(Object component, int i)
|
||||
throws HibernateException {
|
||||
if (component == null) {
|
||||
component = new Object[propertySpan];
|
||||
public Object getPropertyValue(Object component, int i) {
|
||||
if ( component == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( component instanceof Object[] ) {
|
||||
// A few calls to hashCode pass the property values already in an
|
||||
// Object[] (ex: QueryKey hash codes for cached queries).
|
||||
|
@ -395,7 +391,9 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
|||
return ( (Object[]) component )[i];
|
||||
}
|
||||
else {
|
||||
return componentTuplizer.getPropertyValue( component, i );
|
||||
return mappingModelPart
|
||||
.getEmbeddableTypeDescriptor()
|
||||
.getValue( component, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,9 +405,9 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
|||
@Override
|
||||
public Object[] getPropertyValues(Object component) {
|
||||
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
|
||||
// Object[] (ex: QueryKey hash codes for cached queries).
|
||||
// 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;
|
||||
}
|
||||
else {
|
||||
return componentTuplizer.getPropertyValues( component );
|
||||
return mappingModelPart
|
||||
.getEmbeddableTypeDescriptor()
|
||||
.getValues( component );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyValues(Object component, Object[] values)
|
||||
throws HibernateException {
|
||||
componentTuplizer.setPropertyValues( component, values );
|
||||
public void setPropertyValues(Object component, Object[] values) {
|
||||
mappingModelPart.getEmbeddableTypeDescriptor().setValues( component, values );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -486,7 +485,7 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
|||
//equals()/hashCode() implementations
|
||||
final PropertyAccess parentAccess = mappingModelPart().getParentInjectionAttributePropertyAccess();
|
||||
if ( parentAccess != null ) {
|
||||
parentAccess.getSetter().set( result, parentAccess.getGetter().get( component ), factory );
|
||||
parentAccess.getSetter().set( result, parentAccess.getGetter().get( component ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PropertyAccessStrategyMapTest extends BaseUnitTestCase {
|
|||
|
||||
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, access.getGetter().get( map ) );
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class GetterSetterSerializationTest {
|
|||
|
||||
final Setter setterClone = (Setter) ois.readObject();
|
||||
final PK pkNew = new PK( 2L );
|
||||
setterClone.set( entity, pkNew, null );
|
||||
setterClone.set( entity, pkNew );
|
||||
|
||||
assertSame( pkNew, getter.get( entity ) );
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class GetterSetterSerializationTest {
|
|||
|
||||
final Setter setterClone = (Setter) ois.readObject();
|
||||
final PK pkNew = new PK( 2L );
|
||||
setterClone.set( entity, pkNew, null );
|
||||
setterClone.set( entity, pkNew );
|
||||
|
||||
assertSame( pkNew, getter.get( entity ) );
|
||||
}
|
||||
|
|
|
@ -138,11 +138,11 @@ public class ComponentPropertyMapper extends AbstractPropertyMapper implements C
|
|||
|
||||
if ( isAllPropertiesNull( data ) ) {
|
||||
// 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 {
|
||||
// set the component
|
||||
setter.set( obj, subObj, null );
|
||||
setter.set( obj, subObj );
|
||||
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.
|
||||
if ( value != null || !isPrimitive( setter, propertyData, obj.getClass() ) ) {
|
||||
setter.set( obj, value, null );
|
||||
setter.set( obj, value );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class EmbeddedIdMapper extends AbstractCompositeIdMapper implements Simpl
|
|||
}
|
||||
|
||||
if ( ret ) {
|
||||
setter.set( obj, subObj, null );
|
||||
setter.set( obj, subObj );
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SingleIdMapper extends AbstractIdMapper implements SimpleIdMapperBu
|
|||
propertyData,
|
||||
getServiceRegistry()
|
||||
);
|
||||
setter.set( obj, value, null );
|
||||
setter.set( obj, value );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class SingleIdMapper extends AbstractIdMapper implements SimpleIdMapperBu
|
|||
getServiceRegistry()
|
||||
);
|
||||
|
||||
setter.set( objTo, getter.get( objFrom ), null );
|
||||
setter.set( objTo, getter.get( objFrom ) );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,11 +95,11 @@ public class VirtualEntitySingleIdMapper extends SingleIdMapper {
|
|||
}
|
||||
|
||||
if ( !value.getClass().equals( propertyData.getVirtualReturnClass() ) ) {
|
||||
setter.set( objTo, getAssociatedEntityIdMapper().mapToIdFromEntity( value ), null );
|
||||
setter.set( objTo, getAssociatedEntityIdMapper().mapToIdFromEntity( value ) );
|
||||
}
|
||||
else {
|
||||
// This means we're setting the object
|
||||
setter.set( objTo, value, null );
|
||||
setter.set( objTo, value );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -135,10 +135,10 @@ public class VirtualEntitySingleIdMapper extends SingleIdMapper {
|
|||
);
|
||||
|
||||
if ( paramClass != null && paramClass.equals( propertyData.getVirtualReturnClass() ) ) {
|
||||
setter.set( obj, getAssociatedEntityIdMapper().mapToIdFromEntity( value ), null );
|
||||
setter.set( obj, getAssociatedEntityIdMapper().mapToIdFromEntity( value ) );
|
||||
}
|
||||
else {
|
||||
setter.set( obj, value, null );
|
||||
setter.set( obj, value );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -316,7 +316,7 @@ public abstract class AbstractCollectionMapper<T> extends AbstractPropertyMapper
|
|||
enversService.getServiceRegistry()
|
||||
);
|
||||
|
||||
setter.set( obj, collectionProxy, null );
|
||||
setter.set( obj, collectionProxy );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public abstract class AbstractToOneMapper extends AbstractPropertyMapper {
|
|||
propertyData,
|
||||
serviceRegistry
|
||||
);
|
||||
setter.set( targetObject, value, null );
|
||||
setter.set( targetObject, value );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class DefaultTrackingModifiedEntitiesRevisionInfoGenerator extends Defaul
|
|||
Set<String> modifiedEntityNames = (Set<String>) modifiedEntityNamesGetter.get( revisionEntity );
|
||||
if ( modifiedEntityNames == null ) {
|
||||
modifiedEntityNames = new HashSet<>();
|
||||
modifiedEntityNamesSetter.set( revisionEntity, modifiedEntityNames, null );
|
||||
modifiedEntityNamesSetter.set( revisionEntity, modifiedEntityNames );
|
||||
}
|
||||
modifiedEntityNames.add( entityName );
|
||||
}
|
||||
|
|
|
@ -35,13 +35,13 @@ public class RevisionTimestampValueResolver {
|
|||
|
||||
public void resolveNow(Object object) {
|
||||
if ( timestampData.isTimestampDate() ) {
|
||||
revisionTimestampSetter.set( object, new Date(), null );
|
||||
revisionTimestampSetter.set( object, new Date() );
|
||||
}
|
||||
else if ( timestampData.isTimestampLocalDateTime() ) {
|
||||
revisionTimestampSetter.set(object, LocalDateTime.now(), null );
|
||||
revisionTimestampSetter.set(object, LocalDateTime.now() );
|
||||
}
|
||||
else {
|
||||
revisionTimestampSetter.set( object, System.currentTimeMillis(), null );
|
||||
revisionTimestampSetter.set( object, System.currentTimeMillis() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue