HHH-15393 - Improve write-paths to use mapping model
This commit is contained in:
parent
3e6fcdeda3
commit
815c4eb4a1
|
@ -28,8 +28,8 @@ import org.hibernate.engine.spi.SelfDirtinessTracker;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.pretty.MessageHelper;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
||||
|
@ -311,7 +311,8 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
|
|||
return null;
|
||||
}
|
||||
else {
|
||||
final int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex( propertyName );
|
||||
final AttributeMapping attributeMapping = persister.findAttributeMapping( propertyName );
|
||||
final int propertyIndex = attributeMapping.getStateArrayPosition();
|
||||
return loadedState[propertyIndex];
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +324,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
|
|||
assert propertyName != null;
|
||||
assert loadedState != null;
|
||||
|
||||
final int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex( propertyName );
|
||||
final int propertyIndex = persister.findAttributeMapping( propertyName ).getStateArrayPosition();
|
||||
loadedState[propertyIndex] = collection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.lang.reflect.Field;
|
|||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.PropertyNotFoundException;
|
||||
|
@ -25,11 +24,14 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.metamodel.AttributeClassification;
|
||||
import org.hibernate.metamodel.UnsupportedMappingException;
|
||||
import org.hibernate.metamodel.RepresentationMode;
|
||||
import org.hibernate.metamodel.UnsupportedMappingException;
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.CompositeIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.EntityVersionMapping;
|
||||
import org.hibernate.metamodel.model.domain.AbstractIdentifiableType;
|
||||
import org.hibernate.metamodel.model.domain.DomainType;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
|
@ -49,10 +51,7 @@ import org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.property.access.internal.PropertyAccessMapImpl;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||
import org.hibernate.type.AnyType;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.EmbeddedComponentType;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
|
@ -306,36 +305,19 @@ public class AttributeFactory {
|
|||
private static EntityPersister getDeclaringEntity(
|
||||
AbstractIdentifiableType<?> ownerType,
|
||||
MetadataContext metadataContext) {
|
||||
final Type.PersistenceType persistenceType = ownerType.getPersistenceType();
|
||||
if ( persistenceType == Type.PersistenceType.ENTITY ) {
|
||||
return metadataContext.getMetamodel()
|
||||
.getEntityDescriptor( ownerType.getTypeName() );
|
||||
}
|
||||
else if ( persistenceType == Type.PersistenceType.MAPPED_SUPERCLASS ) {
|
||||
PersistentClass persistentClass =
|
||||
metadataContext.getPersistentClassHostingProperties( (MappedSuperclassTypeImpl<?>) ownerType );
|
||||
return metadataContext.getMetamodel()
|
||||
.findEntityDescriptor( persistentClass.getClassName() );
|
||||
}
|
||||
else {
|
||||
throw new AssertionFailure( "Cannot get the metamodel for PersistenceType: " + persistenceType );
|
||||
}
|
||||
return getDeclarerEntityPersister( ownerType, metadataContext );
|
||||
}
|
||||
private static EntityMetamodel getDeclarerEntityMetamodel(
|
||||
|
||||
private static EntityPersister getDeclarerEntityPersister(
|
||||
AbstractIdentifiableType<?> ownerType,
|
||||
MetadataContext metadataContext) {
|
||||
final Type.PersistenceType persistenceType = ownerType.getPersistenceType();
|
||||
if ( persistenceType == Type.PersistenceType.ENTITY ) {
|
||||
return metadataContext.getMetamodel()
|
||||
.getEntityDescriptor( ownerType.getTypeName() )
|
||||
.getEntityMetamodel();
|
||||
return metadataContext.getMetamodel().getEntityDescriptor( ownerType.getTypeName() );
|
||||
}
|
||||
else if ( persistenceType == Type.PersistenceType.MAPPED_SUPERCLASS ) {
|
||||
PersistentClass persistentClass =
|
||||
metadataContext.getPersistentClassHostingProperties( (MappedSuperclassTypeImpl<?>) ownerType );
|
||||
return metadataContext.getMetamodel()
|
||||
.findEntityDescriptor( persistentClass.getClassName() )
|
||||
.getEntityMetamodel();
|
||||
PersistentClass persistentClass = metadataContext.getPersistentClassHostingProperties( (MappedSuperclassTypeImpl<?>) ownerType );
|
||||
return metadataContext.getMetamodel().findEntityDescriptor( persistentClass.getClassName() );
|
||||
}
|
||||
else {
|
||||
throw new AssertionFailure( "Cannot get the metamodel for PersistenceType: " + persistenceType );
|
||||
|
@ -617,21 +599,16 @@ public class AttributeFactory {
|
|||
|
||||
private static final MemberResolver virtualIdentifierMemberResolver = (attributeContext, metadataContext) -> {
|
||||
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) ) {
|
||||
final EntityPersister entityPersister = getDeclarerEntityPersister( identifiableType, metadataContext );
|
||||
final EntityIdentifierMapping identifierMapping = entityPersister.getIdentifierMapping();
|
||||
|
||||
if ( identifierMapping.getNature() != EntityIdentifierMapping.Nature.VIRTUAL ) {
|
||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||
}
|
||||
|
||||
final CompositeIdentifierMapping cid = (CompositeIdentifierMapping) identifierMapping;
|
||||
final EmbeddableMappingType embeddable = cid.getPartMappingType();
|
||||
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(
|
||||
|
@ -658,16 +635,16 @@ public class AttributeFactory {
|
|||
else if ( Type.PersistenceType.ENTITY == persistenceType
|
||||
|| Type.PersistenceType.MAPPED_SUPERCLASS == persistenceType ) {
|
||||
final AbstractIdentifiableType<?> identifiableType = (AbstractIdentifiableType<?>) ownerType;
|
||||
final EntityPersister declaringEntityMapping = getDeclaringEntity( identifiableType, metadataContext );
|
||||
final EntityMetamodel entityMetamodel = declaringEntityMapping.getEntityMetamodel();
|
||||
final EntityPersister declaringEntityPersister = getDeclaringEntity( identifiableType, metadataContext );
|
||||
final String propertyName = property.getName();
|
||||
final Integer index = entityMetamodel.getPropertyIndexOrNull( propertyName );
|
||||
if ( index == null ) {
|
||||
|
||||
final AttributeMapping attributeMapping = declaringEntityPersister.findAttributeMapping( propertyName );
|
||||
if ( attributeMapping == null ) {
|
||||
// just like in #determineIdentifierJavaMember , this *should* indicate we have an IdClass mapping
|
||||
return virtualIdentifierMemberResolver.resolveMember( attributeContext, metadataContext );
|
||||
}
|
||||
else {
|
||||
final Getter getter = declaringEntityMapping.getRepresentationStrategy().resolvePropertyAccess( property ).getGetter();
|
||||
final Getter getter = declaringEntityPersister.getRepresentationStrategy().resolvePropertyAccess( property ).getGetter();
|
||||
return getter instanceof PropertyAccessMapImpl.GetterImpl
|
||||
? new MapMember( propertyName, property.getType().getReturnedClass() )
|
||||
: getter.getMember();
|
||||
|
@ -681,20 +658,16 @@ public class AttributeFactory {
|
|||
private final MemberResolver identifierMemberResolver = (attributeContext, metadataContext) -> {
|
||||
final AbstractIdentifiableType<?> identifiableType = (AbstractIdentifiableType<?>) attributeContext.getOwnerType();
|
||||
final EntityPersister declaringEntityMapping = getDeclaringEntity( identifiableType, metadataContext );
|
||||
final EntityMetamodel entityMetamodel = declaringEntityMapping.getEntityMetamodel();
|
||||
|
||||
if ( !attributeContext.getPropertyMapping().getName()
|
||||
.equals( entityMetamodel.getIdentifierProperty().getName() ) ) {
|
||||
final EntityIdentifierMapping identifierMapping = declaringEntityMapping.getIdentifierMapping();
|
||||
final String attributeName = attributeContext.getPropertyMapping().getName();
|
||||
if ( !attributeName.equals( identifierMapping.getAttributeName() ) ) {
|
||||
// this *should* indicate processing part of an IdClass...
|
||||
return virtualIdentifierMemberResolver.resolveMember( attributeContext, metadataContext );
|
||||
}
|
||||
|
||||
final Getter getter = declaringEntityMapping.getRepresentationStrategy().resolvePropertyAccess( attributeContext.getPropertyMapping() ).getGetter();
|
||||
if ( getter instanceof PropertyAccessMapImpl.GetterImpl ) {
|
||||
return new MapMember(
|
||||
entityMetamodel.getIdentifierProperty().getName(),
|
||||
entityMetamodel.getIdentifierProperty().getType().getReturnedClass()
|
||||
);
|
||||
return new MapMember( identifierMapping.getAttributeName(), identifierMapping.getJavaType().getJavaTypeClass() );
|
||||
}
|
||||
else {
|
||||
return getter.getMember();
|
||||
|
@ -703,20 +676,20 @@ public class AttributeFactory {
|
|||
|
||||
private final MemberResolver versionMemberResolver = (attributeContext, metadataContext) -> {
|
||||
final AbstractIdentifiableType<?> identifiableType = (AbstractIdentifiableType<?>) attributeContext.getOwnerType();
|
||||
final EntityPersister declaringEntityMapping = getDeclaringEntity( identifiableType, metadataContext );
|
||||
final EntityMetamodel entityMetamodel = declaringEntityMapping.getEntityMetamodel();
|
||||
final EntityPersister entityPersister = getDeclaringEntity( identifiableType, metadataContext );
|
||||
final EntityVersionMapping versionMapping = entityPersister.getVersionMapping();
|
||||
assert entityPersister.isVersioned();
|
||||
assert versionMapping != null;
|
||||
|
||||
final String versionPropertyName = attributeContext.getPropertyMapping().getName();
|
||||
if ( !versionPropertyName.equals( entityMetamodel.getVersionProperty().getName() ) ) {
|
||||
if ( !versionPropertyName.equals( versionMapping.getVersionAttribute().getAttributeName() ) ) {
|
||||
// this should never happen, but to be safe...
|
||||
throw new IllegalArgumentException( "Given property did not match declared version property" );
|
||||
}
|
||||
|
||||
final Getter getter = declaringEntityMapping.getRepresentationStrategy().resolvePropertyAccess( attributeContext.getPropertyMapping() ).getGetter();
|
||||
final Getter getter = entityPersister.getRepresentationStrategy().resolvePropertyAccess( attributeContext.getPropertyMapping() ).getGetter();
|
||||
if ( getter instanceof PropertyAccessMapImpl.GetterImpl ) {
|
||||
return new MapMember(
|
||||
versionPropertyName,
|
||||
attributeContext.getPropertyMapping().getType().getReturnedClass()
|
||||
);
|
||||
return new MapMember( versionPropertyName, versionMapping.getJavaType().getJavaTypeClass() );
|
||||
}
|
||||
else {
|
||||
return getter.getMember();
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|||
* @see jakarta.persistence.EmbeddedId
|
||||
*/
|
||||
public interface EntityIdentifierMapping extends ValueMapping, ModelPart {
|
||||
|
||||
String ROLE_LOCAL_NAME = "{id}";
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +27,16 @@ public interface EntityIdentifierMapping extends ValueMapping, ModelPart {
|
|||
return ROLE_LOCAL_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Nature
|
||||
*/
|
||||
Nature getNature();
|
||||
|
||||
/**
|
||||
* The name of the attribute defining the id, if one
|
||||
*/
|
||||
String getAttributeName();
|
||||
|
||||
/**
|
||||
* The strategy for distinguishing between detached and transient
|
||||
* state based on the identifier mapping
|
||||
|
@ -89,4 +100,22 @@ public interface EntityIdentifierMapping extends ValueMapping, ModelPart {
|
|||
void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session);
|
||||
|
||||
Object instantiate();
|
||||
|
||||
enum Nature {
|
||||
/**
|
||||
* Single column id
|
||||
*/
|
||||
SIMPLE,
|
||||
|
||||
/**
|
||||
* @see jakarta.persistence.EmbeddedId
|
||||
*/
|
||||
COMPOSITE,
|
||||
|
||||
/**
|
||||
* Composite identifier defined with multiple {@link jakarta.persistence.Id}
|
||||
* mappings. Often used in conjunction with an {@link jakarta.persistence.IdClass}
|
||||
*/
|
||||
VIRTUAL
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,11 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
return attributeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.SIMPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierValue getUnsavedStrategy() {
|
||||
return unsavedStrategy;
|
||||
|
|
|
@ -10,8 +10,8 @@ import java.util.function.BiConsumer;
|
|||
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.metamodel.internal.AbstractCompositeIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
@ -53,6 +53,11 @@ public class EmbeddedIdentifierMappingImpl
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.COMPOSITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmbeddableMappingType getPartMappingType() {
|
||||
return embeddableDescriptor;
|
||||
|
|
|
@ -92,6 +92,11 @@ public class InverseNonAggregatedIdentifierMapping extends EmbeddedAttributeMapp
|
|||
return super.getPartName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.VIRTUAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmbeddableMappingType getPartMappingType() {
|
||||
return (EmbeddableMappingType) super.getPartMappingType();
|
||||
|
|
|
@ -200,6 +200,16 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
|
|||
return super.toSqlExpression( tableGroup, clause, walker, sqlAstCreationState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.VIRTUAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
||||
return getIdentifier( entity );
|
||||
|
|
|
@ -33,6 +33,11 @@ public class AnonymousTupleBasicEntityIdentifierMapping
|
|||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.SIMPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierValue getUnsavedStrategy() {
|
||||
return delegate.getUnsavedStrategy();
|
||||
|
|
|
@ -11,17 +11,14 @@ import java.util.Map;
|
|||
import org.hibernate.Incubating;
|
||||
import org.hibernate.engine.spi.IdentifierValue;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.CompositeIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping;
|
||||
import org.hibernate.metamodel.model.domain.DomainType;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.query.sqm.SqmExpressible;
|
||||
|
||||
/**
|
||||
* @author Christian Beikov
|
||||
|
@ -46,6 +43,11 @@ public class AnonymousTupleEmbeddedEntityIdentifierMapping extends AnonymousTupl
|
|||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return delegate.getNature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierValue getUnsavedStrategy() {
|
||||
return delegate.getUnsavedStrategy();
|
||||
|
|
|
@ -13,17 +13,13 @@ import org.hibernate.engine.FetchStyle;
|
|||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.IdentifierValue;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.metamodel.mapping.CompositeIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.IdClassEmbeddable;
|
||||
import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.VirtualIdEmbeddable;
|
||||
import org.hibernate.metamodel.model.domain.DomainType;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
||||
/**
|
||||
* @author Christian Beikov
|
||||
|
@ -48,6 +44,16 @@ public class AnonymousTupleNonAggregatedEntityIdentifierMapping extends Anonymou
|
|||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.VIRTUAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierValue getUnsavedStrategy() {
|
||||
return delegate.getUnsavedStrategy();
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.hibernate.metamodel.mapping.EntityVersionMapping;
|
|||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.proxy.LazyInitializer;
|
||||
|
@ -62,9 +61,9 @@ import org.hibernate.type.AssociationType;
|
|||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
||||
import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY;
|
||||
import static org.hibernate.internal.log.LoggingHelper.toLoggableString;
|
||||
|
||||
/**
|
||||
|
@ -734,7 +733,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
|||
final AssociationType associationType = (AssociationType) propertyType;
|
||||
final String ukName = associationType.getLHSPropertyName();
|
||||
if ( ukName != null ) {
|
||||
final int index = ( (UniqueKeyLoadable) concreteDescriptor ).getPropertyIndex( ukName );
|
||||
final int index = concreteDescriptor.findAttributeMapping( ukName ).getStateArrayPosition();
|
||||
final Type type = concreteDescriptor.getPropertyTypes()[index];
|
||||
|
||||
// polymorphism not really handled completely correctly,
|
||||
|
|
|
@ -130,7 +130,7 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
|
|||
}
|
||||
|
||||
protected static int getPropertyIndex(EntityInitializer entityInitializer, String propertyName) {
|
||||
return entityInitializer.getConcreteDescriptor().getPropertyIndex( propertyName );
|
||||
return entityInitializer.getConcreteDescriptor().findAttributeMapping( propertyName ).getStateArrayPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ import static org.hibernate.internal.CoreLogging.messageLogger;
|
|||
public class EntityMetamodel implements Serializable {
|
||||
private static final CoreMessageLogger LOG = messageLogger( EntityMetamodel.class );
|
||||
|
||||
private static final int NO_VERSION_INDX = -66;
|
||||
public static final int NO_VERSION_INDX = -66;
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
|
||||
|
|
|
@ -8,25 +8,25 @@ package org.hibernate.orm.test.fetchstrategyhelper;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
|
@ -175,7 +175,7 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
return entityPersister.getFetchMode( index );
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
return (AssociationType) entityPersister.getSubclassPropertyType( index );
|
||||
}
|
||||
|
||||
|
|
|
@ -8,24 +8,24 @@ package org.hibernate.orm.test.fetchstrategyhelper;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
|
@ -171,7 +171,7 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
return entityPersister.getFetchMode( index );
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
return (AssociationType) entityPersister.getSubclassPropertyType( index );
|
||||
}
|
||||
|
||||
|
|
|
@ -6,24 +6,23 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.fetchstrategyhelper;
|
||||
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
|
@ -93,7 +92,7 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
return entityPersister.getFetchMode( index );
|
||||
}
|
||||
|
||||
|
@ -101,7 +100,7 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
return (AssociationType) entityPersister.getSubclassPropertyType( index );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue