Skip to content

Commit

Permalink
HHH-18847 - Organize the org.hibernate.query.results package
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Nov 19, 2024
1 parent 2c5e0ff commit 6707dee
Show file tree
Hide file tree
Showing 106 changed files with 623 additions and 771 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
*/
package org.hibernate.generator.values;

import java.util.function.BiFunction;

import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.query.results.DomainResultCreationStateImpl;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.query.results.ResultsHelper;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.query.results.internal.DomainResultCreationStateImpl;
import org.hibernate.query.results.internal.ResultsHelper;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup;
Expand All @@ -20,8 +17,8 @@
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;

import static org.hibernate.generator.values.internal.GeneratedValuesHelper.getActualGeneratedModelPart;
import static org.hibernate.query.results.ResultsHelper.impl;
import static org.hibernate.query.results.ResultsHelper.jdbcPositionToValuesArrayPosition;
import static org.hibernate.query.results.internal.ResultsHelper.impl;
import static org.hibernate.query.results.internal.ResultsHelper.jdbcPositionToValuesArrayPosition;

/**
* Simple implementation of {@link ResultBuilder} for retrieving generated basic values.
Expand Down Expand Up @@ -60,7 +57,6 @@ public ResultBuilder cacheKeyInstance() {
public BasicResult<?> buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.mutation.EntityTableMapping;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.query.results.TableGroupImpl;
import org.hibernate.query.results.internal.TableGroupImpl;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.tree.from.NamedTableReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.generator.values.GeneratedValueBasicResultBuilder;
import org.hibernate.generator.values.GeneratedValuesMutationDelegate;
import org.hibernate.query.results.DomainResultCreationStateImpl;
import org.hibernate.query.results.JdbcValuesMappingImpl;
import org.hibernate.query.results.internal.DomainResultCreationStateImpl;
import org.hibernate.query.results.internal.JdbcValuesMappingImpl;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.results.graph.DomainResult;
Expand Down Expand Up @@ -57,7 +57,6 @@ public JdbcValuesMapping resolve(
final DomainResult<?> domainResult = resultBuilder.buildResult(
jdbcResultsMetadata,
domainResults.size(),
creationState.getLegacyFetchResolver()::resolve,
creationState
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import org.jboss.logging.Logger;

import static java.util.Collections.singletonList;
import static org.hibernate.query.results.ResultsHelper.attributeName;
import static org.hibernate.query.results.internal.ResultsHelper.attributeName;

/**
* Builder for SQL AST trees used by {@link Loader} implementations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
*/
package org.hibernate.procedure.internal;

import java.util.function.BiFunction;

