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