use of org.hibernate.query.results.BasicValuedFetchBuilder in project hibernate-orm by hibernate.
the class ResultMementoEntityJpa method resolve.
@Override
public ResultBuilderEntityValued resolve(Consumer<String> querySpaceConsumer, ResultSetMappingResolutionContext context) {
final EntityDiscriminatorMapping discriminatorMapping = entityDescriptor.getDiscriminatorMapping();
final BasicValuedFetchBuilder discriminatorFetchBuilder;
if (discriminatorMapping == null) {
assert discriminatorMemento == null;
discriminatorFetchBuilder = null;
} else {
if (discriminatorMemento != null) {
discriminatorFetchBuilder = (BasicValuedFetchBuilder) discriminatorMemento.resolve(this, querySpaceConsumer, context);
} else {
discriminatorFetchBuilder = new ImplicitFetchBuilderBasic(navigablePath, discriminatorMapping);
}
}
final HashMap<String, FetchBuilder> explicitFetchBuilderMap = new HashMap<>();
// If there are no explicit fetches, we don't register DELAYED builders to get implicit fetching of all basic fetchables
if (!explicitFetchMementoMap.isEmpty()) {
explicitFetchMementoMap.forEach((relativePath, fetchMemento) -> explicitFetchBuilderMap.put(relativePath, fetchMemento.resolve(this, querySpaceConsumer, context)));
final boolean isEnhancedForLazyLoading = entityDescriptor.getRepresentationStrategy().isBytecodeEnhanced();
// Implicit basic fetches are DELAYED by default, so register fetch builders for the remaining basic fetchables
entityDescriptor.visitAttributeMappings(attributeMapping -> {
final Function<String, FetchBuilder> fetchBuilderCreator;
if (attributeMapping instanceof BasicValuedModelPart) {
fetchBuilderCreator = k -> new DelayedFetchBuilderBasicPart(navigablePath.append(k), (BasicValuedModelPart) attributeMapping, isEnhancedForLazyLoading);
explicitFetchBuilderMap.computeIfAbsent(attributeMapping.getFetchableName(), fetchBuilderCreator);
}
});
}
return new CompleteResultBuilderEntityJpa(navigablePath, entityDescriptor, lockMode, discriminatorFetchBuilder, explicitFetchBuilderMap);
}
use of org.hibernate.query.results.BasicValuedFetchBuilder in project hibernate-orm by hibernate.
the class ResultMementoEntityStandard method resolve.
@Override
public ResultBuilderEntityValued resolve(Consumer<String> querySpaceConsumer, ResultSetMappingResolutionContext context) {
final BasicValuedFetchBuilder discriminatorResultBuilder = discriminatorMemento != null ? (BasicValuedFetchBuilder) discriminatorMemento.resolve(this, querySpaceConsumer, context) : null;
final HashMap<String, FetchBuilder> fetchBuilderMap = new HashMap<>();
fetchMementoMap.forEach((attrName, fetchMemento) -> fetchBuilderMap.put(attrName, fetchMemento.resolve(this, querySpaceConsumer, context)));
return new CompleteResultBuilderEntityStandard(tableAlias, navigablePath, entityDescriptor, lockMode, discriminatorResultBuilder, fetchBuilderMap);
}
Aggregations