use of org.hibernate.graph.spi.GraphImplementor in project hibernate-orm by hibernate.
the class StandardEntityGraphTraversalStateImpl method traverse.
@Override
public TraversalResult traverse(FetchParent fetchParent, Fetchable fetchable, boolean exploreKeySubgraph) {
assert !(fetchable instanceof CollectionPart);
final GraphImplementor previousContextRoot = currentGraphContext;
AttributeNodeImplementor attributeNode = null;
if (appliesTo(fetchParent)) {
attributeNode = currentGraphContext.findAttributeNode(fetchable.getFetchableName());
}
currentGraphContext = null;
FetchTiming fetchTiming = null;
boolean joined = false;
if (attributeNode != null) {
fetchTiming = FetchTiming.IMMEDIATE;
joined = true;
final Map<Class<?>, SubGraphImplementor> subgraphMap;
final Class<?> subgraphMapKey;
if (fetchable instanceof PluralAttributeMapping) {
PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) fetchable;
assert exploreKeySubgraph && isJpaMapCollectionType(pluralAttributeMapping) || !exploreKeySubgraph && !isJpaMapCollectionType(pluralAttributeMapping);
if (exploreKeySubgraph) {
subgraphMap = attributeNode.getKeySubGraphMap();
subgraphMapKey = getEntityCollectionPartJavaClass(pluralAttributeMapping.getIndexDescriptor());
} else {
subgraphMap = attributeNode.getSubGraphMap();
subgraphMapKey = getEntityCollectionPartJavaClass(pluralAttributeMapping.getElementDescriptor());
}
} else {
assert !exploreKeySubgraph;
subgraphMap = attributeNode.getSubGraphMap();
subgraphMapKey = fetchable.getJavaType().getJavaTypeClass();
}
if (subgraphMap != null && subgraphMapKey != null) {
currentGraphContext = subgraphMap.get(subgraphMapKey);
}
}
if (fetchTiming == null) {
if (graphSemantic == GraphSemantic.FETCH) {
fetchTiming = FetchTiming.DELAYED;
joined = false;
} else {
fetchTiming = fetchable.getMappedFetchOptions().getTiming();
joined = fetchable.getMappedFetchOptions().getStyle() == FetchStyle.JOIN;
}
}
return new TraversalResult(previousContextRoot, fetchTiming, joined);
}
Aggregations