Search in sources :

Example 1 with CollectionReference

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

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

the class AbstractLoadPlanBuildingAssociationVisitationStrategy method popFromCollectionStack.

private CollectionReference popFromCollectionStack() {
    final CollectionReference last = collectionReferenceStack.removeFirst();
    log.trace("Popped collection reference from stack : " + last);
    propertyPathStack.pop();
    return last;
}
Also used : CollectionReference(org.hibernate.loader.plan.spi.CollectionReference)

Example 3 with CollectionReference

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

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

the class ReturnGraphTreePrinter method write.

public void write(Return rootReturn, int depth, PrintWriter printWriter) {
    if (rootReturn == null) {
        printWriter.println("Return is null!");
        return;
    }
    printWriter.write(TreePrinterHelper.INSTANCE.generateNodePrefix(depth));
    if (ScalarReturn.class.isInstance(rootReturn)) {
        printWriter.println(extractDetails((ScalarReturn) rootReturn));
    } else if (EntityReturn.class.isInstance(rootReturn)) {
        final EntityReturn entityReturn = (EntityReturn) rootReturn;
        printWriter.println(extractDetails(entityReturn));
        writeEntityReferenceFetches(entityReturn, depth + 1, printWriter);
    } else if (CollectionReference.class.isInstance(rootReturn)) {
        final CollectionReference collectionReference = (CollectionReference) rootReturn;
        printWriter.println(extractDetails(collectionReference));
        writeCollectionReferenceFetches(collectionReference, depth + 1, printWriter);
    }
    printWriter.flush();
}
Also used : ScalarReturn(org.hibernate.loader.plan.spi.ScalarReturn) CollectionReference(org.hibernate.loader.plan.spi.CollectionReference) EntityReturn(org.hibernate.loader.plan.spi.EntityReturn)

Example 5 with CollectionReference

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

the class AbstractLoadPlanBuildingAssociationVisitationStrategy method finishingCollection.

@Override
public void finishingCollection(CollectionDefinition collectionDefinition) {
    final boolean isRoot = fetchSourceStack.isEmpty() && collectionReferenceStack.size() == 1;
    if (!isRoot) {
        // if not, this call should represent a fetch which will be handled in #finishingAttribute
        return;
    }
    final CollectionReference popped = popFromCollectionStack();
    checkedPoppedCollection(popped, collectionDefinition);
    log.tracef("%s Finished root collection : %s", StringHelper.repeat("<<", fetchSourceStack.size()), collectionDefinition.getCollectionPersister().getRole());
}
Also used : CollectionReference(org.hibernate.loader.plan.spi.CollectionReference)

Aggregations

CollectionReference (org.hibernate.loader.plan.spi.CollectionReference)6 Type (org.hibernate.type.Type)3 WalkingException (org.hibernate.persister.walking.spi.WalkingException)2 ExpandingFetchSource (org.hibernate.loader.plan.build.spi.ExpandingFetchSource)1 AttributeFetch (org.hibernate.loader.plan.spi.AttributeFetch)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 CompositeAttributeFetch (org.hibernate.loader.plan.spi.CompositeAttributeFetch)1 EntityReturn (org.hibernate.loader.plan.spi.EntityReturn)1 ScalarReturn (org.hibernate.loader.plan.spi.ScalarReturn)1 AssociationAttributeDefinition (org.hibernate.persister.walking.spi.AssociationAttributeDefinition)1