use of org.hibernate.query.results.complete.CompleteFetchBuilderEntityValuedModelPart in project hibernate-orm by hibernate.
the class FetchMementoHbmStandard method resolve.
@Override
public FetchBuilder resolve(Parent parent, Consumer<String> querySpaceConsumer, ResultSetMappingResolutionContext context) {
final Map<String, FetchBuilder> fetchBuilderMap = new HashMap<>();
fetchMementoMap.forEach((attrName, fetchMemento) -> fetchBuilderMap.put(attrName, fetchMemento.resolve(this, querySpaceConsumer, context)));
final DynamicResultBuilderEntityStandard resultBuilder;
if (fetchable instanceof PluralAttributeMapping) {
resultBuilder = new DynamicResultBuilderEntityStandard((EntityMappingType) ((PluralAttributeMapping) fetchable).getElementDescriptor().getPartMappingType(), tableAlias, navigablePath);
FetchBuilder element = fetchBuilderMap.get("element");
if (element != null) {
if (element instanceof DynamicFetchBuilder) {
resultBuilder.addIdColumnAliases(((DynamicFetchBuilder) element).getColumnAliases().toArray(new String[0]));
} else {
resultBuilder.addIdColumnAliases(((CompleteFetchBuilderEntityValuedModelPart) element).getColumnAliases().toArray(new String[0]));
}
}
FetchBuilder index = fetchBuilderMap.get("index");
if (index != null) {
resultBuilder.addFetchBuilder(CollectionPart.Nature.INDEX.getName(), index);
}
for (Map.Entry<String, FetchBuilder> entry : fetchBuilderMap.entrySet()) {
if (entry.getKey().startsWith(ELEMENT_PREFIX)) {
resultBuilder.addFetchBuilder(entry.getKey().substring(ELEMENT_PREFIX.length()), entry.getValue());
}
}
} else {
resultBuilder = new DynamicResultBuilderEntityStandard(((ToOneAttributeMapping) fetchable).getEntityMappingType(), tableAlias, navigablePath);
fetchBuilderMap.forEach(resultBuilder::addFetchBuilder);
}
return new DynamicFetchBuilderLegacy(tableAlias, ownerTableAlias, fetchable.getFetchableName(), keyColumnNames, fetchBuilderMap, resultBuilder);
}
Aggregations