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());
}
}
}
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;
}
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());
}
}
}
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();
}
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());
}
Aggregations