Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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 .
*/
package org.hibernate.loader.plan.build.internal;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.AttributeNode;
import javax.persistence.Subgraph;
import javax.persistence.metamodel.Attribute;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.graph.spi.AttributeNodeImplementor;
import org.hibernate.graph.spi.GraphNodeImplementor;
import org.hibernate.internal.CoreLogging;
import org.hibernate.loader.plan.spi.EntityReturn;
import org.hibernate.loader.plan.spi.LoadPlan;
import org.hibernate.loader.plan.spi.Return;
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.CollectionElementDefinition;
import org.hibernate.persister.walking.spi.CollectionIndexDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.persister.walking.spi.WalkingException;
import 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):
*
* entity metadata and its associations
* entity graph and attribute nodes
*
*
* 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.
*
* @author Strong Liu
* @author Brett Meyer
*/
public abstract class AbstractEntityGraphVisitationStrategy
extends AbstractLoadPlanBuildingAssociationVisitationStrategy {
private static final Logger LOG = CoreLogging.logger( AbstractEntityGraphVisitationStrategy.class );
/**
* 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
*/
protected static final FetchStrategy DEFAULT_EAGER = new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.JOIN );
protected static final FetchStrategy DEFAULT_LAZY = new FetchStrategy( FetchTiming.DELAYED, FetchStyle.SELECT );
protected final LoadQueryInfluencers loadQueryInfluencers;
// Queue containing entity/sub graphs to be visited.
private final ArrayDeque graphStack = new ArrayDeque();
// Queue containing attributes being visited, used eventually to determine the fetch strategy.
private final ArrayDeque attributeStack = new ArrayDeque();
// Queue of maps containing the current graph node's attributes. Used for fast lookup, instead of iterating
// over graphStack.peekLast().attributeImplementorNodes().
private final ArrayDeque