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