Search in sources :

Example 1 with CollectionFetchableElement

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

the class AbstractLoadPlanBuildingAssociationVisitationStrategy method startingCollectionElements.

@Override
public void startingCollectionElements(CollectionElementDefinition elementDefinition) {
    final Type elementType = elementDefinition.getType();
    log.tracef("%s Starting collection element graph : %s", StringHelper.repeat(">>", fetchSourceStack.size()), elementDefinition.getCollectionDefinition().getCollectionPersister().getRole());
    final CollectionReference collectionReference = currentCollection();
    final CollectionFetchableElement elementGraph = collectionReference.getElementGraph();
    if (elementType.isAssociationType() || elementType.isComponentType()) {
        if (elementGraph == null) {
            throw new IllegalStateException("CollectionReference did not return an expected element graph : " + elementDefinition.getCollectionDefinition().getCollectionPersister().getRole());
        }
        if (!elementType.isAnyType()) {
            pushToStack((ExpandingFetchSource) elementGraph);
        }
    } else {
        if (elementGraph != null) {
            throw new IllegalStateException("CollectionReference returned an unexpected element graph : " + elementDefinition.getCollectionDefinition().getCollectionPersister().getRole());
        }
    }
}
Also used : CollectionFetchableElement(org.hibernate.loader.plan.spi.CollectionFetchableElement) Type(org.hibernate.type.Type) CollectionReference(org.hibernate.loader.plan.spi.CollectionReference)

Example 2 with CollectionFetchableElement

use of org.hibernate.loader.plan.spi.CollectionFetchableElement 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)

Aggregations

CollectionFetchableElement (org.hibernate.loader.plan.spi.CollectionFetchableElement)2 BidirectionalEntityReference (org.hibernate.loader.plan.spi.BidirectionalEntityReference)1 CollectionFetchableIndex (org.hibernate.loader.plan.spi.CollectionFetchableIndex)1 CollectionReference (org.hibernate.loader.plan.spi.CollectionReference)1 CompositeFetch (org.hibernate.loader.plan.spi.CompositeFetch)1 EntityReference (org.hibernate.loader.plan.spi.EntityReference)1 Type (org.hibernate.type.Type)1