import org.hibernate.LockMode;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.results.BasicValuedFetchBuilder;
import org.hibernate.query.results.FetchBuilderBasicValued;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.query.results.complete.EntityResultImpl;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.query.results.implicit.ImplicitFetchBuilderBasic;
import org.hibernate.query.results.internal.complete.EntityResultImpl;
import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderBasic;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.entity.EntityResult;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;
Expand All @@ -26,7 +23,7 @@ public class EntityDomainResultBuilder implements ResultBuilder {

private final NavigablePath navigablePath;
private final EntityMappingType entityDescriptor;
private final BasicValuedFetchBuilder discriminatorFetchBuilder;
private final FetchBuilderBasicValued discriminatorFetchBuilder;

public EntityDomainResultBuilder(EntityMappingType entityDescriptor) {
this.entityDescriptor = entityDescriptor;
Expand Down Expand Up @@ -57,7 +54,6 @@ public ResultBuilder cacheKeyInstance() {
public EntityResult buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {

return new EntityResultImpl(
Expand All @@ -73,7 +69,6 @@ public EntityResult buildResult(
entityResult,
navigablePath.append( EntityDiscriminatorMapping.DISCRIMINATOR_ROLE_NAME ),
jdbcResultsMetadata,
legacyFetchResolver,
domainResultCreationState
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
*/
package org.hibernate.procedure.internal;

import java.util.function.BiFunction;

import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.query.results.ResultSetMappingSqlSelection;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.query.results.internal.ResultSetMappingSqlSelection;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.results.graph.DomainResult;
Expand Down Expand Up @@ -38,7 +35,6 @@ public Class<?> getJavaType() {
public DomainResult<T> buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final SqlExpressionResolver sqlExpressionResolver = domainResultCreationState.getSqlAstCreationState()
.getSqlExpressionResolver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
*/
package org.hibernate.query;

import java.time.Instant;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Map;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.CacheRetrieveMode;
import jakarta.persistence.CacheStoreMode;
Expand All @@ -18,7 +12,6 @@
import jakarta.persistence.Parameter;
import jakarta.persistence.TemporalType;
import jakarta.persistence.metamodel.SingularAttribute;

import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.LockMode;
Expand All @@ -31,6 +24,12 @@
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.BasicTypeReference;

import java.time.Instant;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Map;

/**
* Within the context of an active {@linkplain org.hibernate.Session session},
* an instance of this type represents an executable query written in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.FetchMementoBasic;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.complete.CompleteFetchBuilderBasicPart;
import org.hibernate.query.results.internal.complete.CompleteFetchBuilderBasicPart;

/**
* Memento describing a basic-valued fetch. A basic-value cannot be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.query.named.FetchMemento;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.complete.CompleteFetchBuilderEmbeddableValuedModelPart;
import org.hibernate.query.results.internal.complete.CompleteFetchBuilderEmbeddableValuedModelPart;
import org.hibernate.spi.NavigablePath;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.FetchMemento;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.complete.CompleteFetchBuilderEntityValuedModelPart;
import org.hibernate.query.results.internal.complete.CompleteFetchBuilderEntityValuedModelPart;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
import org.hibernate.query.results.complete.CompleteFetchBuilderEntityValuedModelPart;
import org.hibernate.query.results.dynamic.DynamicFetchBuilder;
import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityStandard;
import org.hibernate.query.results.internal.complete.CompleteFetchBuilderEntityValuedModelPart;
import org.hibernate.query.results.internal.dynamic.DynamicFetchBuilder;
import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityStandard;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.FetchMemento;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.query.results.internal.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.FetchableContainer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.FetchMemento;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.ImplicitAttributeFetchBuilder;
import org.hibernate.query.results.internal.implicit.ImplicitAttributeFetchBuilder;

/**
* @author Steve Ebersole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.ModelPartResultMemento;
import org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderBasic;
import org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderEmbeddable;
import org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderEntity;
import org.hibernate.query.results.internal.implicit.ImplicitModelPartResultBuilderBasic;
import org.hibernate.query.results.internal.implicit.ImplicitModelPartResultBuilderEmbeddable;
import org.hibernate.query.results.internal.implicit.ImplicitModelPartResultBuilderEntity;
import org.hibernate.query.results.ResultBuilder;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.ModelPartResultMementoBasic;
import org.hibernate.query.results.ResultBuilderBasicValued;
import org.hibernate.query.results.complete.CompleteResultBuilderBasicModelPart;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderBasicModelPart;

/**
* @author Steve Ebersole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.query.named.ResultMementoBasic;
import org.hibernate.query.results.ResultBuilderBasicValued;
import org.hibernate.query.results.complete.CompleteResultBuilderBasicValuedConverted;
import org.hibernate.query.results.complete.CompleteResultBuilderBasicValuedStandard;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderBasicValuedConverted;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderBasicValuedStandard;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.type.BasicType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.named.ModelPartResultMementoCollection;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.query.results.complete.CompleteResultBuilderCollectionStandard;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderCollectionStandard;

/**
* @author Steve Ebersole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import org.hibernate.query.named.FetchMemento;
import org.hibernate.query.named.FetchMementoBasic;
import org.hibernate.query.named.ResultMementoEntity;
import org.hibernate.query.results.BasicValuedFetchBuilder;
import org.hibernate.query.results.FetchBuilderBasicValued;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.ResultBuilderEntityValued;
import org.hibernate.query.results.complete.CompleteResultBuilderEntityJpa;
import org.hibernate.query.results.complete.DelayedFetchBuilderBasicPart;
import org.hibernate.query.results.implicit.ImplicitFetchBuilderBasic;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderEntityJpa;
import org.hibernate.query.results.internal.complete.DelayedFetchBuilderBasicPart;
import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderBasic;
import org.hibernate.spi.NavigablePath;

/**
Expand Down Expand Up @@ -56,14 +56,14 @@ public ResultBuilderEntityValued resolve(
Consumer<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {
final EntityDiscriminatorMapping discriminatorMapping = entityDescriptor.getDiscriminatorMapping();
final BasicValuedFetchBuilder discriminatorFetchBuilder;
final FetchBuilderBasicValued discriminatorFetchBuilder;
if ( discriminatorMapping == null || !entityDescriptor.hasSubclasses() ) {
assert discriminatorMemento == null;
discriminatorFetchBuilder = null;
}
else {
if ( discriminatorMemento != null ) {
discriminatorFetchBuilder = (BasicValuedFetchBuilder) discriminatorMemento.resolve( this, querySpaceConsumer, context );
discriminatorFetchBuilder = (FetchBuilderBasicValued) discriminatorMemento.resolve( this, querySpaceConsumer, context );
}
else {
discriminatorFetchBuilder = new ImplicitFetchBuilderBasic( navigablePath, discriminatorMapping );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import org.hibernate.query.named.FetchMemento;
import org.hibernate.query.named.FetchMementoBasic;
import org.hibernate.query.named.ResultMementoEntity;
import org.hibernate.query.results.BasicValuedFetchBuilder;
import org.hibernate.query.results.FetchBuilderBasicValued;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.ResultBuilderEntityValued;
import org.hibernate.query.results.complete.CompleteResultBuilderEntityStandard;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderEntityStandard;

/**
* @author Steve Ebersole
Expand Down Expand Up @@ -60,8 +60,8 @@ public ResultBuilderEntityValued resolve(
Consumer<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {

final BasicValuedFetchBuilder discriminatorResultBuilder = discriminatorMemento != null
? (BasicValuedFetchBuilder) discriminatorMemento.resolve( this, querySpaceConsumer, context )
final FetchBuilderBasicValued discriminatorResultBuilder = discriminatorMemento != null
? (FetchBuilderBasicValued) discriminatorMemento.resolve( this, querySpaceConsumer, context )
: null;

final HashMap<String, FetchBuilder> fetchBuilderMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.query.named.ResultMementoInstantiation;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.query.results.complete.CompleteResultBuilderInstantiation;
import org.hibernate.query.results.internal.complete.CompleteResultBuilderInstantiation;
import org.hibernate.type.descriptor.java.JavaType;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@
*/
package org.hibernate.query.results;

import java.util.function.BiConsumer;
import java.util.function.BiFunction;

import org.hibernate.Incubating;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;

import java.util.function.BiConsumer;

/**
* Responsible for building a single {@link DomainResult} instance as part of
* the overall mapping of native / procedure query results.
* Responsible for building a single {@link Fetch} instance.
* Given the following HQL for illustration,
* <pre>
* select b from Book b join fetch b.authors
* </pre>
* we have a single fetch : `Book(b).authors`
*
* @see ResultBuilder
*
* @apiNote By definition a fetch is a reference to the fetched ModelPart
* @author Steve Ebersole
*/
@Incubating
public interface FetchBuilder {
public interface FetchBuilder extends GraphNodeBuilder {
Fetch buildFetch(
FetchParent parent,
NavigablePath fetchPath,
JdbcValuesMetadata jdbcResultsMetadata,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);

default void visitFetchBuilders(BiConsumer<String, FetchBuilder> consumer) {
Expand Down
Loading

0 comments on commit 6707dee

Please sign in to comment.