Search in sources :

Example 1 with CollectionFetchableIndex

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

the class AbstractLoadPlanBuildingAssociationVisitationStrategy method startingCollectionIndex.

@Override
public void startingCollectionIndex(CollectionIndexDefinition indexDefinition) {
    final Type indexType = indexDefinition.getType();
    log.tracef("%s Starting collection index graph : %s", StringHelper.repeat(">>", fetchSourceStack.size()), indexDefinition.getCollectionDefinition().getCollectionPersister().getRole());
    final CollectionReference collectionReference = currentCollection();
    final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph();
    if (indexType.isEntityType() || indexType.isComponentType()) {
        if (indexGraph == null) {
            throw new WalkingException("CollectionReference did not return an expected index graph : " + indexDefinition.getCollectionDefinition().getCollectionPersister().getRole());
        }
        if (!indexType.isAnyType()) {
            pushToStack((ExpandingFetchSource) indexGraph);
        }
    } else {
        if (indexGraph != null) {
            throw new WalkingException("CollectionReference returned an unexpected index graph : " + indexDefinition.getCollectionDefinition().getCollectionPersister().getRole());
        }
    }
}
Also used : Type(org.hibernate.type.Type) CollectionFetchableIndex(org.hibernate.loader.plan.spi.CollectionFetchableIndex) WalkingException(org.hibernate.persister.walking.spi.WalkingException) CollectionReference(org.hibernate.loader.plan.spi.CollectionReference)

Example 2 with CollectionFetchableIndex

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

CollectionFetchableIndex (org.hibernate.loader.plan.spi.CollectionFetchableIndex)2 BidirectionalEntityReference (org.hibernate.loader.plan.spi.BidirectionalEntityReference)1 CollectionFetchableElement (org.hibernate.loader.plan.spi.CollectionFetchableElement)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 WalkingException (org.hibernate.persister.walking.spi.WalkingException)1 Type (org.hibernate.type.Type)1