use of org.hibernate.engine.FetchStrategy in project hibernate-orm by hibernate.
the class AbstractLoadPlanBuildingAssociationVisitationStrategy method handleAssociationAttribute.
protected boolean handleAssociationAttribute(AssociationAttributeDefinition attributeDefinition) {
// todo : this seems to not be correct for one-to-one
final FetchStrategy fetchStrategy = determineFetchStrategy(attributeDefinition);
final ExpandingFetchSource currentSource = currentSource();
currentSource.validateFetchPlan(fetchStrategy, attributeDefinition);
final AssociationAttributeDefinition.AssociationNature nature = attributeDefinition.getAssociationNature();
if (nature == AssociationAttributeDefinition.AssociationNature.ANY) {
// for ANY mappings we need to build a Fetch:
// 1) fetch type is SELECT
// 2) (because the fetch cannot be a JOIN...) do not push it to the stack
// regardless of the fetch style, build the fetch
currentSource.buildAnyAttributeFetch(attributeDefinition, fetchStrategy);
return false;
} else if (nature == AssociationAttributeDefinition.AssociationNature.ENTITY) {
// regardless of the fetch style, build the fetch
EntityFetch fetch = currentSource.buildEntityAttributeFetch(attributeDefinition, fetchStrategy);
if (FetchStrategyHelper.isJoinFetched(fetchStrategy)) {
// only push to the stack if join fetched
pushToStack((ExpandingFetchSource) fetch);
return true;
} else {
return false;
}
} else {
// Collection
// regardless of the fetch style, build the fetch
CollectionAttributeFetch fetch = currentSource.buildCollectionAttributeFetch(attributeDefinition, fetchStrategy);
if (FetchStrategyHelper.isJoinFetched(fetchStrategy)) {
// only push to the stack if join fetched
pushToCollectionStack(fetch);
return true;
} else {
return false;
}
}
}
Aggregations