Top Description Fields Constructors Methods
org.hibernate.loader.plan.build.internal

public abstract Class AbstractEntityGraphVisitationStrategy

extends AbstractLoadPlanBuildingAssociationVisitationStrategy
Class Inheritance
Known Direct Subclasses
org.hibernate.loader.plan.build.internal.FetchGraphLoadPlanBuildingStrategy, org.hibernate.loader.plan.build.internal.LoadGraphLoadPlanBuildingStrategy
Imports
java.util.Map, javax.persistence.Subgraph, org.hibernate.HibernateException, .LockMode, org.hibernate.engine.FetchStrategy, .FetchStyle, .FetchTiming, org.hibernate.engine.spi.LoadQueryInfluencers, .SessionFactoryImplementor, org.hibernate.graph.spi.AttributeNodeImplementor, .GraphImplementor, org.hibernate.internal.CoreLogging, org.hibernate.internal.util.collections.Stack, .StandardStack, org.hibernate.loader.plan.spi.EntityReturn, .LoadPlan, .Return, org.hibernate.persister.walking.spi.AssociationAttributeDefinition, .AttributeDefinition, .CollectionElementDefinition, .CollectionIndexDefinition, .WalkingException, org.jboss.logging.Logger

Abstract strategy of building loadplan based on entity graph. The problem we're resolving here is, we have TWO trees to walk (only entity loading here): And most time, the entity graph tree is partial of entity metadata tree. So, the idea here is, we walk the entity metadata tree, just as how we build the static loadplan from mappings, and we try to match the node to entity graph ( and subgraph ), if there is a match, then the attribute is fetched, it is not, then depends on which property is used to apply this entity graph.
Authors
Strong Liu, Brett Meyer

Field Summary

Modifier and TypeField and Description
private final Stack<AttributeNodeImplementor<J>>
protected static final FetchStrategy
DEFAULT_EAGER

The JPA 2.1 SPEC's Entity Graph only defines _WHEN_ to load an attribute, it doesn't define _HOW_ to load it So I'm here just making an assumption that when it is EAGER, then we use JOIN, and when it is LAZY, then we use SELECT.

protected static final FetchStrategy
private final Stack<GraphImplementor<J>>
protected final LoadQueryInfluencers
private final LockMode
private static final Logger
private EntityReturn
Inherited from org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy:
currentPropertyPath

Constructor Summary

AccessConstructor and Description
protected
AbstractEntityGraphVisitationStrategy(final SessionFactoryImplementor sessionFactory, final LoadQueryInfluencers loadQueryInfluencers, final LockMode lockMode)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
protected void
protected FetchStrategy
public LoadPlan
protected FetchStrategy
public void
public void
public void
public void
public void
protected abstract GraphImplementor<J>
protected abstract FetchStrategy
public void
public boolean
public void
startingCollectionElements(final CollectionElementDefinition
The collection element we are preparing to walk..
elementDefinition
)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.startingCollectionElements.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingCollectionElements.

Notification that we are starting to look at the element definition for the collection.
public void
startingCollectionIndex(final CollectionIndexDefinition
The collection index we are preparing to walk.
indexDefinition
)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.startingCollectionIndex.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingCollectionIndex.

Notification that we are starting to walk the index of a collection (List/Map).
protected boolean
Inherited from org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy:
associationKeyRegisteredcurrentDepthcurrentSourcefinishingCollectionfinishingCompositefinishingEntityfinishingEntityIdentifierfoundAnygetQuerySpacesgetSessionFactoryhandleAssociationAttributehandleCompositeAttributeisDuplicateAssociationKeyisTooManyCollectionsregisteredFetchSourcesessionFactorystartingCollectionstartingCompositestartingEntitystartingEntityIdentifiersupportsRootEntityReturns

Field Detail

attributeStackback to summary
private final Stack<AttributeNodeImplementor<J>> attributeStack
DEFAULT_EAGERback to summary
protected static final FetchStrategy DEFAULT_EAGER

The JPA 2.1 SPEC's Entity Graph only defines _WHEN_ to load an attribute, it doesn't define _HOW_ to load it So I'm here just making an assumption that when it is EAGER, then we use JOIN, and when it is LAZY, then we use SELECT.

Note

this may be changed in the near further, though ATM I have no idea how this will be changed to :) -- stliu

DEFAULT_LAZYback to summary
protected static final FetchStrategy DEFAULT_LAZY
graphStackback to summary
private final Stack<GraphImplementor<J>> graphStack
loadQueryInfluencersback to summary
protected final LoadQueryInfluencers loadQueryInfluencers
lockModeback to summary
private final LockMode lockMode
LOGback to summary
private static final Logger LOG
rootEntityReturnback to summary
private EntityReturn rootEntityReturn

Constructor Detail

