Search in sources :

Example 1 with EagerCollectionFetch

use of org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch in project hibernate-orm by hibernate.

the class PluralAttributeMappingImpl method generateFetch.

@Override
public Fetch generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState) {
    final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
    final boolean added = creationState.registerVisitedAssociationKey(fkDescriptor.getAssociationKey());
    try {
        if (fetchTiming == FetchTiming.IMMEDIATE) {
            if (selected) {
                final TableGroup collectionTableGroup = resolveCollectionTableGroup(fetchParent, fetchablePath, creationState, sqlAstCreationState);
                return new EagerCollectionFetch(fetchablePath, this, collectionTableGroup, fetchParent, creationState);
            } else {
                return createSelectEagerCollectionFetch(fetchParent, fetchablePath, creationState, sqlAstCreationState);
            }
        }
        if (getCollectionDescriptor().getCollectionType().hasHolder()) {
            return createSelectEagerCollectionFetch(fetchParent, fetchablePath, creationState, sqlAstCreationState);
        }
        return createDelayedCollectionFetch(fetchParent, fetchablePath, creationState, sqlAstCreationState);
    } finally {
        // and on top of this, we are not handling circular fetches for plural attributes yet
        if (added) {
            creationState.removeVisitedAssociationKey(fkDescriptor.getAssociationKey());
        }
    }
}
Also used : CollectionTableGroup(org.hibernate.sql.ast.tree.from.CollectionTableGroup) OneToManyTableGroup(org.hibernate.sql.ast.tree.from.OneToManyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) SelectEagerCollectionFetch(org.hibernate.sql.results.graph.collection.internal.SelectEagerCollectionFetch) EagerCollectionFetch(org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch)

Example 2 with EagerCollectionFetch

use of org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch in project hibernate-orm by hibernate.

the class ScrollableResultsConsumer method containsCollectionFetches.

private boolean containsCollectionFetches(JdbcValuesMapping valuesMapping) {
    final List<DomainResult<?>> domainResults = valuesMapping.getDomainResults();
    for (DomainResult domainResult : domainResults) {
        if (domainResult instanceof EntityResult) {
            EntityResult entityResult = (EntityResult) domainResult;
            final List<Fetch> fetches = entityResult.getFetches();
            for (Fetch fetch : fetches) {
                if (fetch instanceof EagerCollectionFetch) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Fetch(org.hibernate.sql.results.graph.Fetch) EagerCollectionFetch(org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch) DomainResult(org.hibernate.sql.results.graph.DomainResult) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) EagerCollectionFetch(org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch)

Aggregations

EagerCollectionFetch (org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch)2 SqlAstCreationState (org.hibernate.sql.ast.spi.SqlAstCreationState)1 CollectionTableGroup (org.hibernate.sql.ast.tree.from.CollectionTableGroup)1 OneToManyTableGroup (org.hibernate.sql.ast.tree.from.OneToManyTableGroup)1 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)1 DomainResult (org.hibernate.sql.results.graph.DomainResult)1 Fetch (org.hibernate.sql.results.graph.Fetch)1 SelectEagerCollectionFetch (org.hibernate.sql.results.graph.collection.internal.SelectEagerCollectionFetch)1 EntityResult (org.hibernate.sql.results.graph.entity.EntityResult)1