Search in sources :

Example 1 with CompositeFetch

use of org.hibernate.loader.plan.spi.CompositeFetch in project hibernate-orm by hibernate.

the class ReturnGraphTreePrinter method writeCollectionReferenceFetches.

private void writeCollectionReferenceFetches(CollectionReference collectionReference, int depth, PrintWriter printWriter) {
    final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph();
    if (indexGraph != null) {
        printWriter.print(TreePrinterHelper.INSTANCE.generateNodePrefix(depth) + "(collection index) ");
        if (EntityReference.class.isInstance(indexGraph)) {
            final EntityReference indexGraphAsEntityReference = (EntityReference) indexGraph;
            printWriter.println(extractDetails(indexGraphAsEntityReference));
            writeEntityReferenceFetches(indexGraphAsEntityReference, depth + 1, printWriter);
        } else if (CompositeFetch.class.isInstance(indexGraph)) {
            final CompositeFetch indexGraphAsCompositeFetch = (CompositeFetch) indexGraph;
            printWriter.println(extractDetails(indexGraphAsCompositeFetch));
            writeCompositeFetchFetches(indexGraphAsCompositeFetch, depth + 1, printWriter);
        }
    }
    final CollectionFetchableElement elementGraph = collectionReference.getElementGraph();
    if (elementGraph != null) {
        printWriter.print(TreePrinterHelper.INSTANCE.generateNodePrefix(depth) + "(collection element) ");
        if (EntityReference.class.isInstance(elementGraph)) {
            final EntityReference elementGraphAsEntityReference = (EntityReference) elementGraph;
            printWriter.println(extractDetails(elementGraphAsEntityReference));
            writeEntityReferenceFetches(elementGraphAsEntityReference, depth + 1, printWriter);
        } else if (CompositeFetch.class.isInstance(elementGraph)) {
            final CompositeFetch elementGraphAsCompositeFetch = (CompositeFetch) elementGraph;
            printWriter.println(extractDetails(elementGraphAsCompositeFetch));
            writeCompositeFetchFetches(elementGraphAsCompositeFetch, depth + 1, printWriter);
        }
    }
}
Also used : CollectionFetchableElement(org.hibernate.loader.plan.spi.CollectionFetchableElement) CompositeFetch(org.hibernate.loader.plan.spi.CompositeFetch) EntityReference(org.hibernate.loader.plan.spi.EntityReference) BidirectionalEntityReference(org.hibernate.loader.plan.spi.BidirectionalEntityReference) CollectionFetchableIndex(org.hibernate.loader.plan.spi.CollectionFetchableIndex)

Example 2 with CompositeFetch

use of org.hibernate.loader.plan.spi.CompositeFetch in project hibernate-orm by hibernate.

the class AbstractRowReader method resolveEntityKey.

private void resolveEntityKey(ResultSet resultSet, ResultSetProcessingContextImpl context, FetchSource fetchSource) throws SQLException {
    // Resolve any bidirectional entity references first.
    for (BidirectionalEntityReference bidirectionalEntityReference : fetchSource.getBidirectionalEntityReferences()) {
        final EntityReferenceInitializer targetEntityReferenceInitializer = entityInitializerByEntityReference.get(bidirectionalEntityReference.getTargetEntityReference());
        resolveEntityKey(resultSet, context, targetEntityReferenceInitializer);
        targetEntityReferenceInitializer.hydrateEntityState(resultSet, context);
    }
    for (Fetch fetch : fetchSource.getFetches()) {
        if (EntityFetch.class.isInstance(fetch)) {
            final EntityFetch entityFetch = (EntityFetch) fetch;
            final EntityReferenceInitializer entityReferenceInitializer = entityInitializerByEntityReference.get(entityFetch);
            if (entityReferenceInitializer != null) {
                resolveEntityKey(resultSet, context, entityReferenceInitializer);
                entityReferenceInitializer.hydrateEntityState(resultSet, context);
            }
        } else if (CompositeFetch.class.isInstance(fetch)) {
            resolveEntityKey(resultSet, context, (CompositeFetch) fetch);
        }
    }
}
Also used : CompositeFetch(org.hibernate.loader.plan.spi.CompositeFetch) Fetch(org.hibernate.loader.plan.spi.Fetch) EntityFetch(org.hibernate.loader.plan.spi.EntityFetch) EntityFetch(org.hibernate.loader.plan.spi.EntityFetch) CompositeFetch(org.hibernate.loader.plan.spi.CompositeFetch) BidirectionalEntityReference(org.hibernate.loader.plan.spi.BidirectionalEntityReference) EntityReferenceInitializer(org.hibernate.loader.plan.exec.process.spi.EntityReferenceInitializer)

Example 3 with CompositeFetch

use of org.hibernate.loader.plan.spi.CompositeFetch in project hibernate-orm by hibernate.

the class ReturnGraphTreePrinter method writeFetch.

private void writeFetch(Fetch fetch, int depth, PrintWriter printWriter) {
    printWriter.print(TreePrinterHelper.INSTANCE.generateNodePrefix(depth));
    if (EntityFetch.class.isInstance(fetch)) {
        final EntityFetch entityFetch = (EntityFetch) fetch;
        printWriter.println(extractDetails(entityFetch));
        writeEntityReferenceFetches(entityFetch, depth + 1, printWriter);
    } else if (CompositeFetch.class.isInstance(fetch)) {
        final CompositeFetch compositeFetch = (CompositeFetch) fetch;
        printWriter.println(extractDetails(compositeFetch));
        writeCompositeFetchFetches(compositeFetch, depth + 1, printWriter);
    } else if (CollectionAttributeFetch.class.isInstance(fetch)) {
        final CollectionAttributeFetch collectionFetch = (CollectionAttributeFetch) fetch;
        printWriter.println(extractDetails(collectionFetch));
        writeCollectionReferenceFetches(collectionFetch, depth + 1, printWriter);
    }
}
Also used : EntityFetch(org.hibernate.loader.plan.spi.EntityFetch) CollectionAttributeFetch(org.hibernate.loader.plan.spi.CollectionAttributeFetch) CompositeFetch(org.hibernate.loader.plan.spi.CompositeFetch)

Example 4 with CompositeFetch

use of org.hibernate.loader.plan.spi.CompositeFetch in project hibernate-orm by hibernate.

the class AbstractLoadPlanBuildingAssociationVisitationStrategy method handleCompositeAttribute.

protected boolean handleCompositeAttribute(AttributeDefinition attributeDefinition) {
    final CompositeFetch compositeFetch = currentSource().buildCompositeAttributeFetch(attributeDefinition);
    pushToStack((ExpandingFetchSource) compositeFetch);
    return true;
}
Also used : CompositeFetch(org.hibernate.loader.plan.spi.CompositeFetch)

Aggregations

CompositeFetch (org.hibernate.loader.plan.spi.CompositeFetch)4 BidirectionalEntityReference (org.hibernate.loader.plan.spi.BidirectionalEntityReference)2 EntityFetch (org.hibernate.loader.plan.spi.EntityFetch)2 EntityReferenceInitializer (org.hibernate.loader.plan.exec.process.spi.EntityReferenceInitializer)1 CollectionAttributeFetch (org.hibernate.loader.plan.spi.CollectionAttributeFetch)1 CollectionFetchableElement (org.hibernate.loader.plan.spi.CollectionFetchableElement)1 CollectionFetchableIndex (org.hibernate.loader.plan.spi.CollectionFetchableIndex)1 EntityReference (org.hibernate.loader.plan.spi.EntityReference)1 Fetch (org.hibernate.loader.plan.spi.Fetch)1