HHH-8276 - Integrate LoadPlans into UniqueEntityLoader (PoC)
This commit is contained in:
parent
8638aac01a
commit
803c73c555
|
@ -161,6 +161,7 @@ import org.hibernate.id.SequenceHiLoGenerator;
|
|||
import org.hibernate.id.TableHiLoGenerator;
|
||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Constraint;
|
||||
|
@ -926,7 +927,7 @@ public final class AnnotationBinder {
|
|||
);
|
||||
propertyHolder.setInIdClass( null );
|
||||
inferredData = new PropertyPreloadedData(
|
||||
propertyAccessor, "_identifierMapper", compositeClass
|
||||
propertyAccessor, PropertyPath.IDENTIFIER_MAPPER_PROPERTY, compositeClass
|
||||
);
|
||||
Component mapper = fillComponent(
|
||||
propertyHolder,
|
||||
|
@ -959,7 +960,7 @@ public final class AnnotationBinder {
|
|||
}
|
||||
|
||||
Property property = new Property();
|
||||
property.setName( "_identifierMapper" );
|
||||
property.setName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY );
|
||||
property.setNodeName( "id" );
|
||||
property.setUpdateable( false );
|
||||
property.setInsertable( false );
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.hibernate.AnnotationException;
|
|||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
import org.hibernate.annotations.common.reflection.XProperty;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Join;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
|
@ -350,7 +351,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
|
|||
if ( userPropertyName != null ) result = super.getOverriddenColumn( userPropertyName );
|
||||
}
|
||||
if ( result == null ) {
|
||||
String userPropertyName = extractUserPropertyName( "_identifierMapper", propertyName );
|
||||
String userPropertyName = extractUserPropertyName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY, propertyName );
|
||||
if ( userPropertyName != null ) result = super.getOverriddenColumn( userPropertyName );
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.hibernate.internal.util.ReflectHelper;
|
|||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.JoinedIterator;
|
||||
import org.hibernate.internal.util.xml.XmlDocument;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.Array;
|
||||
import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
||||
|
@ -1880,7 +1881,7 @@ public final class HbmBinder {
|
|||
);
|
||||
persistentClass.setIdentifierMapper(mapper);
|
||||
Property property = new Property();
|
||||
property.setName("_identifierMapper");
|
||||
property.setName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY );
|
||||
property.setNodeName("id");
|
||||
property.setUpdateable(false);
|
||||
property.setInsertable(false);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class LoadQueryInfluencers implements Serializable {
|
|||
private final Set<String> enabledFetchProfileNames;
|
||||
|
||||
public LoadQueryInfluencers() {
|
||||
this( null, Collections.<String, Filter>emptyMap(), Collections.<String>emptySet() );
|
||||
this( null );
|
||||
}
|
||||
|
||||
public LoadQueryInfluencers(SessionFactoryImplementor sessionFactory) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.hibernate.TransientObjectException;
|
|||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.internal.ForeignKeys;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
|
@ -111,7 +112,7 @@ public class ForeignGenerator implements IdentifierGenerator, Configurable {
|
|||
}
|
||||
else {
|
||||
// try identifier mapper
|
||||
foreignValueSourceType = (EntityType) persister.getPropertyType( "_identifierMapper." + propertyName );
|
||||
foreignValueSourceType = (EntityType) persister.getPropertyType( PropertyPath.IDENTIFIER_MAPPER_PROPERTY + "." + propertyName );
|
||||
}
|
||||
|
||||
Serializable id;
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.hibernate.internal.util.StringHelper;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class PropertyPath {
|
||||
public static final String IDENTIFIER_MAPPER_PROPERTY = "_identifierMapper";
|
||||
private final PropertyPath parent;
|
||||
private final String property;
|
||||
private final String fullPath;
|
||||
|
@ -40,7 +41,7 @@ public class PropertyPath {
|
|||
// the _identifierMapper is a "hidden" property on entities with composite keys.
|
||||
// concatenating it will prevent the path from correctly being used to look up
|
||||
// various things such as criteria paths and fetch profile association paths
|
||||
if ( "_identifierMapper".equals( property ) ) {
|
||||
if ( IDENTIFIER_MAPPER_PROPERTY.equals( property ) ) {
|
||||
this.fullPath = parent != null ? parent.getFullPath() : "";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -32,17 +32,12 @@ import org.hibernate.engine.FetchTiming;
|
|||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.loader.plan2.build.spi.AbstractLoadPlanBuildingAssociationVisitationStrategy;
|
||||
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
||||
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
||||
import org.hibernate.loader.plan2.spi.CollectionReturn;
|
||||
import org.hibernate.loader.plan2.spi.EntityFetch;
|
||||
import org.hibernate.loader.plan2.spi.EntityReturn;
|
||||
import org.hibernate.loader.plan2.spi.LoadPlan;
|
||||
import org.hibernate.loader.plan2.spi.Return;
|
||||
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
||||
import org.hibernate.persister.walking.spi.AssociationKey;
|
||||
|
||||
/**
|
||||
* LoadPlanBuilderStrategy implementation used for building LoadPlans based on metamodel-defined fetching. Built
|
||||
|
@ -58,8 +53,6 @@ public class FetchStyleLoadPlanBuildingAssociationVisitationStrategy
|
|||
|
||||
private Return rootReturn;
|
||||
|
||||
private PropertyPath propertyPath = new PropertyPath( "" );
|
||||
|
||||
public FetchStyleLoadPlanBuildingAssociationVisitationStrategy(
|
||||
SessionFactoryImplementor sessionFactory,
|
||||
LoadQueryInfluencers loadQueryInfluencers) {
|
||||
|
@ -102,7 +95,7 @@ public class FetchStyleLoadPlanBuildingAssociationVisitationStrategy
|
|||
|
||||
@Override
|
||||
protected FetchStrategy determineFetchStrategy(AssociationAttributeDefinition attributeDefinition) {
|
||||
FetchStrategy fetchStrategy = attributeDefinition.determineFetchPlan( loadQueryInfluencers, propertyPath );
|
||||
FetchStrategy fetchStrategy = attributeDefinition.determineFetchPlan( loadQueryInfluencers, currentPropertyPath );
|
||||
if ( fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN ) {
|
||||
// see if we need to alter the join fetch to another form for any reason
|
||||
fetchStrategy = adjustJoinFetchIfNeeded( attributeDefinition, fetchStrategy );
|
||||
|
|
|
@ -515,7 +515,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
|||
compositionDefinition.getName()
|
||||
);
|
||||
}
|
||||
|
||||
protected PropertyPath currentPropertyPath = new PropertyPath( "" );
|
||||
@Override
|
||||
public boolean startingAttribute(AttributeDefinition attributeDefinition) {
|
||||
log.tracef(
|
||||
|
@ -529,7 +529,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
|||
final boolean isComponentType = attributeType.isComponentType();
|
||||
final boolean isAssociationType = attributeType.isAssociationType();
|
||||
final boolean isBasicType = ! ( isComponentType || isAssociationType );
|
||||
|
||||
currentPropertyPath = currentPropertyPath.append( attributeDefinition.getName() );
|
||||
if ( isBasicType ) {
|
||||
return true;
|
||||
}
|
||||
|
@ -548,6 +548,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
|||
StringHelper.repeat( "<<", fetchSourceStack.size() ),
|
||||
attributeDefinition
|
||||
);
|
||||
currentPropertyPath = currentPropertyPath.getParent();
|
||||
}
|
||||
|
||||
private Map<AssociationKey,FetchSource> fetchedAssociationKeySourceMap = new HashMap<AssociationKey, FetchSource>();
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.persister.walking.internal;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
|
|
|
@ -29,11 +29,40 @@ import org.hibernate.type.Type;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface CollectionIndexDefinition {
|
||||
/**
|
||||
* Returns the collection definition.
|
||||
* @return the collection definition.
|
||||
*/
|
||||
public CollectionDefinition getCollectionDefinition();
|
||||
|
||||
/**
|
||||
* Returns the collection index type.
|
||||
* @return the collection index type
|
||||
*/
|
||||
public Type getType();
|
||||
|
||||
/**
|
||||
* If the index type returned by {@link #getType()} is an
|
||||
* {@link org.hibernate.type.EntityType}, then the entity
|
||||
* definition for the collection index is returned;
|
||||
* otherwise, IllegalStateException is thrown.
|
||||
*
|
||||
* @return the entity definition for the collection index.
|
||||
*
|
||||
* @throws IllegalStateException if the collection index type
|
||||
* returned by {@link #getType()} is not of type
|
||||
* {@link org.hibernate.type.EntityType}.
|
||||
*/
|
||||
public EntityDefinition toEntityDefinition();
|
||||
|
||||
/**
|
||||
* If the index type returned by {@link #getType()} is a
|
||||
* {@link org.hibernate.type.CompositeType}, then the composite
|
||||
* index definition for the collection index is returned;
|
||||
* otherwise, IllegalStateException is thrown.
|
||||
*
|
||||
* @return the composite index definition for the collection index.
|
||||
*
|
||||
* @throws IllegalStateException if the collection index type
|
||||
* returned by {@link #getType()} is not of type
|
||||
* {@link org.hibernate.type.CompositeType}.
|
||||
*/
|
||||
public CompositionDefinition toCompositeDefinition();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.hibernate.type.Type;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface NonEncapsulatedEntityIdentifierDefinition extends EntityIdentifierDefinition, CompositionDefinition {
|
||||
public Iterable<AttributeDefinition> getAttributes();
|
||||
|
||||
public Type getCompositeType();
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.hibernate.event.spi.PersistEvent;
|
|||
import org.hibernate.event.spi.PersistEventListener;
|
||||
import org.hibernate.id.Assigned;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
|
@ -639,7 +640,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
|||
//final int index = entityMetamodel.getPropertyIndexOrNull( basePropertyName );
|
||||
Integer index = entityMetamodel.getPropertyIndexOrNull( basePropertyName );
|
||||
if (index == null) {
|
||||
propertyPath = "_identifierMapper." + propertyPath;
|
||||
propertyPath = PropertyPath.IDENTIFIER_MAPPER_PROPERTY + "." + propertyPath;
|
||||
loc = propertyPath.indexOf('.');
|
||||
basePropertyName = loc > 0
|
||||
? propertyPath.substring( 0, loc )
|
||||
|
|
Loading…
Reference in New Issue