AbstractEntityGraphVisitationStrategyback to summary
protected AbstractEntityGraphVisitationStrategy(final SessionFactoryImplementor sessionFactory, final LoadQueryInfluencers loadQueryInfluencers, final LockMode lockMode)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Method Detail

addRootReturnback to summary
protected void addRootReturn(final Return rootReturn)

Implements abstract org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.addRootReturn.

Annotations
@Override
adjustJoinFetchIfNeededback to summary
protected FetchStrategy adjustJoinFetchIfNeeded(AssociationAttributeDefinition attributeDefinition, FetchStrategy fetchStrategy)
buildLoadPlanback to summary
public LoadPlan buildLoadPlan()

Implements org.hibernate.loader.plan.build.spi.LoadPlanBuildingAssociationVisitationStrategy.buildLoadPlan.

Doc from org.hibernate.loader.plan.build.spi.LoadPlanBuildingAssociationVisitationStrategy.buildLoadPlan.

After visitation is done, build the load plan.

Returns:LoadPlan

The load plan

Annotations
@Override
determineFetchStrategyback to summary
protected FetchStrategy determineFetchStrategy(final AssociationAttributeDefinition attributeDefinition)

Implements abstract org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.determineFetchStrategy.

Annotations
@Override
finishback to summary
public void finish()

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.finish.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finish.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finish.

Notification we are finished visitation.

Annotations
@Override
finishingAttributeback to summary
public void finishingAttribute(final AttributeDefinition attributeDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.finishingAttribute.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finishingAttribute.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finishingAttribute.

Notification that we are finishing walking an attribute.

Parameters
attributeDefinition:AttributeDefinition

The attribute we are done walking

Annotations
@Override
finishingCollectionElementsback to summary
public void finishingCollectionElements(final CollectionElementDefinition elementDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.finishingCollectionElements.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finishingCollectionElements.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finishingCollectionElements.

Notification that we are finishing walking the elements of a collection (List/Map).

Parameters
elementDefinition:CollectionElementDefinition

The collection element we are finishing

Annotations
@Override
finishingCollectionIndexback to summary
public void finishingCollectionIndex(final CollectionIndexDefinition indexDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.finishingCollectionIndex.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finishingCollectionIndex.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.finishingCollectionIndex.

Notification that we are finishing walking the index of a collection (List/Map).

Parameters
indexDefinition:CollectionIndexDefinition

The collection index we are finishing

Annotations
@Override
foundCircularAssociationback to summary
public void foundCircularAssociation(AssociationAttributeDefinition attributeDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.foundCircularAssociation.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.foundCircularAssociation.

Annotations
@Override
getRootEntityGraphback to summary
protected abstract GraphImplementor<J> getRootEntityGraph()
resolveImplicitFetchStrategyFromEntityGraphback to summary
protected abstract FetchStrategy resolveImplicitFetchStrategyFromEntityGraph(final AssociationAttributeDefinition attributeDefinition)
startback to summary
public void start()

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.start.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.start.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.start.

Notification we are preparing to start visitation.

Annotations
@Override
startingAttributeback to summary
public boolean startingAttribute(AttributeDefinition attributeDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.startingAttribute.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingAttribute.

I'm using the NULL-OBJECT pattern here. For attributes that don't exist in the EntityGraph, a predefined NULL-ATTRIBUTE-NODE is pushed to the stack. And for a nonexistent subgraph, a predefined NULL-SUBGRAPH is pushed to the stack. So, whenever we start visiting an attribute, there will be an attribute node pushed to the attribute stack, and a subgraph node pushed to the graph stack. when we finish visiting an attribute, these two will be popped from each stack.

Parameters
attributeDefinition:AttributeDefinition

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingAttribute.

The attribute we are preparing to walk.

Returns:boolean

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingAttribute.

true if the walking should continue; false if walking should stop.

Annotations
@Override
startingCollectionElementsback to summary
public void startingCollectionElements(final CollectionElementDefinition elementDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.startingCollectionElements.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingCollectionElements.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingCollectionElements.

Notification that we are starting to look at the element definition for the collection. If the collection elements are entities this will be followed up by a call to startingEntity

Parameters
elementDefinition:CollectionElementDefinition

The collection element we are preparing to walk..

Annotations
@Override
startingCollectionIndexback to summary
public void startingCollectionIndex(final CollectionIndexDefinition indexDefinition)

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.startingCollectionIndex.

Implements org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingCollectionIndex.

Doc from org.hibernate.persister.walking.spi.AssociationVisitationStrategy.startingCollectionIndex.

Notification that we are starting to walk the index of a collection (List/Map). In the case of a Map, if the indices (the keys) are entities this will be followed up by a call to startingEntity

Parameters
indexDefinition:CollectionIndexDefinition

The collection index we are preparing to walk.

Annotations
@Override
supportsRootCollectionReturnsback to summary
protected boolean supportsRootCollectionReturns()

Overrides org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.supportsRootCollectionReturns.

Annotations
@Override