From 6707dee0a636b0e516bca0c461ffb39bf0bd4bfa Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 14 Nov 2024 13:37:58 -0600 Subject: [PATCH] HHH-18847 - Organize the org.hibernate.query.results package --- .../GeneratedValueBasicResultBuilder.java | 12 +- .../internal/GeneratedValuesHelper.java | 2 +- .../GeneratedValuesMappingProducer.java | 5 +- .../ast/internal/LoaderSelectBuilder.java | 2 +- .../internal/EntityDomainResultBuilder.java | 15 +-- .../internal/ScalarDomainResultBuilder.java | 6 +- .../java/org/hibernate/query/NativeQuery.java | 13 +- .../internal/FetchMementoBasicStandard.java | 2 +- .../FetchMementoEmbeddableStandard.java | 2 +- .../internal/FetchMementoEntityStandard.java | 2 +- .../internal/FetchMementoHbmStandard.java | 8 +- .../ImplicitAttributeFetchMemento.java | 2 +- .../ImplicitModelPartResultMemento.java | 6 +- .../ModelPartResultMementoBasicImpl.java | 2 +- .../internal/ResultMementoBasicStandard.java | 4 +- .../ResultMementoCollectionStandard.java | 2 +- .../internal/ResultMementoEntityJpa.java | 12 +- .../internal/ResultMementoEntityStandard.java | 8 +- .../ResultMementoInstantiationStandard.java | 2 +- .../hibernate/query/results/FetchBuilder.java | 21 +-- ...lder.java => FetchBuilderBasicValued.java} | 8 +- .../query/results/GraphNodeBuilder.java | 16 +++ .../query/results/LegacyFetchBuilder.java | 33 +++++ .../results/MissingSqlSelectionException.java | 6 +- ...sitionalSelectionsNotAllowedException.java | 16 --- .../query/results/ResultBuilder.java | 31 +++-- .../results/ResultBuilderBasicValued.java | 8 +- .../results/ResultBuilderEmbeddable.java | 8 +- .../results/ResultBuilderEntityValued.java | 8 +- .../ResultBuilderInstantiationValued.java | 4 +- .../query/results/ResultSetMapping.java | 47 ++++--- .../query/results/complete/package-info.java | 17 --- .../results/dynamic/LegacyFetchResolver.java | 21 --- .../results/{ => internal}/Builders.java | 41 +++--- .../DomainResultCreationStateImpl.java | 127 +++++++----------- .../{ => internal}/FromClauseAccessImpl.java | 8 +- .../{ => internal}/JdbcValuesMappingImpl.java | 15 +-- .../{ => internal}/ResultSetMappingImpl.java | 75 +++++------ .../ResultSetMappingSqlSelection.java | 13 +- .../results/{ => internal}/ResultsHelper.java | 4 +- .../{ => internal}/TableGroupImpl.java | 5 +- .../complete/CompleteFetchBuilder.java | 2 +- .../CompleteFetchBuilderBasicPart.java | 33 ++--- ...FetchBuilderEmbeddableValuedModelPart.java | 11 +- ...leteFetchBuilderEntityValuedModelPart.java | 11 +- .../complete/CompleteResultBuilder.java | 2 +- .../CompleteResultBuilderBasicModelPart.java | 14 +- .../CompleteResultBuilderBasicValued.java | 2 +- ...leteResultBuilderBasicValuedConverted.java | 21 ++- ...pleteResultBuilderBasicValuedStandard.java | 18 ++- .../CompleteResultBuilderCollection.java | 2 +- ...mpleteResultBuilderCollectionStandard.java | 17 +-- .../CompleteResultBuilderEntityJpa.java | 24 ++-- .../CompleteResultBuilderEntityStandard.java | 26 ++-- .../CompleteResultBuilderEntityValued.java | 2 +- .../CompleteResultBuilderInstantiation.java | 16 +-- .../DelayedFetchBuilderBasicPart.java | 17 +-- .../complete/EntityResultImpl.java | 2 +- .../complete/ModelPartReference.java | 2 +- .../complete/ModelPartReferenceBasic.java | 2 +- .../ModelPartReferenceCollection.java | 2 +- .../ModelPartReferenceEmbeddable.java | 2 +- .../complete/ModelPartReferenceEntity.java | 2 +- .../internal/complete/package-info.java | 13 ++ .../AbstractFetchBuilderContainer.java | 2 +- .../dynamic/DynamicFetchBuilder.java | 2 +- .../dynamic/DynamicFetchBuilderContainer.java | 2 +- .../dynamic/DynamicFetchBuilderLegacy.java | 55 ++++---- .../dynamic/DynamicFetchBuilderStandard.java | 17 +-- .../dynamic/DynamicResultBuilder.java | 2 +- .../DynamicResultBuilderAttribute.java | 16 +-- .../dynamic/DynamicResultBuilderBasic.java | 2 +- .../DynamicResultBuilderBasicConverted.java | 19 ++- .../DynamicResultBuilderBasicStandard.java | 18 ++- .../dynamic/DynamicResultBuilderEntity.java | 5 +- .../DynamicResultBuilderEntityCalculated.java | 9 +- .../DynamicResultBuilderEntityStandard.java | 29 ++-- .../DynamicResultBuilderInstantiation.java | 19 ++- .../{ => internal}/dynamic/package-info.java | 10 +- .../ImplicitAttributeFetchBuilder.java | 8 +- .../implicit/ImplicitFetchBuilder.java | 2 +- .../implicit/ImplicitFetchBuilderBasic.java | 24 ++-- ...tFetchBuilderDiscriminatedAssociation.java | 9 +- .../ImplicitFetchBuilderEmbeddable.java | 45 +++---- .../implicit/ImplicitFetchBuilderEntity.java | 44 ++---- .../ImplicitFetchBuilderEntityPart.java | 5 +- .../implicit/ImplicitFetchBuilderPlural.java | 5 +- .../ImplicitModelPartResultBuilder.java | 2 +- .../ImplicitModelPartResultBuilderBasic.java | 12 +- ...licitModelPartResultBuilderEmbeddable.java | 16 +-- .../ImplicitModelPartResultBuilderEntity.java | 12 +- .../implicit/ImplicitResultClassBuilder.java | 11 +- .../{ => internal}/implicit/package-info.java | 6 +- .../hibernate/query/results/package-info.java | 18 +-- .../query/sql/internal/NativeQueryImpl.java | 20 +-- .../internal/ResultSetMappingProcessor.java | 53 ++++---- .../query/sql/spi/NativeQueryImplementor.java | 2 +- .../internal/cte/CteInsertHandler.java | 2 +- .../internal/cte/CteUpdateHandler.java | 2 +- .../temptable/InsertExecutionDelegate.java | 2 +- .../temptable/UpdateExecutionDelegate.java | 2 +- .../graph/DomainResultCreationState.java | 2 +- ...ValuesMappingProducerProviderStandard.java | 2 +- .../orm/test/hbm/query/QueryReturnTest.java | 4 +- .../query/resultmapping/NamedRepoTests.java | 2 +- migration-guide.adoc | 5 + 106 files changed, 629 insertions(+), 777 deletions(-) rename hibernate-core/src/main/java/org/hibernate/query/results/{BasicValuedFetchBuilder.java => FetchBuilderBasicValued.java} (71%) create mode 100644 hibernate-core/src/main/java/org/hibernate/query/results/GraphNodeBuilder.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/results/LegacyFetchBuilder.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/results/PositionalSelectionsNotAllowedException.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/results/complete/package-info.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/results/dynamic/LegacyFetchResolver.java rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/Builders.java (86%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/DomainResultCreationStateImpl.java (86%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/FromClauseAccessImpl.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/JdbcValuesMappingImpl.java (87%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/ResultSetMappingImpl.java (87%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/ResultSetMappingSqlSelection.java (84%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/ResultsHelper.java (97%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/TableGroupImpl.java (90%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteFetchBuilder.java (88%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteFetchBuilderBasicPart.java (84%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteFetchBuilderEntityValuedModelPart.java (90%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilder.java (82%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderBasicModelPart.java (88%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderBasicValued.java (87%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderBasicValuedConverted.java (90%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderBasicValuedStandard.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderCollection.java (79%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderCollectionStandard.java (93%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderEntityJpa.java (90%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderEntityStandard.java (90%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderEntityValued.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/CompleteResultBuilderInstantiation.java (91%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/DelayedFetchBuilderBasicPart.java (87%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/EntityResultImpl.java (98%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/ModelPartReference.java (91%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/ModelPartReferenceBasic.java (85%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/ModelPartReferenceCollection.java (85%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/ModelPartReferenceEmbeddable.java (86%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/complete/ModelPartReferenceEntity.java (85%) create mode 100644 hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/package-info.java rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/AbstractFetchBuilderContainer.java (98%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicFetchBuilder.java (88%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicFetchBuilderContainer.java (94%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicFetchBuilderLegacy.java (90%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicFetchBuilderStandard.java (93%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilder.java (92%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderAttribute.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderBasic.java (84%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderBasicConverted.java (94%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderBasicStandard.java (95%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderEntity.java (80%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderEntityCalculated.java (94%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderEntityStandard.java (95%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/DynamicResultBuilderInstantiation.java (92%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/dynamic/package-info.java (73%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal/implicit}/ImplicitAttributeFetchBuilder.java (86%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilder.java (81%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilderBasic.java (88%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java (88%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilderEmbeddable.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilderEntity.java (85%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilderEntityPart.java (88%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitFetchBuilderPlural.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitModelPartResultBuilder.java (82%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitModelPartResultBuilderBasic.java (86%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitModelPartResultBuilderEmbeddable.java (87%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitModelPartResultBuilderEntity.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/ImplicitResultClassBuilder.java (89%) rename hibernate-core/src/main/java/org/hibernate/query/results/{ => internal}/implicit/package-info.java (83%) diff --git a/hibernate-core/src/main/java/org/hibernate/generator/values/GeneratedValueBasicResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/generator/values/GeneratedValueBasicResultBuilder.java index 776d7c20d9..7769eff23a 100644 --- a/hibernate-core/src/main/java/org/hibernate/generator/values/GeneratedValueBasicResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/generator/values/GeneratedValueBasicResultBuilder.java @@ -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; @@ -20,8 +17,8 @@ import org.hibernate.sql.results.graph.basic.BasicResult; 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. @@ -60,7 +57,6 @@ public class GeneratedValueBasicResultBuilder implements ResultBuilder { public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesHelper.java b/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesHelper.java index 2bb21a814f..6273899fac 100644 --- a/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesHelper.java @@ -31,7 +31,7 @@ import org.hibernate.metamodel.mapping.SelectableMapping; 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; diff --git a/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesMappingProducer.java b/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesMappingProducer.java index 5d6f2f5236..9a7f711ff2 100644 --- a/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesMappingProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/generator/values/internal/GeneratedValuesMappingProducer.java @@ -12,8 +12,8 @@ import org.hibernate.engine.spi.LoadQueryInfluencers; 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; @@ -57,7 +57,6 @@ public class GeneratedValuesMappingProducer implements JdbcValuesMappingProducer final DomainResult domainResult = resultBuilder.buildResult( jdbcResultsMetadata, domainResults.size(), - creationState.getLegacyFetchResolver()::resolve, creationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java index 9a4da9813b..4f54ebfa7e 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java @@ -86,7 +86,7 @@ import org.hibernate.sql.results.internal.StandardEntityGraphTraversalStateImpl; 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. diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/EntityDomainResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/EntityDomainResultBuilder.java index ed464d188d..ed528404b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/EntityDomainResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/EntityDomainResultBuilder.java @@ -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; @@ -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; @@ -57,7 +54,6 @@ public class EntityDomainResultBuilder implements ResultBuilder { public EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { return new EntityResultImpl( @@ -73,7 +69,6 @@ public class EntityDomainResultBuilder implements ResultBuilder { entityResult, navigablePath.append( EntityDiscriminatorMapping.DISCRIMINATOR_ROLE_NAME ), jdbcResultsMetadata, - legacyFetchResolver, domainResultCreationState ); }, diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultBuilder.java index e9fcadf194..8dd11343e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultBuilder.java @@ -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; @@ -38,7 +35,6 @@ public class ScalarDomainResultBuilder implements ResultBuilder { public DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final SqlExpressionResolver sqlExpressionResolver = domainResultCreationState.getSqlAstCreationState() .getSqlExpressionResolver(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java b/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java index 19b2939bf3..45037ea798 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java @@ -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; @@ -18,7 +12,6 @@ import jakarta.persistence.LockModeType; 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; @@ -31,6 +24,12 @@ import org.hibernate.spi.NavigablePath; 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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoBasicStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoBasicStandard.java index 22436c0d7d..5da807e514 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoBasicStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoBasicStandard.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.mapping.BasicValuedModelPart; 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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEmbeddableStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEmbeddableStandard.java index 2f33cd156e..392f508ab8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEmbeddableStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEmbeddableStandard.java @@ -10,7 +10,7 @@ import java.util.function.Consumer; 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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEntityStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEntityStandard.java index eb1177c561..8361da7465 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEntityStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoEntityStandard.java @@ -10,7 +10,7 @@ import java.util.function.Consumer; 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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoHbmStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoHbmStandard.java index d3b9df8f1c..c0ee765a9d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoHbmStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/FetchMementoHbmStandard.java @@ -14,13 +14,13 @@ import org.hibernate.metamodel.mapping.CollectionPart; 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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitAttributeFetchMemento.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitAttributeFetchMemento.java index fcd30ae763..c1ba8831e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitAttributeFetchMemento.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitAttributeFetchMemento.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.mapping.AttributeMapping; 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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitModelPartResultMemento.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitModelPartResultMemento.java index d74da44e1f..af4c99cb13 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitModelPartResultMemento.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ImplicitModelPartResultMemento.java @@ -12,9 +12,9 @@ import org.hibernate.metamodel.mapping.EntityValuedModelPart; 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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ModelPartResultMementoBasicImpl.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ModelPartResultMementoBasicImpl.java index 0866175bc5..51b4605d06 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ModelPartResultMementoBasicImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ModelPartResultMementoBasicImpl.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.mapping.BasicValuedModelPart; 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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoBasicStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoBasicStandard.java index ddbf3e8cd4..05db5d6669 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoBasicStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoBasicStandard.java @@ -12,8 +12,8 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; 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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoCollectionStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoCollectionStandard.java index 6e4af3e366..aa3ed466a0 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoCollectionStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoCollectionStandard.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping; 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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityJpa.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityJpa.java index 2acddfd1ae..fd3e77ba35 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityJpa.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityJpa.java @@ -16,12 +16,12 @@ import org.hibernate.metamodel.mapping.EntityMappingType; 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; /** @@ -56,14 +56,14 @@ public class ResultMementoEntityJpa implements ResultMementoEntity, FetchMemento Consumer 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 ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityStandard.java index 249d3c718c..6be6cc3463 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoEntityStandard.java @@ -15,10 +15,10 @@ import org.hibernate.query.QueryLogging; 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 @@ -60,8 +60,8 @@ public class ResultMementoEntityStandard implements ResultMementoEntity, FetchMe Consumer 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 fetchBuilderMap = new HashMap<>(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoInstantiationStandard.java b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoInstantiationStandard.java index 9f973027da..5ef8190e83 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoInstantiationStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/ResultMementoInstantiationStandard.java @@ -11,7 +11,7 @@ import java.util.function.Consumer; 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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilder.java index d65dcd580e..092cfbd74b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilder.java @@ -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, + *
+ *     select b from Book b join fetch b.authors
+ * 
+ * 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 legacyFetchResolver, DomainResultCreationState domainResultCreationState); default void visitFetchBuilders(BiConsumer consumer) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/BasicValuedFetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilderBasicValued.java similarity index 71% rename from hibernate-core/src/main/java/org/hibernate/query/results/BasicValuedFetchBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilderBasicValued.java index 2cb5548bcd..bee1586416 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/BasicValuedFetchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/FetchBuilderBasicValued.java @@ -4,24 +4,22 @@ */ package org.hibernate.query.results; -import java.util.function.BiFunction; - import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.basic.BasicFetch; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; /** + * FetchBuilder specialization for basic mappings + * * @author Steve Ebersole */ -public interface BasicValuedFetchBuilder extends FetchBuilder { +public interface FetchBuilderBasicValued extends FetchBuilder { @Override BasicFetch buildFetch( FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/GraphNodeBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/GraphNodeBuilder.java new file mode 100644 index 0000000000..005898590b --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/query/results/GraphNodeBuilder.java @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.query.results; + +/** + * Commonality between the builders for results and fetches. + * + * @see ResultBuilder + * @see FetchBuilder + * + * @author Steve Ebersole + */ +public interface GraphNodeBuilder { +} diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/LegacyFetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/LegacyFetchBuilder.java new file mode 100644 index 0000000000..c1f818b5bf --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/query/results/LegacyFetchBuilder.java @@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.query.results; + +/** + * Specialized FetchBuilder implementations which handle building fetches defined via:
    + *
  • {@code hbm.xml} definitions
  • + *
  • calls to {@link org.hibernate.query.NativeQuery#addFetch}, and friends
  • + *
+ * + * @author Steve Ebersole + */ +public interface LegacyFetchBuilder extends FetchBuilder { + /** + * The table-alias associated with the fetch modeled by this builder. + */ + String getTableAlias(); + + /** + * The alias for the node (result or fetch) which owns the fetch modeled by this builder. + */ + String getOwnerAlias(); + + /** + * The name of the model-part being fetched. + */ + String getFetchableName(); + + @Override + LegacyFetchBuilder cacheKeyInstance(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/MissingSqlSelectionException.java b/hibernate-core/src/main/java/org/hibernate/query/results/MissingSqlSelectionException.java index c25168e8c5..e4ecdc6c19 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/MissingSqlSelectionException.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/MissingSqlSelectionException.java @@ -7,10 +7,8 @@ package org.hibernate.query.results; import org.hibernate.HibernateException; /** - * Indicates that a column defined as part of a SQL ResultSet mapping was not part - * of the query's ResultSet - * - * @see ResultSetMapping + * Indicates that a column defined as part of a {@linkplain ResultSetMapping SQL ResultSet mapping} was not part + * of the query's {@linkplain java.sql.ResultSet} * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/PositionalSelectionsNotAllowedException.java b/hibernate-core/src/main/java/org/hibernate/query/results/PositionalSelectionsNotAllowedException.java deleted file mode 100644 index 13222e0add..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/results/PositionalSelectionsNotAllowedException.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.query.results; - -import org.hibernate.HibernateException; - -/** - * @author Steve Ebersole - */ -public class PositionalSelectionsNotAllowedException extends HibernateException { - public PositionalSelectionsNotAllowedException(String message) { - super( message ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilder.java index 8893ec89c6..b7f98b60bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilder.java @@ -4,29 +4,44 @@ */ package org.hibernate.query.results; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; - import org.hibernate.Incubating; -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.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 DomainResult}. + * Given the following HQL for illustration, + *
+ *     select b from Book b join fetch b.authors
+ * 
+ * we have a single result : `Book(b)` + * + * @see FetchBuilder * * @author Steve Ebersole */ @Incubating -public interface ResultBuilder { +public interface ResultBuilder extends GraphNodeBuilder { + /** + * Build a result + * + * @param jdbcResultsMetadata The JDBC values and metadata + * @param resultPosition The position in the domain results for the result to be built + * @param domainResultCreationState Access to useful stuff + */ DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState); + /** + * The Java type of the value returned for a {@linkplain DomainResult result} built by this builder. + * + * @see DomainResult#getResultJavaType() + */ Class getJavaType(); ResultBuilder cacheKeyInstance(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderBasicValued.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderBasicValued.java index 7055dc7b1d..5362dc1f7c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderBasicValued.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderBasicValued.java @@ -4,15 +4,14 @@ */ package org.hibernate.query.results; -import java.util.function.BiFunction; - -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; /** - * Nominal extension to ResultBuilder for cases involving scalar results + * ResultBuilder specialization for cases involving scalar results. + * + * @see jakarta.persistence.ColumnResult * * @author Steve Ebersole */ @@ -21,6 +20,5 @@ public interface ResultBuilderBasicValued extends ResultBuilder { BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEmbeddable.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEmbeddable.java index 7debb74ce0..dc4c58f319 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEmbeddable.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEmbeddable.java @@ -4,21 +4,19 @@ */ package org.hibernate.query.results; -import java.util.function.BiFunction; - -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.embeddable.EmbeddableResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; /** + * ResultBuilder specialization for cases involving embeddable results. + * * @author Steve Ebersole */ public interface ResultBuilderEmbeddable extends ResultBuilder { @Override - EmbeddableResult buildResult( + EmbeddableResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEntityValued.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEntityValued.java index 7c9d041c15..c4257893ca 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEntityValued.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderEntityValued.java @@ -4,15 +4,14 @@ */ package org.hibernate.query.results; -import java.util.function.BiFunction; - -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.entity.EntityResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; /** - * Specialization of ResultBuilder for building an EntityResult + * ResultBuilder specialization for cases involving entity results. + * + * @see jakarta.persistence.EntityResult * * @author Steve Ebersole */ @@ -21,6 +20,5 @@ public interface ResultBuilderEntityValued extends ResultBuilder { EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderInstantiationValued.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderInstantiationValued.java index 8f6e814129..4e18cb03f4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderInstantiationValued.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultBuilderInstantiationValued.java @@ -5,7 +5,9 @@ package org.hibernate.query.results; /** - * Nominal extension to ResultBuilder for cases involving dynamic-instantiation results + * ResultBuilder specialization for cases involving dynamic-instantiation results. + * + * @see jakarta.persistence.ConstructorResult * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java index 433d6e8cf4..7bc4975a10 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java @@ -4,35 +4,38 @@ */ package org.hibernate.query.results; -import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - import org.hibernate.Incubating; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.query.NativeQuery; import org.hibernate.query.named.NamedResultSetMappingMemento; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + /** - * Acts as the {@link JdbcValuesMappingProducer} for {@link NativeQuery} - * or {@link org.hibernate.procedure.ProcedureCall} / {@link jakarta.persistence.StoredProcedureQuery} - * instances. These mappings can be defined
    - *
  • - * statically via {@link jakarta.persistence.SqlResultSetMapping} or `hbm.xml` mapping - *
  • - *
  • - * dynamically via Hibernate-specific APIs:
      - *
    • {@link NativeQuery#addScalar}
    • - *
    • {@link NativeQuery#addEntity}
    • - *
    • {@link NativeQuery#addJoin}
    • - *
    • {@link NativeQuery#addFetch}
    • - *
    • {@link NativeQuery#addRoot}
    • - *
    - *
  • + * JdbcValuesMappingProducer implementation based on a graph of {@linkplain ResultBuilder} + * and {@linkplain FetchBuilder} reference. Used to model result-set mappings from:
      + *
    • {@link jakarta.persistence.SqlResultSetMapping}
    • + *
    • {@code orm.xml}
    • + *
    • {@code mapping.xml}
    • + *
    • {@code hbm.xml}
    • + *
    • + * Hibernate-specific APIs:
        + *
      • {@link NativeQuery#addScalar}
      • + *
      • {@link NativeQuery#addEntity}
      • + *
      • {@link NativeQuery#addJoin}
      • + *
      • {@link NativeQuery#addFetch}
      • + *
      • {@link NativeQuery#addRoot}
      • + *
      + *
    • *
    * + * @see NativeQuery + * @see org.hibernate.procedure.ProcedureCall + * @see jakarta.persistence.StoredProcedureQuery + * * @author Steve Ebersole */ @Incubating @@ -70,7 +73,7 @@ public interface ResultSetMapping extends JdbcValuesMappingProducer { * {@link ResultBuilder#visitFetchBuilders}), fetches defined in the legacy way are unassociated * to their "parent". */ - void visitLegacyFetchBuilders(Consumer resultBuilderConsumer); + void visitLegacyFetchBuilders(Consumer resultBuilderConsumer); /** * Add a builder @@ -80,7 +83,7 @@ public interface ResultSetMapping extends JdbcValuesMappingProducer { /** * Add a legacy fetch builder */ - void addLegacyFetchBuilder(DynamicFetchBuilderLegacy fetchBuilder); + void addLegacyFetchBuilder(LegacyFetchBuilder fetchBuilder); /** * Create a memento from this mapping. diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/package-info.java b/hibernate-core/src/main/java/org/hibernate/query/results/complete/package-info.java deleted file mode 100644 index d0bbc290c8..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ - -/** - * Support for immutable result/fetch builder graph nodes built from static sources - * such as {@link jakarta.persistence.SqlResultSetMapping} or the {@code hbm.xml} - * mapping element {@code }. - *

    - * The differentiation from {@link org.hibernate.query.results.dynamic} is that here - * we have up-front knowledge of the complete mapping graph and can perform optimized - * resolution process - */ -package org.hibernate.query.results.complete; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/LegacyFetchResolver.java b/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/LegacyFetchResolver.java deleted file mode 100644 index 2e3e9b694c..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/LegacyFetchResolver.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-or-later - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.query.results.dynamic; - -import org.hibernate.query.NativeQuery; - -/** - * Contract for handling Hibernate's legacy way of representing fetches through - * {@link NativeQuery#addFetch}, {@link NativeQuery#addJoin}, - * `hbm.xml` mappings, etc - * - * @see org.hibernate.query.results.DomainResultCreationStateImpl#getLegacyFetchResolver() - * - * @author Steve Ebersole - */ -@FunctionalInterface -public interface LegacyFetchResolver { - DynamicFetchBuilderLegacy resolve(String ownerTableAlias, String fetchedPartPath); -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/Builders.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/Builders.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/query/results/Builders.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/Builders.java index b541a8ec09..3a5cf54e1e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/Builders.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/Builders.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; import java.util.ArrayList; import java.util.HashMap; @@ -23,23 +23,26 @@ import org.hibernate.metamodel.spi.MappingMetamodelImplementor; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.NativeQuery; import org.hibernate.query.internal.ResultSetMappingResolutionContext; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; -import org.hibernate.query.results.dynamic.DynamicResultBuilderAttribute; -import org.hibernate.query.results.dynamic.DynamicResultBuilderBasic; -import org.hibernate.query.results.dynamic.DynamicResultBuilderBasicConverted; -import org.hibernate.query.results.dynamic.DynamicResultBuilderBasicStandard; -import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityCalculated; -import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityStandard; -import org.hibernate.query.results.dynamic.DynamicResultBuilderInstantiation; -import org.hibernate.query.results.implicit.ImplicitFetchBuilder; -import org.hibernate.query.results.implicit.ImplicitFetchBuilderBasic; -import org.hibernate.query.results.implicit.ImplicitFetchBuilderDiscriminatedAssociation; -import org.hibernate.query.results.implicit.ImplicitFetchBuilderEmbeddable; -import org.hibernate.query.results.implicit.ImplicitFetchBuilderEntity; -import org.hibernate.query.results.implicit.ImplicitFetchBuilderEntityPart; -import org.hibernate.query.results.implicit.ImplicitFetchBuilderPlural; -import org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderEntity; -import org.hibernate.query.results.implicit.ImplicitResultClassBuilder; +import org.hibernate.query.results.FetchBuilder; +import org.hibernate.query.results.ResultBuilder; +import org.hibernate.query.results.ResultBuilderBasicValued; +import org.hibernate.query.results.internal.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderAttribute; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderBasic; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderBasicConverted; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderBasicStandard; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityCalculated; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityStandard; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderInstantiation; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilder; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderBasic; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderDiscriminatedAssociation; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderEmbeddable; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderEntity; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderEntityPart; +import org.hibernate.query.results.internal.implicit.ImplicitFetchBuilderPlural; +import org.hibernate.query.results.internal.implicit.ImplicitModelPartResultBuilderEntity; +import org.hibernate.query.results.internal.implicit.ImplicitResultClassBuilder; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.Fetchable; @@ -52,6 +55,8 @@ import jakarta.persistence.metamodel.EntityType; import jakarta.persistence.metamodel.SingularAttribute; /** + * Commonly helpful creators for {@linkplain ResultBuilder} and {@linkplain FetchBuilder} references. + * * @author Steve Ebersole */ public class Builders { diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/DomainResultCreationStateImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/DomainResultCreationStateImpl.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/query/results/DomainResultCreationStateImpl.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/DomainResultCreationStateImpl.java index 956be35b2a..5351c60dfa 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/DomainResultCreationStateImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/DomainResultCreationStateImpl.java @@ -2,13 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; - -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; +package org.hibernate.query.results.internal; import org.hibernate.Internal; import org.hibernate.LockMode; @@ -18,7 +12,6 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.util.collections.Stack; import org.hibernate.internal.util.collections.StandardStack; import org.hibernate.metamodel.mapping.Association; -import org.hibernate.metamodel.mapping.AssociationKey; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.CompositeIdentifierMapping; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; @@ -28,11 +21,10 @@ import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping; import org.hibernate.metamodel.mapping.internal.BasicValuedCollectionPart; import org.hibernate.metamodel.mapping.internal.CaseStatementDiscriminatorMappingImpl; -import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping; +import org.hibernate.query.results.FetchBuilder; +import org.hibernate.query.results.LegacyFetchBuilder; import org.hibernate.spi.EntityIdentifierNavigablePath; import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; -import org.hibernate.query.results.dynamic.LegacyFetchResolver; import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator; import org.hibernate.sql.ast.spi.SqlAliasBaseManager; import org.hibernate.sql.ast.spi.SqlAstCreationContext; @@ -55,9 +47,20 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; -import static org.hibernate.query.results.ResultsHelper.attributeName; +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; + +import static org.hibernate.query.results.internal.ResultsHelper.attributeName; /** + * Central implementation of {@linkplain DomainResultCreationState}, + * {@linkplain SqlAstCreationState}, {@linkplain SqlAstProcessingState} and + * {@linkplain SqlExpressionResolver} used while building + * {@linkplain org.hibernate.query.results.ResultSetMapping} references. + * * @author Steve Ebersole */ @Internal @@ -76,7 +79,7 @@ public class DomainResultCreationStateImpl private final SqlAliasBaseManager sqlAliasBaseManager; - private final LegacyFetchResolverImpl legacyFetchResolver; + private final LegacyFetchResolver legacyFetchResolver; private final SessionFactoryImplementor sessionFactory; private final Stack fetchBuilderResolverStack = new StandardStack<>( Function.class, fetchableName -> null ); @@ -89,7 +92,7 @@ public class DomainResultCreationStateImpl public DomainResultCreationStateImpl( String stateIdentifier, JdbcValuesMetadata jdbcResultsMetadata, - Map> legacyFetchBuilders, + Map> legacyFetchBuilders, Consumer sqlSelectionConsumer, LoadQueryInfluencers loadQueryInfluencers, SessionFactoryImplementor sessionFactory) { @@ -100,15 +103,11 @@ public class DomainResultCreationStateImpl this.fromClauseAccess = new FromClauseAccessImpl(); this.sqlAliasBaseManager = new SqlAliasBaseManager(); - this.legacyFetchResolver = new LegacyFetchResolverImpl( legacyFetchBuilders ); + this.legacyFetchResolver = new LegacyFetchResolver( legacyFetchBuilders ); this.sessionFactory = sessionFactory; } - public LegacyFetchResolver getLegacyFetchResolver() { - return legacyFetchResolver; - } - public SessionFactoryImplementor getSessionFactory() { return sessionFactory; } @@ -131,6 +130,7 @@ public class DomainResultCreationStateImpl } public Map.Entry getCurrentRelativePath() { + //noinspection unchecked return relativePathStack.getCurrent(); } @@ -139,10 +139,12 @@ public class DomainResultCreationStateImpl } public Function getCurrentExplicitFetchMementoResolver() { + //noinspection unchecked return fetchBuilderResolverStack.getCurrent(); } public Function popExplicitFetchMementoResolver() { + //noinspection unchecked return fetchBuilderResolverStack.pop(); } @@ -177,21 +179,6 @@ public class DomainResultCreationStateImpl return sqlAliasBaseManager; } - @Override - public boolean forceIdentifierSelection() { - return true; - } - - @Override - public boolean registerVisitedAssociationKey(AssociationKey associationKey) { - return false; - } - - @Override - public boolean isAssociationKeyVisited(AssociationKey associationKey) { - return false; - } - @Override public ModelPart resolveModelPart(NavigablePath navigablePath) { final TableGroup tableGroup = fromClauseAccess.findTableGroup( navigablePath ); @@ -283,8 +270,7 @@ public class DomainResultCreationStateImpl sqlSelectionMap.put( key, (ResultSetMappingSqlSelection) created ); sqlSelectionConsumer.accept( (ResultSetMappingSqlSelection) created ); } - else if ( created instanceof ColumnReference ) { - final ColumnReference columnReference = (ColumnReference) created; + else if ( created instanceof ColumnReference columnReference ) { final String selectableName = columnReference.getSelectableName(); final int valuesArrayPosition; if ( nestingFetchParent != null ) { @@ -341,20 +327,19 @@ public class DomainResultCreationStateImpl return (SqlSelection) expression; } - private static class LegacyFetchResolverImpl implements LegacyFetchResolver { - private final Map> legacyFetchBuilders; + private static class LegacyFetchResolver { + private final Map> legacyFetchBuilders; - public LegacyFetchResolverImpl(Map> legacyFetchBuilders) { + public LegacyFetchResolver(Map> legacyFetchBuilders) { this.legacyFetchBuilders = legacyFetchBuilders; } - @Override - public DynamicFetchBuilderLegacy resolve(String ownerTableAlias, String fetchedPartPath) { + public LegacyFetchBuilder resolve(String ownerTableAlias, String fetchedPartPath) { if ( legacyFetchBuilders == null ) { return null; } - final Map fetchBuilders = legacyFetchBuilders.get( ownerTableAlias ); + final Map fetchBuilders = legacyFetchBuilders.get( ownerTableAlias ); if ( fetchBuilders == null ) { return null; } @@ -377,6 +362,7 @@ public class DomainResultCreationStateImpl final EntityValuedModelPart parentModelPart = fetchParent.getEntityValuedModelPart(); final EntityIdentifierMapping identifierMapping = parentModelPart.getEntityMappingType().getIdentifierMapping(); final String identifierAttributeName = attributeName( identifierMapping ); + //noinspection unchecked final Map.Entry oldEntry = relativePathStack.getCurrent(); final String fullPath; if ( identifierMapping instanceof NonAggregatedIdentifierMapping ) { @@ -389,10 +375,9 @@ public class DomainResultCreationStateImpl } final Fetchable identifierFetchable = (Fetchable) identifierMapping; - final FetchBuilder explicitFetchBuilder = (FetchBuilder) fetchBuilderResolverStack - .getCurrent() - .apply( fullPath ); - DynamicFetchBuilderLegacy fetchBuilderLegacy; + //noinspection unchecked + final FetchBuilder explicitFetchBuilder = (FetchBuilder) fetchBuilderResolverStack.getCurrent().apply( fullPath ); + LegacyFetchBuilder fetchBuilderLegacy; if ( explicitFetchBuilder == null ) { fetchBuilderLegacy = legacyFetchResolver.resolve( fromClauseAccess.findTableGroup( fetchParent.getNavigablePath() ) @@ -421,21 +406,17 @@ public class DomainResultCreationStateImpl if ( explicitFetchBuilder != null ) { fetchBuilder = explicitFetchBuilder; } - else { - if ( fetchBuilderLegacy == null ) { - fetchBuilder = Builders.implicitFetchBuilder( fetchPath, identifierFetchable, this ); - } - else { - fetchBuilder = fetchBuilderLegacy; - } + else if ( fetchBuilderLegacy != null ) { + fetchBuilder = fetchBuilderLegacy; } + else { + fetchBuilder = Builders.implicitFetchBuilder( fetchPath, identifierFetchable, this ); + } + return fetchBuilder.buildFetch( fetchParent, fetchPath, jdbcResultsMetadata, - (s, s2) -> { - throw new UnsupportedOperationException(); - }, this ); } @@ -471,6 +452,7 @@ public class DomainResultCreationStateImpl ); } else { + //noinspection unchecked final Map.Entry oldEntry = relativePathStack.getCurrent(); final String key = oldEntry.getKey(); currentEntry = new AbstractMap.SimpleEntry<>( @@ -480,10 +462,9 @@ public class DomainResultCreationStateImpl } // todo (6.0): figure out if we can somehow create the navigable paths in a better way final String fullPath = currentEntry.getKey(); - FetchBuilder explicitFetchBuilder = (FetchBuilder) fetchBuilderResolverStack - .getCurrent() - .apply( fullPath ); - DynamicFetchBuilderLegacy fetchBuilderLegacy; + //noinspection unchecked + FetchBuilder explicitFetchBuilder = (FetchBuilder) fetchBuilderResolverStack.getCurrent().apply( fullPath ); + LegacyFetchBuilder fetchBuilderLegacy; if ( explicitFetchBuilder == null ) { fetchBuilderLegacy = legacyFetchResolver.resolve( fromClauseAccess.findTableGroup( fetchParent.getNavigablePath() ) @@ -495,8 +476,7 @@ public class DomainResultCreationStateImpl else { fetchBuilderLegacy = null; } - if ( fetchable instanceof Association && fetchable.getMappedFetchOptions().getTiming() == FetchTiming.DELAYED ) { - final Association association = (Association) fetchable; + if ( fetchable instanceof Association association && fetchable.getMappedFetchOptions().getTiming() == FetchTiming.DELAYED ) { final ForeignKeyDescriptor foreignKeyDescriptor = association.getForeignKeyDescriptor(); final String partName = attributeName( @@ -509,9 +489,8 @@ public class DomainResultCreationStateImpl currentEntry.getKey() + "." + partName, currentEntry.getValue().append( partName ) ); - explicitFetchBuilder = (FetchBuilder) fetchBuilderResolverStack - .getCurrent() - .apply( currentEntry.getKey() ); + //noinspection unchecked + explicitFetchBuilder = (FetchBuilder) fetchBuilderResolverStack.getCurrent().apply( currentEntry.getKey() ); if ( explicitFetchBuilder == null ) { fetchBuilderLegacy = legacyFetchResolver.resolve( fromClauseAccess.findTableGroup( fetchParent.getNavigablePath() ) @@ -524,27 +503,21 @@ public class DomainResultCreationStateImpl } relativePathStack.push( currentEntry ); try { - final NavigablePath fetchPath = fetchParent.resolveNavigablePath( fetchable ); final FetchBuilder fetchBuilder; if ( explicitFetchBuilder != null ) { fetchBuilder = explicitFetchBuilder; } + else if ( fetchBuilderLegacy == null ) { + fetchBuilder = Builders.implicitFetchBuilder( fetchPath, fetchable, this ); + } else { - if ( fetchBuilderLegacy == null ) { - fetchBuilder = Builders.implicitFetchBuilder( fetchPath, fetchable, this ); - } - else { - fetchBuilder = fetchBuilderLegacy; - } + fetchBuilder = fetchBuilderLegacy; } final Fetch fetch = fetchBuilder.buildFetch( fetchParent, fetchPath, jdbcResultsMetadata, - (s, s2) -> { - throw new UnsupportedOperationException(); - }, this ); fetches.add( fetch ); @@ -557,8 +530,8 @@ public class DomainResultCreationStateImpl } private String getRelativePath(String oldEntry, Fetchable fetchable) { - if ( fetchable instanceof AttributeMapping || fetchable instanceof SingleAttributeIdentifierMapping || fetchable instanceof BasicValuedCollectionPart ) { - if ( !oldEntry.equals( "" ) ) { + if ( fetchable instanceof AttributeMapping || fetchable instanceof BasicValuedCollectionPart ) { + if ( !"".equals( oldEntry ) ) { return oldEntry + '.' + fetchable.getFetchableName(); } return fetchable.getFetchableName(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/FromClauseAccessImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/FromClauseAccessImpl.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/FromClauseAccessImpl.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/FromClauseAccessImpl.java index e79086b9c1..fb71f14d4d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/FromClauseAccessImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/FromClauseAccessImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; import java.util.HashMap; import java.util.Map; @@ -14,6 +14,9 @@ import org.hibernate.sql.ast.tree.from.TableGroup; import org.checkerframework.checker.nullness.qual.Nullable; /** + * FromClauseAccess implementation used while building + * {@linkplain org.hibernate.query.results.ResultSetMapping} references. + * * @author Steve Ebersole */ public class FromClauseAccessImpl implements FromClauseAccess { @@ -57,8 +60,7 @@ public class FromClauseAccessImpl implements FromClauseAccess { @Override public TableGroup findTableGroup(NavigablePath navigablePath) { if ( tableGroupByPath != null ) { - final TableGroup tableGroup = tableGroupByPath.get( navigablePath ); - return tableGroup; + return tableGroupByPath.get( navigablePath ); } return null; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/JdbcValuesMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/JdbcValuesMappingImpl.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/query/results/JdbcValuesMappingImpl.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/JdbcValuesMappingImpl.java index bbb60c6057..42a374b80e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/JdbcValuesMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/JdbcValuesMappingImpl.java @@ -2,27 +2,24 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; -import java.util.List; -import java.util.Map; - -import org.hibernate.Internal; +import org.checkerframework.checker.nullness.qual.Nullable; import org.hibernate.LockMode; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.jdbc.internal.StandardJdbcValuesMapping; -import org.checkerframework.checker.nullness.qual.Nullable; +import java.util.List; +import java.util.Map; /** - * Implementation of JdbcValuesMapping for native / procedure queries + * JdbcValuesMapping implementation used while building + * {@linkplain org.hibernate.query.results.ResultSetMapping} references. * * @author Steve Ebersole */ -@Internal public class JdbcValuesMappingImpl extends StandardJdbcValuesMapping { - private final int rowSize; private final @Nullable Map registeredLockModes; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultSetMappingImpl.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingImpl.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultSetMappingImpl.java index 8742d54ca3..9d99cad964 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultSetMappingImpl.java @@ -2,7 +2,26 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; + +import org.hibernate.engine.spi.LoadQueryInfluencers; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.internal.util.StringHelper; +import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException; +import org.hibernate.metamodel.mapping.BasicValuedMapping; +import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.query.named.NamedResultSetMappingMemento; +import org.hibernate.query.results.LegacyFetchBuilder; +import org.hibernate.query.results.ResultBuilder; +import org.hibernate.query.results.ResultSetMapping; +import org.hibernate.sql.ast.spi.SqlSelection; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.entity.EntityResult; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import org.hibernate.type.BasicType; import java.util.ArrayList; import java.util.Collections; @@ -15,35 +34,17 @@ import java.util.TreeSet; import java.util.function.BiConsumer; import java.util.function.Consumer; -import org.hibernate.Incubating; -import org.hibernate.Internal; -import org.hibernate.engine.spi.LoadQueryInfluencers; -import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.internal.util.StringHelper; -import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException; -import org.hibernate.metamodel.mapping.BasicValuedMapping; -import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.query.named.NamedResultSetMappingMemento; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; -import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.results.graph.DomainResult; -import org.hibernate.sql.results.graph.basic.BasicResult; -import org.hibernate.sql.results.graph.entity.EntityResult; -import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; -import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; -import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import org.hibernate.type.BasicType; - /** + * ResultSetMapping implementation used while building + * {@linkplain org.hibernate.query.results.ResultSetMapping} references. + * * @author Steve Ebersole */ -@Incubating -@Internal public class ResultSetMappingImpl implements ResultSetMapping { private final String mappingIdentifier; private final boolean isDynamic; private List resultBuilders; - private Map> legacyFetchBuilders; + private Map> legacyFetchBuilders; public ResultSetMappingImpl(String mappingIdentifier) { this( mappingIdentifier, false ); @@ -71,10 +72,10 @@ public class ResultSetMappingImpl implements ResultSetMapping { this.legacyFetchBuilders = null; } else { - final Map> legacyFetchBuilders = new HashMap<>( original.legacyFetchBuilders.size() ); - for ( Map.Entry> entry : original.legacyFetchBuilders.entrySet() ) { - final Map newValue = new HashMap<>( entry.getValue().size() ); - for ( Map.Entry builderEntry : entry.getValue().entrySet() ) { + final Map> legacyFetchBuilders = new HashMap<>( original.legacyFetchBuilders.size() ); + for ( Map.Entry> entry : original.legacyFetchBuilders.entrySet() ) { + final Map newValue = new HashMap<>( entry.getValue().size() ); + for ( Map.Entry builderEntry : entry.getValue().entrySet() ) { newValue.put( builderEntry.getKey(), builderEntry.getValue().cacheKeyInstance() ); } legacyFetchBuilders.put( entry.getKey(), newValue ); @@ -117,13 +118,13 @@ public class ResultSetMappingImpl implements ResultSetMapping { } @Override - public void visitLegacyFetchBuilders(Consumer resultBuilderConsumer) { + public void visitLegacyFetchBuilders(Consumer resultBuilderConsumer) { if ( legacyFetchBuilders == null ) { return; } - for ( Map.Entry> entry : legacyFetchBuilders.entrySet() ) { - for ( DynamicFetchBuilderLegacy fetchBuilder : entry.getValue().values() ) { + for ( Map.Entry> entry : legacyFetchBuilders.entrySet() ) { + for ( LegacyFetchBuilder fetchBuilder : entry.getValue().values() ) { resultBuilderConsumer.accept( fetchBuilder ); } } @@ -138,8 +139,8 @@ public class ResultSetMappingImpl implements ResultSetMapping { } @Override - public void addLegacyFetchBuilder(DynamicFetchBuilderLegacy fetchBuilder) { - final Map existingFetchBuildersByOwner; + public void addLegacyFetchBuilder(LegacyFetchBuilder fetchBuilder) { + final Map existingFetchBuildersByOwner; if ( legacyFetchBuilders == null ) { legacyFetchBuilders = new HashMap<>(); @@ -149,7 +150,7 @@ public class ResultSetMappingImpl implements ResultSetMapping { existingFetchBuildersByOwner = legacyFetchBuilders.get( fetchBuilder.getOwnerAlias() ); } - final Map fetchBuildersByOwner; + final Map fetchBuildersByOwner; if ( existingFetchBuildersByOwner == null ) { fetchBuildersByOwner = new HashMap<>(); legacyFetchBuilders.put( fetchBuilder.getOwnerAlias(), fetchBuildersByOwner ); @@ -158,10 +159,7 @@ public class ResultSetMappingImpl implements ResultSetMapping { fetchBuildersByOwner = existingFetchBuildersByOwner; } - final DynamicFetchBuilderLegacy previousBuilder = fetchBuildersByOwner.put( fetchBuilder.getFetchableName(), fetchBuilder ); - if ( previousBuilder != null ) { - // todo (6.0) : error? log? nothing? - } + fetchBuildersByOwner.put( fetchBuilder.getFetchableName(), fetchBuilder ); } @Override @@ -226,7 +224,6 @@ public class ResultSetMappingImpl implements ResultSetMapping { domainResult = resultBuilder.buildResult( jdbcResultsMetadata, domainResults.size(), - creationState.getLegacyFetchResolver()::resolve, creationState ); } @@ -317,7 +314,7 @@ public class ResultSetMappingImpl implements ResultSetMapping { final ResultSetMappingSqlSelection sqlSelection = new ResultSetMappingSqlSelection( valuesArrayPosition, (BasicValuedMapping) jdbcMapping ); sqlSelectionConsumer.accept( sqlSelection ); - return new BasicResult( + return new BasicResult<>( valuesArrayPosition, name, jdbcMapping, diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultSetMappingSqlSelection.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultSetMappingSqlSelection.java index adea8eb000..40c2b817cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultSetMappingSqlSelection.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedMapping; @@ -16,15 +16,16 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.ValueExtractor; /** - * SqlSelection used in {@link ResultSetMapping} resolution. Doubles as its own - * {@link Expression} as well. + * SqlSelection implementation used while building + * {@linkplain org.hibernate.query.results.ResultSetMapping} references. + * Doubles as its own {@link Expression} as well. * * @author Steve Ebersole */ public class ResultSetMappingSqlSelection implements SqlSelection, Expression, SqlExpressionAccess { private final int valuesArrayPosition; private final BasicValuedMapping valueMapping; - private final ValueExtractor valueExtractor; + private final ValueExtractor valueExtractor; public ResultSetMappingSqlSelection(int valuesArrayPosition, BasicValuedMapping valueMapping) { this.valuesArrayPosition = valuesArrayPosition; @@ -39,7 +40,7 @@ public class ResultSetMappingSqlSelection implements SqlSelection, Expression, S } @Override - public ValueExtractor getJdbcValueExtractor() { + public ValueExtractor getJdbcValueExtractor() { return valueExtractor; } @@ -59,7 +60,7 @@ public class ResultSetMappingSqlSelection implements SqlSelection, Expression, S } @Override - public MappingModelExpressible getExpressionType() { + public MappingModelExpressible getExpressionType() { return valueMapping; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultsHelper.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultsHelper.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/query/results/ResultsHelper.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultsHelper.java index cf7aabf958..968998aeed 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultsHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/ResultsHelper.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.ModelPart; @@ -42,7 +42,7 @@ public class ResultsHelper { } throw new IllegalArgumentException( - "Passed DomainResultCreationState not an instance of org.hibernate.query.results.DomainResultCreationStateImpl" + "Passed DomainResultCreationState not an instance of org.hibernate.query.results.internal.DomainResultCreationStateImpl" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/TableGroupImpl.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/TableGroupImpl.java index 0fc53c68e0..985aabd192 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/TableGroupImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; +package org.hibernate.query.results.internal; import java.util.Collections; import java.util.List; @@ -15,7 +15,8 @@ import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReferenceJoin; /** - * A TableGroup created with regards to a SQL ResultSet mapping + * TableGroup implementation used while building + * {@linkplain org.hibernate.query.results.ResultSetMapping} references. * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilder.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilder.java index 7268abf392..dd1121032b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilder.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderBasicPart.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderBasicPart.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderBasicPart.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderBasicPart.java index e79924b8fe..5e1a85b8df 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderBasicPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderBasicPart.java @@ -2,25 +2,19 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; +import org.hibernate.AssertionFailure; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.DiscriminatorMapping; import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.BasicValuedFetchBuilder; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; +import org.hibernate.query.results.FetchBuilderBasicValued; import org.hibernate.query.results.MissingSqlSelectionException; -import org.hibernate.query.results.PositionalSelectionsNotAllowedException; -import org.hibernate.query.results.ResultSetMappingSqlSelection; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.ResultSetMappingSqlSelection; +import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.results.graph.DomainResultCreationState; @@ -28,14 +22,18 @@ import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.basic.BasicFetch; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; -import static org.hibernate.query.results.ResultsHelper.jdbcPositionToValuesArrayPosition; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.jdbcPositionToValuesArrayPosition; import static org.hibernate.sql.ast.spi.SqlExpressionResolver.createColumnReferenceKey; /** * @author Steve Ebersole */ -public class CompleteFetchBuilderBasicPart implements CompleteFetchBuilder, BasicValuedFetchBuilder, ModelPartReferenceBasic { +public class CompleteFetchBuilderBasicPart implements CompleteFetchBuilder, FetchBuilderBasicValued, ModelPartReferenceBasic { private final NavigablePath navigablePath; private final BasicValuedModelPart referencedModelPart; private final String selectionAlias; @@ -74,7 +72,6 @@ public class CompleteFetchBuilderBasicPart implements CompleteFetchBuilder, Basi FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); @@ -101,9 +98,7 @@ public class CompleteFetchBuilderBasicPart implements CompleteFetchBuilder, Basi } else { if ( ! creationStateImpl.arePositionalSelectionsAllowed() ) { - throw new PositionalSelectionsNotAllowedException( - "Positional SQL selection resolution not allowed" - ); + throw new AssertionFailure( "Positional SQL selection resolution not allowed" ); } jdbcPosition = creationStateImpl.getNumberOfProcessedSelections() + 1; selectedAlias = jdbcResultsMetadata.resolveColumnName( jdbcPosition ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java index 1441f9538e..f3b3045ccb 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderEmbeddableValuedModelPart.java @@ -2,17 +2,15 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import java.util.List; -import java.util.function.BiFunction; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; -import org.hibernate.query.results.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableReference; @@ -21,7 +19,7 @@ import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * CompleteFetchBuilder for embeddable-valued ModelParts @@ -72,7 +70,6 @@ public class CompleteFetchBuilderEmbeddableValuedModelPart FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { assert fetchPath.equals( navigablePath ); final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderEntityValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderEntityValuedModelPart.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderEntityValuedModelPart.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderEntityValuedModelPart.java index 65c8e5f715..d9db12d754 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteFetchBuilderEntityValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteFetchBuilderEntityValuedModelPart.java @@ -2,18 +2,16 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import java.util.List; -import java.util.function.BiFunction; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.ValuedModelPart; -import org.hibernate.query.results.ResultsHelper; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.results.graph.DomainResultCreationState; @@ -22,7 +20,7 @@ import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * CompleteFetchBuilder for entity-valued ModelParts @@ -73,7 +71,6 @@ public class CompleteFetchBuilderEntityValuedModelPart FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { assert fetchPath.equals( navigablePath ); final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilder.java similarity index 82% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilder.java index a13fe3b04b..645a67e983 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilder.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.query.results.ResultBuilder; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicModelPart.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicModelPart.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicModelPart.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicModelPart.java index 322662a80d..69c0ff8104 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicModelPart.java @@ -2,16 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.ResultBuilder; -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; import org.hibernate.sql.ast.tree.from.TableReference; @@ -19,7 +16,7 @@ import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * CompleteResultBuilder for basic-valued ModelParts @@ -65,7 +62,6 @@ public class CompleteResultBuilderBasicModelPart public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValued.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValued.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValued.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValued.java index 7c0b206530..d76c9419e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValued.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValued.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.query.results.ResultBuilderBasicValued; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValuedConverted.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValuedConverted.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValuedConverted.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValuedConverted.java index 81e23760f3..3185671c9f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValuedConverted.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValuedConverted.java @@ -2,31 +2,28 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.Objects; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; +import jakarta.persistence.AttributeConverter; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedMapping; -import org.hibernate.type.descriptor.converter.internal.JpaAttributeConverterImpl; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.ResultBuilder; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.ResultSetMappingSqlSelection; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.ResultSetMappingSqlSelection; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.resource.beans.spi.ManagedBean; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import org.hibernate.type.descriptor.converter.internal.JpaAttributeConverterImpl; import org.hibernate.type.descriptor.java.BasicJavaType; import org.hibernate.type.descriptor.java.JavaType; -import jakarta.persistence.AttributeConverter; +import java.util.Objects; -import static org.hibernate.query.results.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * ResultBuilder for scalar results defined via:

      @@ -49,6 +46,7 @@ public class CompleteResultBuilderBasicValuedConverted implements CompleteR BasicValuedMapping underlyingMapping) { this.explicitColumnName = explicitColumnName; this.underlyingMapping = underlyingMapping; + //noinspection unchecked,rawtypes this.valueConverter = new JpaAttributeConverterImpl<>( converterBean, converterJtd, @@ -71,7 +69,6 @@ public class CompleteResultBuilderBasicValuedConverted implements CompleteR public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValuedStandard.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValuedStandard.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValuedStandard.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValuedStandard.java index bf5db51513..560be23e39 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderBasicValuedStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderBasicValuedStandard.java @@ -2,19 +2,15 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.Objects; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedMapping; import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.ResultBuilder; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.ResultSetMappingSqlSelection; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.ResultSetMappingSqlSelection; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.results.graph.DomainResultCreationState; @@ -22,7 +18,9 @@ import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.java.JavaType; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.Objects; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * ResultBuilder for scalar results defined via:
        @@ -43,6 +41,7 @@ public class CompleteResultBuilderBasicValuedStandard implements CompleteResultB String explicitColumnName, BasicValuedMapping explicitType, JavaType explicitJavaType) { + //noinspection unchecked assert explicitType == null || explicitType.getJdbcMapping() .getJavaTypeDescriptor() .getJavaTypeClass() @@ -67,7 +66,6 @@ public class CompleteResultBuilderBasicValuedStandard implements CompleteResultB public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderCollection.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderCollection.java similarity index 79% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderCollection.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderCollection.java index eba71c4032..1e13891b08 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderCollection.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderCollection.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderCollectionStandard.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderCollectionStandard.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderCollectionStandard.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderCollectionStandard.java index c2a49ff867..cef8b60f29 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderCollectionStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderCollectionStandard.java @@ -2,10 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.Arrays; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.EntityMappingType; @@ -14,11 +11,10 @@ import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.query.NativeQuery; -import org.hibernate.query.results.DomainResultCreationStateImpl; -import org.hibernate.query.results.FromClauseAccessImpl; 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.FromClauseAccessImpl; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.spi.SqlAliasBaseConstant; import org.hibernate.sql.ast.tree.from.TableGroup; @@ -26,7 +22,9 @@ import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.Arrays; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * @author Steve Ebersole @@ -91,7 +89,6 @@ public class CompleteResultBuilderCollectionStandard implements CompleteResultBu public DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState ); final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityJpa.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityJpa.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityJpa.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityJpa.java index c8a57a1855..c79fb59659 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityJpa.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityJpa.java @@ -2,28 +2,26 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.HashMap; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.query.results.BasicValuedFetchBuilder; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; +import org.hibernate.query.results.FetchBuilderBasicValued; 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.SqlAliasBase; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.entity.EntityResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import java.util.HashMap; +import java.util.Objects; +import java.util.function.BiConsumer; + /** * CompleteResultBuilderEntityValued implementation specific to JPA. In JPA * mappings, fetches contains also entity-identifier-related fetches - so we will @@ -38,14 +36,14 @@ public class CompleteResultBuilderEntityJpa implements CompleteResultBuilderEnti private final NavigablePath navigablePath; private final EntityMappingType entityDescriptor; private final LockMode lockMode; - private final BasicValuedFetchBuilder discriminatorFetchBuilder; + private final FetchBuilderBasicValued discriminatorFetchBuilder; private final HashMap explicitFetchBuilderMap; public CompleteResultBuilderEntityJpa( NavigablePath navigablePath, EntityMappingType entityDescriptor, LockMode lockMode, - BasicValuedFetchBuilder discriminatorFetchBuilder, + FetchBuilderBasicValued discriminatorFetchBuilder, HashMap explicitFetchBuilderMap) { this.navigablePath = navigablePath; this.entityDescriptor = entityDescriptor; @@ -87,7 +85,6 @@ public class CompleteResultBuilderEntityJpa implements CompleteResultBuilderEnti public EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final String implicitAlias = entityDescriptor.getSqlAliasStem() + resultPosition; final SqlAliasBase sqlAliasBase = domainResultCreationState.getSqlAliasBaseManager().createSqlAliasBase( implicitAlias ); @@ -126,7 +123,6 @@ public class CompleteResultBuilderEntityJpa implements CompleteResultBuilderEnti entityResult, navigablePath.append( EntityDiscriminatorMapping.DISCRIMINATOR_ROLE_NAME ), jdbcResultsMetadata, - legacyFetchResolver, domainResultCreationState ); }, diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityStandard.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityStandard.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityStandard.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityStandard.java index 29fb0c864b..45545b5211 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityStandard.java @@ -2,29 +2,27 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.HashMap; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.query.NativeQuery; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.BasicValuedFetchBuilder; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; +import org.hibernate.query.results.FetchBuilderBasicValued; 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.SqlAliasBaseConstant; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.entity.EntityResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import java.util.HashMap; +import java.util.Objects; +import java.util.function.BiConsumer; + /** * @author Steve Ebersole */ @@ -33,7 +31,7 @@ public class CompleteResultBuilderEntityStandard implements CompleteResultBuilde private final NavigablePath navigablePath; private final EntityMappingType entityDescriptor; private final LockMode lockMode; - private final BasicValuedFetchBuilder discriminatorFetchBuilder; + private final FetchBuilderBasicValued discriminatorFetchBuilder; private final HashMap explicitFetchBuilderMap; public CompleteResultBuilderEntityStandard( @@ -41,7 +39,7 @@ public class CompleteResultBuilderEntityStandard implements CompleteResultBuilde NavigablePath navigablePath, EntityMappingType entityDescriptor, LockMode lockMode, - BasicValuedFetchBuilder discriminatorFetchBuilder, + FetchBuilderBasicValued discriminatorFetchBuilder, HashMap explicitFetchBuilderMap) { this.tableAlias = tableAlias; this.navigablePath = navigablePath; @@ -120,7 +118,6 @@ public class CompleteResultBuilderEntityStandard implements CompleteResultBuilde public EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl impl = ResultsHelper.impl( domainResultCreationState ); impl.disallowPositionalSelections(); @@ -156,7 +153,6 @@ public class CompleteResultBuilderEntityStandard implements CompleteResultBuilde entityResult, navigablePath.append( EntityDiscriminatorMapping.DISCRIMINATOR_ROLE_NAME ), jdbcResultsMetadata, - legacyFetchResolver, domainResultCreationState ); }, diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityValued.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityValued.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityValued.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityValued.java index e21eb5fe02..d6c7b3718f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderEntityValued.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderEntityValued.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.query.results.ResultBuilderEntityValued; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderInstantiation.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderInstantiation.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderInstantiation.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderInstantiation.java index 3baac22da8..ee36dc0faa 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/CompleteResultBuilderInstantiation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/CompleteResultBuilderInstantiation.java @@ -2,16 +2,11 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiFunction; - -import org.hibernate.query.sqm.DynamicInstantiationNature; -import org.hibernate.query.results.ResultBuilderInstantiationValued; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.query.results.ResultBuilder; +import org.hibernate.query.results.ResultBuilderInstantiationValued; +import org.hibernate.query.sqm.DynamicInstantiationNature; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.instantiation.internal.ArgumentDomainResult; @@ -19,6 +14,9 @@ import org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiati import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.java.JavaType; +import java.util.ArrayList; +import java.util.List; + /** * ResultBuilder for dynamic instantiation results ({@link jakarta.persistence.ConstructorResult} * @@ -51,7 +49,6 @@ public class CompleteResultBuilderInstantiation public DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final List> argumentDomainResults = new ArrayList<>( argumentResultBuilders.size() ); @@ -62,7 +59,6 @@ public class CompleteResultBuilderInstantiation argumentResultBuilder.buildResult( jdbcResultsMetadata, i, - legacyFetchResolver, domainResultCreationState ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/DelayedFetchBuilderBasicPart.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/DelayedFetchBuilderBasicPart.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/DelayedFetchBuilderBasicPart.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/DelayedFetchBuilderBasicPart.java index 374ded21ae..9a4292a33a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/DelayedFetchBuilderBasicPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/DelayedFetchBuilderBasicPart.java @@ -2,28 +2,26 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; - -import java.util.Collections; -import java.util.List; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.complete; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.BasicValuedFetchBuilder; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.FetchBuilderBasicValued; +import org.hibernate.spi.NavigablePath; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.basic.BasicFetch; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import java.util.Collections; +import java.util.List; + /** * @author Christian Beikov */ public class DelayedFetchBuilderBasicPart - implements CompleteFetchBuilder, BasicValuedFetchBuilder, ModelPartReferenceBasic { + implements CompleteFetchBuilder, FetchBuilderBasicValued, ModelPartReferenceBasic { private final NavigablePath navigablePath; private final BasicValuedModelPart referencedModelPart; private final boolean isEnhancedForLazyLoading; @@ -57,7 +55,6 @@ public class DelayedFetchBuilderBasicPart FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { return new BasicFetch<>( -1, diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/EntityResultImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/EntityResultImpl.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/EntityResultImpl.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/EntityResultImpl.java index 488744df13..d0c969b1e7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/EntityResultImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/EntityResultImpl.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import java.util.BitSet; import java.util.function.Function; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReference.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReference.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReference.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReference.java index cff49959a9..fbb517f5ae 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReference.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReference.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.spi.NavigablePath; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceBasic.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceBasic.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceBasic.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceBasic.java index d843e16368..a4899b922a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceBasic.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceBasic.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.BasicValuedModelPart; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceCollection.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceCollection.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceCollection.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceCollection.java index 803b8738df..3e2105576a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceCollection.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceCollection.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.PluralAttributeMapping; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceEmbeddable.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceEmbeddable.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceEmbeddable.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceEmbeddable.java index d3f218b3bf..054a13d1be 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceEmbeddable.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceEmbeddable.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceEntity.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceEntity.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceEntity.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceEntity.java index 010fc98922..10ee36ebf6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/complete/ModelPartReferenceEntity.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/ModelPartReferenceEntity.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.complete; +package org.hibernate.query.results.internal.complete; import org.hibernate.metamodel.mapping.EntityValuedModelPart; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/package-info.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/package-info.java new file mode 100644 index 0000000000..deb1213b81 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/complete/package-info.java @@ -0,0 +1,13 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. + */ + +/** + * Support for immutable result/fetch builder graph nodes built from static sources + * such as {@link jakarta.persistence.SqlResultSetMapping}, {@code orm.xml}, + * {@code mapping.xml} or {@code hbm.xml}. + */ +package org.hibernate.query.results.internal.complete; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/AbstractFetchBuilderContainer.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/AbstractFetchBuilderContainer.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/AbstractFetchBuilderContainer.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/AbstractFetchBuilderContainer.java index 053e46b5bf..dce0cd9724 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/AbstractFetchBuilderContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/AbstractFetchBuilderContainer.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; import java.util.HashMap; import java.util.Locale; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilder.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilder.java index 6b85cc1d2f..abf152ef8e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilder.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderContainer.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderContainer.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderContainer.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderContainer.java index ed65d1a425..6dcc3dd349 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderContainer.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.query.results.FetchBuilder; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderLegacy.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderLegacy.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderLegacy.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderLegacy.java index 294b6c1f1d..50339d6261 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderLegacy.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderLegacy.java @@ -2,14 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.LockMode; import org.hibernate.engine.FetchTiming; @@ -20,9 +13,10 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping; import org.hibernate.query.NativeQuery; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.ResultsHelper; +import org.hibernate.query.results.LegacyFetchBuilder; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.spi.SqlAliasBase; @@ -36,13 +30,20 @@ import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.BiConsumer; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * @author Steve Ebersole * @author Christian Beikov */ -public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQuery.FetchReturn, DynamicFetchBuilderContainer { +public class DynamicFetchBuilderLegacy + implements LegacyFetchBuilder, DynamicFetchBuilder, NativeQuery.FetchReturn, NativeQuery.ReturnableResultNode, DynamicFetchBuilderContainer { private static final String ELEMENT_PREFIX = CollectionPart.Nature.ELEMENT.getName() + "."; private static final String INDEX_PREFIX = CollectionPart.Nature.INDEX.getName() + "."; @@ -124,7 +125,6 @@ public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQue FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationState = impl( domainResultCreationState ); final TableGroup ownerTableGroup = creationState.getFromClauseAccess().findByAlias( ownerTableAlias ); @@ -153,8 +153,7 @@ public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQue if ( columnNames != null ) { final ForeignKeyDescriptor keyDescriptor; - if ( attributeMapping instanceof PluralAttributeMapping ) { - final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) attributeMapping; + if ( attributeMapping instanceof PluralAttributeMapping pluralAttributeMapping ) { keyDescriptor = pluralAttributeMapping.getKeyDescriptor(); } else { @@ -166,20 +165,18 @@ public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQue } if ( !columnNames.isEmpty() ) { - keyDescriptor.forEachSelectable( - (selectionIndex, selectableMapping) -> { - resolveSqlSelection( - columnNames.get( selectionIndex ), - tableGroup.resolveTableReference( - fetchPath, - keyDescriptor.getKeyPart(), - selectableMapping.getContainingTableExpression() - ), - selectableMapping, - jdbcResultsMetadata, - domainResultCreationState - ); - } + keyDescriptor.forEachSelectable( (selectionIndex, selectableMapping) -> { + resolveSqlSelection( + columnNames.get( selectionIndex ), + tableGroup.resolveTableReference( + fetchPath, + keyDescriptor.getKeyPart(), + selectableMapping.getContainingTableExpression() + ), + selectableMapping, + jdbcResultsMetadata, + domainResultCreationState + ); } ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderStandard.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderStandard.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderStandard.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderStandard.java index d7be959e16..3f3417e7ca 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicFetchBuilderStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicFetchBuilderStandard.java @@ -2,11 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.BasicValuedModelPart; @@ -15,9 +11,9 @@ import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.ValuedModelPart; import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping; import org.hibernate.query.NativeQuery; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.DomainResultCreationStateImpl; -import org.hibernate.query.results.ResultsHelper; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableReference; @@ -28,6 +24,9 @@ import org.hibernate.sql.results.graph.Fetchable; import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import java.util.ArrayList; +import java.util.List; + /** * @author Steve Ebersole @@ -69,7 +68,6 @@ public class DynamicFetchBuilderStandard FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState ); @@ -121,8 +119,7 @@ public class DynamicFetchBuilderStandard creationStateImpl ); } - else if ( attributeMapping instanceof ToOneAttributeMapping ) { - final ToOneAttributeMapping toOneAttributeMapping = (ToOneAttributeMapping) attributeMapping; + else if ( attributeMapping instanceof ToOneAttributeMapping toOneAttributeMapping ) { toOneAttributeMapping.getForeignKeyDescriptor().getPart( toOneAttributeMapping.getSideNature() ) .forEachSelectable( getSelectableConsumer( diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilder.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilder.java index c345588729..15916025c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilder.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.query.NativeQuery; import org.hibernate.query.results.ResultBuilder; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderAttribute.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderAttribute.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderAttribute.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderAttribute.java index 45d2acc31b..48c1af53c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderAttribute.java @@ -2,16 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.Locale; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping; import org.hibernate.query.NativeQuery; -import org.hibernate.query.results.DomainResultCreationStateImpl; -import org.hibernate.query.results.ResultSetMappingSqlSelection; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +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; @@ -19,8 +16,10 @@ import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; -import static org.hibernate.query.results.ResultsHelper.jdbcPositionToValuesArrayPosition; +import java.util.Locale; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.jdbcPositionToValuesArrayPosition; /** * DynamicResultBuilder based on a named mapped attribute @@ -76,7 +75,6 @@ public class DynamicResultBuilderAttribute implements DynamicResultBuilder, Nati public DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl domainResultCreationStateImpl = impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasic.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasic.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasic.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasic.java index edd920cdbd..2eb17f5965 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasic.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasic.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.query.results.ResultBuilderBasicValued; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasicConverted.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasicConverted.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasicConverted.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasicConverted.java index 26f4b95a7f..394d7e0bc6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasicConverted.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasicConverted.java @@ -2,19 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.Objects; -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.dynamic; import jakarta.persistence.AttributeConverter; - import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedMapping; -import org.hibernate.type.descriptor.converter.internal.JpaAttributeConverterImpl; -import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.ResultSetMappingSqlSelection; +import org.hibernate.query.results.internal.ResultSetMappingSqlSelection; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.resource.beans.spi.ManagedBean; import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.resource.beans.spi.ProvidedInstanceManagedBeanImpl; @@ -24,10 +18,14 @@ import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.BasicType; +import org.hibernate.type.descriptor.converter.internal.JpaAttributeConverterImpl; +import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry; import org.hibernate.type.spi.TypeConfiguration; +import java.util.Objects; + /** * A ResultBuilder for explicitly converted scalar results * @@ -84,7 +82,7 @@ public class DynamicResultBuilderBasicConverted implements DynamicResultBui } @Override - public DynamicResultBuilderBasicConverted cacheKeyInstance() { + public DynamicResultBuilderBasicConverted cacheKeyInstance() { return this; } @@ -92,7 +90,6 @@ public class DynamicResultBuilderBasicConverted implements DynamicResultBui public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final TypeConfiguration typeConfiguration = domainResultCreationState.getSqlAstCreationState() .getCreationContext() diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasicStandard.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasicStandard.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasicStandard.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasicStandard.java index eda44a2a88..63f3f930a4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderBasicStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderBasicStandard.java @@ -2,18 +2,14 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; -import java.util.Objects; -import java.util.function.BiFunction; - -import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; -import org.hibernate.query.NativeQuery; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedMapping; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.ResultSetMappingSqlSelection; +import org.hibernate.metamodel.mapping.JdbcMapping; +import org.hibernate.query.NativeQuery; +import org.hibernate.query.results.internal.ResultSetMappingSqlSelection; +import org.hibernate.query.results.internal.ResultsHelper; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.expression.Expression; @@ -21,8 +17,11 @@ import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.BasicType; +import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; import org.hibernate.type.descriptor.java.JavaType; +import java.util.Objects; + /** * Standard DynamicResultBuilder for basic values. * @@ -118,7 +117,6 @@ public class DynamicResultBuilderBasicStandard implements DynamicResultBuilderBa public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final SessionFactoryImplementor sessionFactory = domainResultCreationState.getSqlAstCreationState() .getCreationContext() diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntity.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntity.java similarity index 80% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntity.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntity.java index c55715b4d5..cdfc374e1e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntity.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntity.java @@ -2,9 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.query.results.ResultBuilderEntityValued; import org.hibernate.sql.results.graph.DomainResultCreationState; @@ -19,6 +17,5 @@ public interface DynamicResultBuilderEntity extends DynamicResultBuilder, Result EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntityCalculated.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntityCalculated.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntityCalculated.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntityCalculated.java index c5b4e4837d..93b5c682b1 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntityCalculated.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntityCalculated.java @@ -2,15 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.query.NativeQuery; -import org.hibernate.query.results.DomainResultCreationStateImpl; -import org.hibernate.query.results.ResultsHelper; +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.SqlAliasBaseConstant; import org.hibernate.sql.ast.tree.from.TableGroup; @@ -106,7 +104,6 @@ public class DynamicResultBuilderEntityCalculated implements DynamicResultBuilde public EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntityStandard.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntityStandard.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntityStandard.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntityStandard.java index f9a192c49e..42c7e17f7e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderEntityStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderEntityStandard.java @@ -2,15 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.BiFunction; -import java.util.function.Function; +package org.hibernate.query.results.internal.dynamic; import org.hibernate.LockMode; import org.hibernate.engine.FetchTiming; @@ -23,10 +15,10 @@ import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.internal.ManyToManyCollectionPart; import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping; import org.hibernate.query.NativeQuery; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.complete.CompleteFetchBuilder; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.ResultsHelper; +import org.hibernate.query.results.internal.complete.CompleteFetchBuilder; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SqlAliasBaseConstant; @@ -39,7 +31,14 @@ import org.hibernate.sql.results.graph.Fetchable; import org.hibernate.sql.results.graph.entity.EntityResult; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * @author Steve Ebersole @@ -138,7 +137,6 @@ public class DynamicResultBuilderEntityStandard public EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { return buildResultOrFetch( (tableGroup) -> (EntityResult) entityMapping.createDomainResult( @@ -221,8 +219,7 @@ public class DynamicResultBuilderEntityStandard if ( keyColumnAliases != null ) { final ModelPart keyPart; final TableGroup keyTableGroup; - if ( fetchable instanceof PluralAttributeMapping ) { - final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) fetchable; + if ( fetchable instanceof PluralAttributeMapping pluralAttributeMapping ) { if ( pluralAttributeMapping.getCollectionDescriptor().isOneToMany() ) { keyPart = entityMapping.getIdentifierMapping(); keyTableGroup = tableGroup; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderInstantiation.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderInstantiation.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderInstantiation.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderInstantiation.java index 7c353656a2..ca8c62e647 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/DynamicResultBuilderInstantiation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/DynamicResultBuilderInstantiation.java @@ -2,16 +2,12 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiFunction; - -import org.hibernate.query.sqm.DynamicInstantiationNature; import org.hibernate.query.NativeQuery; -import org.hibernate.query.results.Builders; +import org.hibernate.query.results.internal.Builders; import org.hibernate.query.results.ResultBuilderInstantiationValued; +import org.hibernate.query.sqm.DynamicInstantiationNature; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.instantiation.internal.ArgumentDomainResult; @@ -19,6 +15,9 @@ import org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiati import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.java.JavaType; +import java.util.ArrayList; +import java.util.List; + /** * @author Steve Ebersole */ @@ -96,15 +95,14 @@ public class DynamicResultBuilderInstantiation } @Override - public DynamicResultBuilderInstantiation cacheKeyInstance() { - return new DynamicResultBuilderInstantiation( this ); + public DynamicResultBuilderInstantiation cacheKeyInstance() { + return new DynamicResultBuilderInstantiation<>( this ); } @Override public DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { if ( argumentResultBuilders.isEmpty() ) { throw new IllegalStateException( "DynamicResultBuilderInstantiation defined no arguments" ); @@ -119,7 +117,6 @@ public class DynamicResultBuilderInstantiation argument.argumentBuilder.buildResult( jdbcResultsMetadata, i, - legacyFetchResolver, domainResultCreationState ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/package-info.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/package-info.java similarity index 73% rename from hibernate-core/src/main/java/org/hibernate/query/results/dynamic/package-info.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/package-info.java index 84e852fbb2..0f9479d80d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/dynamic/package-info.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/dynamic/package-info.java @@ -1,13 +1,13 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. */ /** - * Support for mutable result/fetch builder graphs nodes built dynamically via - * Hibernate's {@link org.hibernate.query.NativeQuery} APIs + * Support for mutable result/fetch builder graphs nodes built dynamically. + * Using, for example, Hibernate's {@link org.hibernate.query.NativeQuery} API. * * @see org.hibernate.query.NativeQuery#addScalar * @see org.hibernate.query.NativeQuery#addEntity @@ -15,4 +15,4 @@ * @see org.hibernate.query.NativeQuery#addFetch * @see org.hibernate.query.NativeQuery#addRoot */ -package org.hibernate.query.results.dynamic; +package org.hibernate.query.results.internal.dynamic; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ImplicitAttributeFetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitAttributeFetchBuilder.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/query/results/ImplicitAttributeFetchBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitAttributeFetchBuilder.java index 85b1411122..b68dd57ee6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ImplicitAttributeFetchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitAttributeFetchBuilder.java @@ -2,15 +2,12 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.implicit; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.AttributeMapping; +import org.hibernate.query.results.FetchBuilder; import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; -import org.hibernate.query.results.implicit.ImplicitFetchBuilder; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; @@ -40,7 +37,6 @@ public class ImplicitAttributeFetchBuilder implements FetchBuilder, ImplicitFetc FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { assert fetchPath.equals( navigablePath ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilder.java similarity index 81% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilder.java index b92bc20ad5..1575684c39 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilder.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; +package org.hibernate.query.results.internal.implicit; import org.hibernate.query.results.FetchBuilder; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderBasic.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderBasic.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderBasic.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderBasic.java index f8ef557352..aaa44eb248 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderBasic.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderBasic.java @@ -2,20 +2,15 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; +package org.hibernate.query.results.internal.implicit; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.BasicValuedFetchBuilder; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.ResultsHelper; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.FetchBuilderBasicValued; +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.expression.Expression; import org.hibernate.sql.ast.tree.from.TableGroup; @@ -24,12 +19,15 @@ import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.basic.BasicFetch; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * @author Steve Ebersole */ -public class ImplicitFetchBuilderBasic implements ImplicitFetchBuilder, BasicValuedFetchBuilder { +public class ImplicitFetchBuilderBasic implements ImplicitFetchBuilder, FetchBuilderBasicValued { private final NavigablePath fetchPath; private final BasicValuedModelPart fetchable; private final FetchBuilder fetchBuilder; @@ -61,14 +59,12 @@ public class ImplicitFetchBuilderBasic implements ImplicitFetchBuilder, BasicVal FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { if ( fetchBuilder != null ) { return (BasicFetch) fetchBuilder.buildFetch( parent, fetchPath, jdbcResultsMetadata, - legacyFetchResolver, domainResultCreationState ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java index bedb1ffa89..33079db4fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderDiscriminatedAssociation.java @@ -2,14 +2,12 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; +package org.hibernate.query.results.internal.implicit; -import java.util.function.BiFunction; import org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping; -import org.hibernate.query.results.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.tree.from.TableGroup; @@ -19,7 +17,7 @@ import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import static org.hibernate.query.results.internal.ResultsHelper.impl; public class ImplicitFetchBuilderDiscriminatedAssociation implements ImplicitFetchBuilder { private final NavigablePath fetchPath; @@ -43,7 +41,6 @@ public class ImplicitFetchBuilderDiscriminatedAssociation implements ImplicitFet FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState creationState) { final DomainResultCreationStateImpl creationStateImpl = impl( creationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEmbeddable.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEmbeddable.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEmbeddable.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEmbeddable.java index a87bec2df4..3110414bb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEmbeddable.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEmbeddable.java @@ -2,21 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; +package org.hibernate.query.results.internal.implicit; import org.hibernate.engine.FetchTiming; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.query.results.Builders; -import org.hibernate.query.results.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.Builders; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.tree.from.TableGroup; @@ -28,7 +20,13 @@ import org.hibernate.sql.results.graph.Fetchable; import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * @author Steve Ebersole @@ -92,11 +90,11 @@ public class ImplicitFetchBuilderEmbeddable implements ImplicitFetchBuilder { FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState creationState) { final DomainResultCreationStateImpl creationStateImpl = impl( creationState ); - final TableGroup tableGroup = creationStateImpl.getFromClauseAccess().resolveTableGroup( + // make sure the TableGroup is available + creationStateImpl.getFromClauseAccess().resolveTableGroup( fetchPath, navigablePath -> { final TableGroup parentTableGroup = creationStateImpl @@ -117,15 +115,7 @@ public class ImplicitFetchBuilderEmbeddable implements ImplicitFetchBuilder { } ); - final Fetch fetch = parent.generateFetchableFetch( - fetchable, - fetchPath, - FetchTiming.IMMEDIATE, - true, - null, - creationState - ); -// final FetchParent fetchParent = (FetchParent) fetch; + // final FetchParent fetchParent = (FetchParent) fetch; // fetchBuilders.forEach( // (subFetchPath, fetchBuilder) -> fetchBuilder.buildFetch( // fetchParent, @@ -136,7 +126,14 @@ public class ImplicitFetchBuilderEmbeddable implements ImplicitFetchBuilder { // ) // ); - return fetch; + return parent.generateFetchableFetch( + fetchable, + fetchPath, + FetchTiming.IMMEDIATE, + true, + null, + creationState + ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEntity.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEntity.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEntity.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEntity.java index 6e6917cfc7..1e0453e586 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEntity.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEntity.java @@ -2,33 +2,31 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; +package org.hibernate.query.results.internal.implicit; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.EmbeddableMappingType; +import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.Builders; -import org.hibernate.query.results.DomainResultCreationStateImpl; +import org.hibernate.query.results.internal.Builders; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.DomainResultCreationStateImpl; +import org.hibernate.spi.NavigablePath; 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.graph.Fetchable; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; -import static org.hibernate.query.results.ResultsHelper.impl; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import static org.hibernate.query.results.internal.ResultsHelper.impl; /** * @author Steve Ebersole @@ -67,8 +65,7 @@ public class ImplicitFetchBuilderEntity implements ImplicitFetchBuilder { final Map fetchBuilders; if ( explicitAssociationKeyFetchBuilder == null ) { final MappingType partMappingType = foreignKeyDescriptor.getPartMappingType(); - if ( partMappingType instanceof EmbeddableMappingType ) { - final EmbeddableMappingType embeddableValuedModelPart = (EmbeddableMappingType) partMappingType; + if ( partMappingType instanceof EmbeddableMappingType embeddableValuedModelPart ) { final int size = embeddableValuedModelPart.getNumberOfFetchables(); fetchBuilders = CollectionHelper.linkedMapOfSize( size ); for ( int i = 0; i < size; i++ ) { @@ -122,9 +119,8 @@ public class ImplicitFetchBuilderEntity implements ImplicitFetchBuilder { FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState creationState) { - final Fetch fetch = parent.generateFetchableFetch( + return parent.generateFetchableFetch( fetchable, fetchPath, fetchable.getMappedFetchOptions().getTiming(), @@ -132,18 +128,6 @@ public class ImplicitFetchBuilderEntity implements ImplicitFetchBuilder { null, creationState ); -// final FetchParent fetchParent = (FetchParent) fetch; -// fetchBuilders.forEach( -// (subFetchPath, fetchBuilder) -> fetchBuilder.buildFetch( -// fetchParent, -// subFetchPath, -// jdbcResultsMetadata, -// legacyFetchResolver, -// creationState -// ) -// ); - - return fetch; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEntityPart.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEntityPart.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEntityPart.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEntityPart.java index 86f54f5a97..eb892d2fc8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderEntityPart.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderEntityPart.java @@ -2,15 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; +package org.hibernate.query.results.internal.implicit; -import java.util.function.BiFunction; import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.internal.EntityCollectionPart; import org.hibernate.spi.NavigablePath; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; @@ -38,7 +36,6 @@ public class ImplicitFetchBuilderEntityPart implements ImplicitFetchBuilder { FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState creationState) { return parent.generateFetchableFetch( fetchable, diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderPlural.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderPlural.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderPlural.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderPlural.java index b69969368d..27afecc609 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitFetchBuilderPlural.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitFetchBuilderPlural.java @@ -2,14 +2,12 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; +package org.hibernate.query.results.internal.implicit; -import java.util.function.BiFunction; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.spi.NavigablePath; import org.hibernate.query.results.FetchBuilder; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; @@ -41,7 +39,6 @@ public class ImplicitFetchBuilderPlural implements ImplicitFetchBuilder { FetchParent parent, NavigablePath fetchPath, JdbcValuesMetadata jdbcResultsMetadata, - BiFunction legacyFetchResolver, DomainResultCreationState creationState) { final Fetch fetch = parent.generateFetchableFetch( diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilder.java similarity index 82% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilder.java index 413778a2c7..8241444826 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilder.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; +package org.hibernate.query.results.internal.implicit; import org.hibernate.query.results.ResultBuilder; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderBasic.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderBasic.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderBasic.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderBasic.java index 831ac01a33..3e173280ef 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderBasic.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderBasic.java @@ -2,17 +2,14 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.implicit; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.ResultBuilder; import org.hibernate.query.results.ResultBuilderBasicValued; -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.tree.from.TableGroup; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.basic.BasicResult; @@ -45,7 +42,6 @@ public class ImplicitModelPartResultBuilderBasic public BasicResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderEmbeddable.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderEmbeddable.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderEmbeddable.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderEmbeddable.java index d3e8009f2e..034d3ea08a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderEmbeddable.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderEmbeddable.java @@ -2,17 +2,14 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.implicit; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.ResultBuilder; import org.hibernate.query.results.ResultBuilderEmbeddable; -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.SqlAstJoinType; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroupJoin; @@ -47,10 +44,9 @@ public class ImplicitModelPartResultBuilderEmbeddable } @Override - public EmbeddableResult buildResult( + public EmbeddableResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState ); creationStateImpl.disallowPositionalSelections(); @@ -85,7 +81,7 @@ public class ImplicitModelPartResultBuilderEmbeddable } ); - return (EmbeddableResult) modelPart.createDomainResult( + return (EmbeddableResult) modelPart.createDomainResult( navigablePath, tableGroup, null, diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderEntity.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderEntity.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderEntity.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderEntity.java index acd92e69fa..b273cd25ef 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitModelPartResultBuilderEntity.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitModelPartResultBuilderEntity.java @@ -2,18 +2,15 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.implicit; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityValuedModelPart; -import org.hibernate.spi.NavigablePath; -import org.hibernate.query.results.DomainResultCreationStateImpl; import org.hibernate.query.results.ResultBuilder; import org.hibernate.query.results.ResultBuilderEntityValued; -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.tree.from.TableGroup; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.entity.EntityResult; @@ -53,7 +50,6 @@ public class ImplicitModelPartResultBuilderEntity public EntityResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState ); creationStateImpl.disallowPositionalSelections(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitResultClassBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitResultClassBuilder.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitResultClassBuilder.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitResultClassBuilder.java index 945c9a82ea..c8ea3f7fc9 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/ImplicitResultClassBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/ImplicitResultClassBuilder.java @@ -2,15 +2,13 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.query.results.implicit; - -import java.util.function.BiFunction; +package org.hibernate.query.results.internal.implicit; +import jakarta.persistence.NamedNativeQuery; import org.hibernate.engine.spi.SessionFactoryImplementor; 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; @@ -20,8 +18,6 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.BasicType; import org.hibernate.type.spi.TypeConfiguration; -import jakarta.persistence.NamedNativeQuery; - /** * ResultBuilder for handling {@link NamedNativeQuery#resultClass()} when the * class does not refer to an entity @@ -39,7 +35,6 @@ public class ImplicitResultClassBuilder implements ResultBuilder { public DomainResult buildResult( JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, - BiFunction legacyFetchResolver, DomainResultCreationState domainResultCreationState) { assert resultPosition == 0; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/package-info.java b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/package-info.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/query/results/implicit/package-info.java rename to hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/package-info.java index e6a4d8bee8..e7eae68d9b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/implicit/package-info.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/internal/implicit/package-info.java @@ -1,8 +1,8 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. */ /** @@ -12,4 +12,4 @@ *
      • mapping results to a named entity class with no explicit property mappings
      • *
      */ -package org.hibernate.query.results.implicit; +package org.hibernate.query.results.internal.implicit; diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/package-info.java b/hibernate-core/src/main/java/org/hibernate/query/results/package-info.java index 6370afc92d..b015f89ca3 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/package-info.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/package-info.java @@ -6,20 +6,10 @@ */ /** - * Support for defining result set mappings used in {@link org.hibernate.query.NativeQuery}, - * {@link org.hibernate.procedure.ProcedureCall}, and {@link jakarta.persistence.StoredProcedureQuery}. - * These result set mappings are used to map the values in the JDBC {@link java.sql.ResultSet} into - * the query result graph. - *

      - * Subpackages handle different sources of result set mappings: - *

        - *
      • {@link org.hibernate.query.results.complete} handles result set mappings which are completely - * known upfront and are faster to resolve. - *
      • {@link org.hibernate.query.results.dynamic} handles result set mappings which are defined - * incrementally via the {@link org.hibernate.query.NativeQuery} interface and need to resolve - * themselves against other dynamic mappings. These take more resources to resolve. - *
      • {@link org.hibernate.query.results.implicit} handles implicit result set mappings. - *
      + * Support for defining {@linkplain org.hibernate.query.results.ResultSetMapping result set mappings} + * used in {@link org.hibernate.query.NativeQuery}, {@link org.hibernate.procedure.ProcedureCall}, + * and {@link jakarta.persistence.StoredProcedureQuery}. These result set mappings are used to map + * the values in the JDBC {@link java.sql.ResultSet} into the query result graph. * * @see org.hibernate.query.results.ResultSetMapping * diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java index 6301a2c49e..4714942c28 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java @@ -53,17 +53,17 @@ import org.hibernate.query.internal.QueryOptionsImpl; import org.hibernate.query.internal.ResultSetMappingResolutionContext; import org.hibernate.query.named.NamedObjectRepository; import org.hibernate.query.named.NamedResultSetMappingMemento; -import org.hibernate.query.results.Builders; +import org.hibernate.query.results.internal.Builders; import org.hibernate.query.results.ResultBuilder; import org.hibernate.query.results.ResultSetMapping; -import org.hibernate.query.results.ResultSetMappingImpl; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; -import org.hibernate.query.results.dynamic.DynamicResultBuilderBasicStandard; -import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityCalculated; -import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityStandard; -import org.hibernate.query.results.dynamic.DynamicResultBuilderInstantiation; -import org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderEntity; -import org.hibernate.query.results.implicit.ImplicitResultClassBuilder; +import org.hibernate.query.results.internal.ResultSetMappingImpl; +import org.hibernate.query.results.internal.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderBasicStandard; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityCalculated; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityStandard; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderInstantiation; +import org.hibernate.query.results.internal.implicit.ImplicitModelPartResultBuilderEntity; +import org.hibernate.query.results.internal.implicit.ImplicitResultClassBuilder; import org.hibernate.query.spi.AbstractQuery; import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.MutableQueryOptions; @@ -114,7 +114,7 @@ import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.makeCopy; import static org.hibernate.jpa.HibernateHints.HINT_NATIVE_LOCK_MODE; -import static org.hibernate.query.results.Builders.resultClassBuilder; +import static org.hibernate.query.results.internal.Builders.resultClassBuilder; import static org.hibernate.query.results.ResultSetMapping.resolveResultSetMapping; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java index fc3f76a0a2..2305da1b08 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java @@ -28,11 +28,12 @@ import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.NativeQuery; import org.hibernate.query.results.FetchBuilder; +import org.hibernate.query.results.LegacyFetchBuilder; import org.hibernate.query.results.ResultSetMapping; -import org.hibernate.query.results.complete.CompleteResultBuilderCollectionStandard; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderContainer; -import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; -import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityStandard; +import org.hibernate.query.results.internal.complete.CompleteResultBuilderCollectionStandard; +import org.hibernate.query.results.internal.dynamic.DynamicFetchBuilderContainer; +import org.hibernate.query.results.internal.dynamic.DynamicFetchBuilderLegacy; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityStandard; import org.hibernate.spi.NavigablePath; import org.hibernate.type.CollectionType; import org.hibernate.type.ComponentType; @@ -102,13 +103,11 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { // so that role returns can be more easily resolved to their owners resultSetMapping.visitResultBuilders( (i, resultBuilder) -> { - if ( resultBuilder instanceof NativeQuery.RootReturn ) { - final NativeQuery.RootReturn rootReturn = (NativeQuery.RootReturn) resultBuilder; + if ( resultBuilder instanceof NativeQuery.RootReturn rootReturn ) { alias2Return.put( rootReturn.getTableAlias(), rootReturn ); resultBuilder.visitFetchBuilders( this::processFetchBuilder ); } - else if ( resultBuilder instanceof NativeQuery.CollectionReturn ) { - final NativeQuery.CollectionReturn collectionReturn = (NativeQuery.CollectionReturn) resultBuilder; + else if ( resultBuilder instanceof NativeQuery.CollectionReturn collectionReturn ) { alias2Return.put( collectionReturn.getTableAlias(), collectionReturn ); Map propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap() addCollection( @@ -119,12 +118,12 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { } } ); - resultSetMapping.visitLegacyFetchBuilders( - fetchBuilder -> { - alias2Return.put( fetchBuilder.getTableAlias(), fetchBuilder ); - alias2OwnerAlias.put( fetchBuilder.getTableAlias(), fetchBuilder.getOwnerAlias() ); - } - ); + + // handle fetches defined using {@code hbm.xml} or NativeQuery apis + resultSetMapping.visitLegacyFetchBuilders( (fetchBuilder) -> { + alias2Return.put( fetchBuilder.getTableAlias(), (NativeQuery.ReturnableResultNode) fetchBuilder ); + alias2OwnerAlias.put( fetchBuilder.getTableAlias(), fetchBuilder.getOwnerAlias() ); + } ); // Now, process the returns for ( NativeQuery.ResultNode queryReturn : alias2Return.values() ) { @@ -135,11 +134,10 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { } private void processFetchBuilder(String attributeName, FetchBuilder fetchBuilder) { - if ( fetchBuilder instanceof DynamicFetchBuilderLegacy ) { - resultSetMapping.addLegacyFetchBuilder( (DynamicFetchBuilderLegacy) fetchBuilder ); + if ( fetchBuilder instanceof LegacyFetchBuilder ) { + resultSetMapping.addLegacyFetchBuilder( (LegacyFetchBuilder) fetchBuilder ); } - else if ( fetchBuilder instanceof NativeQuery.FetchReturn ) { - final NativeQuery.FetchReturn fetchReturn = (NativeQuery.FetchReturn) fetchBuilder; + else if ( fetchBuilder instanceof NativeQuery.FetchReturn fetchReturn ) { alias2Return.put( fetchReturn.getTableAlias(), fetchReturn ); alias2OwnerAlias.put( fetchReturn.getTableAlias(), fetchReturn.getOwnerAlias() ); } @@ -155,8 +153,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { final Set visited = new HashSet<>(); this.resultSetMapping.visitResultBuilders( (i, resultBuilder) -> { - if ( resultBuilder instanceof NativeQuery.RootReturn ) { - final NativeQuery.RootReturn rootReturn = (NativeQuery.RootReturn) resultBuilder; + if ( resultBuilder instanceof NativeQuery.RootReturn rootReturn ) { final String suffix = alias2Suffix.get( rootReturn.getTableAlias() ); visited.add( rootReturn.getTableAlias() ); if ( suffix == null ) { @@ -172,8 +169,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { alias2Return.put( rootReturn.getTableAlias(), resultBuilderEntity ); } } - else if ( resultBuilder instanceof NativeQuery.CollectionReturn ) { - final NativeQuery.CollectionReturn collectionReturn = (NativeQuery.CollectionReturn) resultBuilder; + else if ( resultBuilder instanceof NativeQuery.CollectionReturn collectionReturn ) { final String suffix = alias2CollectionSuffix.get( collectionReturn.getTableAlias() ); if ( suffix == null ) { resultSetMapping.addResultBuilder( resultBuilder ); @@ -202,7 +198,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { private void applyFetchBuilder( ResultSetMapping resultSetMapping, - DynamicFetchBuilderLegacy fetchBuilder, + LegacyFetchBuilder fetchBuilder, Set visited) { if ( !visited.add( fetchBuilder.getTableAlias() ) ) { return; @@ -273,7 +269,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { } } - private NavigablePath determineNavigablePath(DynamicFetchBuilderLegacy fetchBuilder) { + private NavigablePath determineNavigablePath(LegacyFetchBuilder fetchBuilder) { final NativeQuery.ResultNode ownerResult = alias2Return.get( fetchBuilder.getOwnerAlias() ); if ( ownerResult instanceof NativeQuery.RootReturn ) { return ( (NativeQuery.RootReturn) ownerResult ).getNavigablePath() @@ -349,8 +345,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { String propertyName, String[] columnAliases, Type propertyType) { - if ( propertyType instanceof CollectionType ) { - final CollectionType collectionType = (CollectionType) propertyType; + if ( propertyType instanceof CollectionType collectionType ) { final String[] keyColumnAliases; if ( collectionType.useLHSPrimaryKey() ) { keyColumnAliases = identifierAliases; @@ -363,7 +358,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { } resultBuilderEntity.addProperty( propertyName, keyColumnAliases ); } - else if ( propertyType instanceof ComponentType ) { + else if ( propertyType instanceof ComponentType componentType ) { final Map fetchBuilderMap = new HashMap<>(); final DynamicFetchBuilderLegacy fetchBuilder = new DynamicFetchBuilderLegacy( "", @@ -372,7 +367,6 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { null, fetchBuilderMap ); - final ComponentType componentType = (ComponentType) propertyType; final String[] propertyNames = componentType.getPropertyNames(); final Type[] propertyTypes = componentType.getSubtypes(); int aliasIndex = 0; @@ -574,8 +568,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext { addCollection( role, alias, propertyResultsMap ); // collectionOwnerAliases.add( ownerAlias ); } - else if ( returnType instanceof EntityType ) { - EntityType eType = ( EntityType ) returnType; + else if ( returnType instanceof EntityType eType ) { String returnEntityName = eType.getAssociatedEntityName(); EntityPersister persister = getSQLLoadable( returnEntityName ); Map propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java index c731bdfa04..2f0a04fcd8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java @@ -24,7 +24,7 @@ import org.hibernate.query.QueryParameter; import org.hibernate.query.ResultListTransformer; import org.hibernate.query.TupleTransformer; import org.hibernate.query.named.NameableQuery; -import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityStandard; +import org.hibernate.query.results.internal.dynamic.DynamicResultBuilderEntityStandard; import org.hibernate.query.spi.QueryImplementor; import org.hibernate.transform.ResultTransformer; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java index 6dc881e6a8..7729bc24f1 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java @@ -30,7 +30,7 @@ import org.hibernate.metamodel.mapping.SqlExpressible; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.SemanticException; import org.hibernate.query.SortDirection; -import org.hibernate.query.results.TableGroupImpl; +import org.hibernate.query.results.internal.TableGroupImpl; import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.sqm.BinaryArithmeticOperator; import org.hibernate.query.sqm.ComparisonOperator; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java index 7eaec24836..83977b79aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java @@ -17,7 +17,7 @@ import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.SemanticException; -import org.hibernate.query.results.TableGroupImpl; +import org.hibernate.query.results.internal.TableGroupImpl; import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/InsertExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/InsertExecutionDelegate.java index 149b85d1f3..6ee6bded1a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/InsertExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/InsertExecutionDelegate.java @@ -39,7 +39,7 @@ import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.SemanticException; import org.hibernate.query.SortDirection; -import org.hibernate.query.results.TableGroupImpl; +import org.hibernate.query.results.internal.TableGroupImpl; import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.common.FetchClauseType; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/UpdateExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/UpdateExecutionDelegate.java index 33785c015f..403bb9e3ab 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/UpdateExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/UpdateExecutionDelegate.java @@ -24,7 +24,7 @@ import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SoftDeleteMapping; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.SemanticException; -import org.hibernate.query.results.TableGroupImpl; +import org.hibernate.query.results.internal.TableGroupImpl; import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.internal.DomainParameterXref; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java index 9a798e7e5a..84819e9d01 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java @@ -25,7 +25,7 @@ import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode; import org.hibernate.sql.results.graph.entity.EntityResultGraphNode; import org.hibernate.sql.results.graph.internal.ImmutableFetchList; -import static org.hibernate.query.results.ResultsHelper.attributeName; +import static org.hibernate.query.results.internal.ResultsHelper.attributeName; /** * Contains state related to building {@link DomainResult} and diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerProviderStandard.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerProviderStandard.java index f482f18d81..c9c4eddf9e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerProviderStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerProviderStandard.java @@ -6,7 +6,7 @@ package org.hibernate.sql.results.jdbc.internal; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.query.results.ResultSetMapping; -import org.hibernate.query.results.ResultSetMappingImpl; +import org.hibernate.query.results.internal.ResultSetMappingImpl; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.select.QueryGroup; import org.hibernate.sql.ast.tree.select.QueryPart; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hbm/query/QueryReturnTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hbm/query/QueryReturnTest.java index 3c54697e54..8393e821a5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hbm/query/QueryReturnTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hbm/query/QueryReturnTest.java @@ -13,8 +13,8 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.query.internal.ResultSetMappingResolutionContext; import org.hibernate.query.named.NamedResultSetMappingMemento; import org.hibernate.query.results.ResultSetMapping; -import org.hibernate.query.results.ResultSetMappingImpl; -import org.hibernate.query.results.complete.CompleteResultBuilderEntityValued; +import org.hibernate.query.results.internal.ResultSetMappingImpl; +import org.hibernate.query.results.internal.complete.CompleteResultBuilderEntityValued; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.orm.junit.JiraKey; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/resultmapping/NamedRepoTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/resultmapping/NamedRepoTests.java index 965e709745..94d467c6be 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/resultmapping/NamedRepoTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/resultmapping/NamedRepoTests.java @@ -11,7 +11,7 @@ import org.hibernate.query.named.NamedObjectRepository; import org.hibernate.query.named.NamedResultSetMappingMemento; import org.hibernate.query.results.ResultBuilderBasicValued; import org.hibernate.query.results.ResultSetMapping; -import org.hibernate.query.results.ResultSetMappingImpl; +import org.hibernate.query.results.internal.ResultSetMappingImpl; import org.hibernate.query.spi.QueryEngine; import org.hibernate.testing.orm.junit.DomainModel; diff --git a/migration-guide.adoc b/migration-guide.adoc index fa365be48d..91fd7476ea 100644 --- a/migration-guide.adoc +++ b/migration-guide.adoc @@ -475,6 +475,11 @@ In Hibernate 7, these SQL `UPDATE` statements only occur if the `@OrderColumn` i ** Removed `hibernate.allow_refresh_detached_entity` +[[reorg]] +== Reorganize Packages (for api/spi/internal, etc) + +* Re-organized the `org.hibernate.query.results` package + [[todo]] == Todos (dev)