HHH-18847 - Organize the org.hibernate.query.results package

This commit is contained in:
Steve Ebersole 2024-11-14 13:37:58 -06:00
parent 2c5e0ff113
commit 6707dee0a6
106 changed files with 629 additions and 777 deletions

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );

View File

@ -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;

View File

@ -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
);

View File

@ -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.

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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
);
},

View File

@ -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<T> implements ResultBuilder {
public DomainResult<T> buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final SqlExpressionResolver sqlExpressionResolver = domainResultCreationState.getSqlAstCreationState()
.getSqlExpressionResolver();

View File

@ -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

View File

@ -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

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;

View File

@ -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

View File

@ -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;
/**

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {
final EntityDiscriminatorMapping discriminatorMapping = entityDescriptor.getDiscriminatorMapping();
final BasicValuedFetchBuilder discriminatorFetchBuilder;
final FetchBuilderBasicValued discriminatorFetchBuilder;
if ( discriminatorMapping == null || !entityDescriptor.hasSubclasses() ) {
assert discriminatorMemento == null;
discriminatorFetchBuilder = null;
}
else {
if ( discriminatorMemento != null ) {
discriminatorFetchBuilder = (BasicValuedFetchBuilder) discriminatorMemento.resolve( this, querySpaceConsumer, context );
discriminatorFetchBuilder = (FetchBuilderBasicValued) discriminatorMemento.resolve( this, querySpaceConsumer, context );
}
else {
discriminatorFetchBuilder = new ImplicitFetchBuilderBasic( navigablePath, discriminatorMapping );

View File

@ -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<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {
final BasicValuedFetchBuilder discriminatorResultBuilder = discriminatorMemento != null
? (BasicValuedFetchBuilder) discriminatorMemento.resolve( this, querySpaceConsumer, context )
final FetchBuilderBasicValued discriminatorResultBuilder = discriminatorMemento != null
? (FetchBuilderBasicValued) discriminatorMemento.resolve( this, querySpaceConsumer, context )
: null;
final HashMap<String, FetchBuilder> fetchBuilderMap = new HashMap<>();

View File

@ -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;
/**

View File

@ -4,32 +4,33 @@
*/
package org.hibernate.query.results;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import org.hibernate.Incubating;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;
import java.util.function.BiConsumer;
/**
* Responsible for building a single {@link DomainResult} instance as part of
* the overall mapping of native / procedure query results.
* Responsible for building a single {@link Fetch} instance.
* Given the following HQL for illustration,
* <pre>
* select b from Book b join fetch b.authors
* </pre>
* we have a single fetch : `Book(b).authors`
*
* @see ResultBuilder
*
* @apiNote By definition a fetch is a reference to the fetched ModelPart
* @author Steve Ebersole
*/
@Incubating
public interface FetchBuilder {
public interface FetchBuilder extends GraphNodeBuilder {
Fetch buildFetch(
FetchParent parent,
NavigablePath fetchPath,
JdbcValuesMetadata jdbcResultsMetadata,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);
default void visitFetchBuilders(BiConsumer<String, FetchBuilder> consumer) {

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);
}

View File

@ -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 {
}

View File

@ -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:<ul>
* <li>{@code hbm.xml} definitions</li>
* <li>calls to {@link org.hibernate.query.NativeQuery#addFetch}, and friends</li>
* </ul>
*
* @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();
}

View File

@ -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
*/

View File

@ -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 );
}
}

View File

@ -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,
* <pre>
* select b from Book b join fetch b.authors
* </pre>
* 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<String, String, DynamicFetchBuilderLegacy> 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();

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);
}

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);
}

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);
}

View File

@ -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
*/

View File

@ -4,26 +4,25 @@
*/
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<ul>
* JdbcValuesMappingProducer implementation based on a graph of {@linkplain ResultBuilder}
* and {@linkplain FetchBuilder} reference. Used to model result-set mappings from:<ul>
* <li>{@link jakarta.persistence.SqlResultSetMapping}</li>
* <li>{@code orm.xml}</li>
* <li>{@code mapping.xml}</li>
* <li>{@code hbm.xml}</li>
* <li>
* statically via {@link jakarta.persistence.SqlResultSetMapping} or `hbm.xml` mapping
* </li>
* <li>
* dynamically via Hibernate-specific APIs:<ul>
* Hibernate-specific APIs:<ul>
* <li>{@link NativeQuery#addScalar}</li>
* <li>{@link NativeQuery#addEntity}</li>
* <li>{@link NativeQuery#addJoin}</li>
@ -33,6 +32,10 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer;
* </li>
* </ul>
*
* @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<DynamicFetchBuilderLegacy> resultBuilderConsumer);
void visitLegacyFetchBuilders(Consumer<LegacyFetchBuilder> 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.

View File

@ -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 <resultset/>}.
* <p>
* 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;

View File

@ -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);
}

View File

@ -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 {

View File

@ -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<Function> fetchBuilderResolverStack = new StandardStack<>( Function.class, fetchableName -> null );
@ -89,7 +92,7 @@ public class DomainResultCreationStateImpl
public DomainResultCreationStateImpl(
String stateIdentifier,
JdbcValuesMetadata jdbcResultsMetadata,
Map<String, Map<String, DynamicFetchBuilderLegacy>> legacyFetchBuilders,
Map<String, Map<String, LegacyFetchBuilder>> legacyFetchBuilders,
Consumer<SqlSelection> 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<String, NavigablePath> getCurrentRelativePath() {
//noinspection unchecked
return relativePathStack.getCurrent();
}
@ -139,10 +139,12 @@ public class DomainResultCreationStateImpl
}
public Function<String, FetchBuilder> getCurrentExplicitFetchMementoResolver() {
//noinspection unchecked
return fetchBuilderResolverStack.getCurrent();
}
public Function<String, FetchBuilder> 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<String,Map<String, DynamicFetchBuilderLegacy>> legacyFetchBuilders;
private static class LegacyFetchResolver {
private final Map<String,Map<String, LegacyFetchBuilder>> legacyFetchBuilders;
public LegacyFetchResolverImpl(Map<String, Map<String, DynamicFetchBuilderLegacy>> legacyFetchBuilders) {
public LegacyFetchResolver(Map<String, Map<String, LegacyFetchBuilder>> 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<String, DynamicFetchBuilderLegacy> fetchBuilders = legacyFetchBuilders.get( ownerTableAlias );
final Map<String, LegacyFetchBuilder> 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<String, NavigablePath> 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 {
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<String, NavigablePath> 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 ) {
else if ( fetchBuilderLegacy == null ) {
fetchBuilder = Builders.implicitFetchBuilder( fetchPath, fetchable, this );
}
else {
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();

View File

@ -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;

View File

@ -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<String, LockMode> registeredLockModes;

View File

@ -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<ResultBuilder> resultBuilders;
private Map<String, Map<String, DynamicFetchBuilderLegacy>> legacyFetchBuilders;
private Map<String, Map<String, LegacyFetchBuilder>> legacyFetchBuilders;
public ResultSetMappingImpl(String mappingIdentifier) {
this( mappingIdentifier, false );
@ -71,10 +72,10 @@ public class ResultSetMappingImpl implements ResultSetMapping {
this.legacyFetchBuilders = null;
}
else {
final Map<String, Map<String, DynamicFetchBuilderLegacy>> legacyFetchBuilders = new HashMap<>( original.legacyFetchBuilders.size() );
for ( Map.Entry<String, Map<String, DynamicFetchBuilderLegacy>> entry : original.legacyFetchBuilders.entrySet() ) {
final Map<String, DynamicFetchBuilderLegacy> newValue = new HashMap<>( entry.getValue().size() );
for ( Map.Entry<String, DynamicFetchBuilderLegacy> builderEntry : entry.getValue().entrySet() ) {
final Map<String, Map<String, LegacyFetchBuilder>> legacyFetchBuilders = new HashMap<>( original.legacyFetchBuilders.size() );
for ( Map.Entry<String, Map<String, LegacyFetchBuilder>> entry : original.legacyFetchBuilders.entrySet() ) {
final Map<String, LegacyFetchBuilder> newValue = new HashMap<>( entry.getValue().size() );
for ( Map.Entry<String, LegacyFetchBuilder> 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<DynamicFetchBuilderLegacy> resultBuilderConsumer) {
public void visitLegacyFetchBuilders(Consumer<LegacyFetchBuilder> resultBuilderConsumer) {
if ( legacyFetchBuilders == null ) {
return;
}
for ( Map.Entry<String, Map<String, DynamicFetchBuilderLegacy>> entry : legacyFetchBuilders.entrySet() ) {
for ( DynamicFetchBuilderLegacy fetchBuilder : entry.getValue().values() ) {
for ( Map.Entry<String, Map<String, LegacyFetchBuilder>> 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<String, DynamicFetchBuilderLegacy> existingFetchBuildersByOwner;
public void addLegacyFetchBuilder(LegacyFetchBuilder fetchBuilder) {
final Map<String, LegacyFetchBuilder> existingFetchBuildersByOwner;
if ( legacyFetchBuilders == null ) {
legacyFetchBuilders = new HashMap<>();
@ -149,7 +150,7 @@ public class ResultSetMappingImpl implements ResultSetMapping {
existingFetchBuildersByOwner = legacyFetchBuilders.get( fetchBuilder.getOwnerAlias() );
}
final Map<String, DynamicFetchBuilderLegacy> fetchBuildersByOwner;
final Map<String, LegacyFetchBuilder> 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,

View File

@ -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;
}

View File

@ -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"
);
}

View File

@ -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
*/

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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 );

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
assert fetchPath.equals( navigablePath );
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
assert fetchPath.equals( navigablePath );
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );

View File

@ -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;

View File

@ -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:<ul>
@ -49,6 +46,7 @@ public class CompleteResultBuilderBasicValuedConverted<O,R> 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<O,R> implements CompleteR
public BasicResult<?> buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );
final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory();

View File

@ -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:<ul>
@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );
final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory();

View File

@ -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

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( domainResultCreationState );
final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory();

View File

@ -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<String, FetchBuilder> explicitFetchBuilderMap;
public CompleteResultBuilderEntityJpa(
NavigablePath navigablePath,
EntityMappingType entityDescriptor,
LockMode lockMode,
BasicValuedFetchBuilder discriminatorFetchBuilder,
FetchBuilderBasicValued discriminatorFetchBuilder,
HashMap<String, FetchBuilder> explicitFetchBuilderMap) {
this.navigablePath = navigablePath;
this.entityDescriptor = entityDescriptor;
@ -87,7 +85,6 @@ public class CompleteResultBuilderEntityJpa implements CompleteResultBuilderEnti
public EntityResult buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> 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
);
},

View File

@ -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<String, FetchBuilder> explicitFetchBuilderMap;
public CompleteResultBuilderEntityStandard(
@ -41,7 +39,7 @@ public class CompleteResultBuilderEntityStandard implements CompleteResultBuilde
NavigablePath navigablePath,
EntityMappingType entityDescriptor,
LockMode lockMode,
BasicValuedFetchBuilder discriminatorFetchBuilder,
FetchBuilderBasicValued discriminatorFetchBuilder,
HashMap<String, FetchBuilder> explicitFetchBuilderMap) {
this.tableAlias = tableAlias;
this.navigablePath = navigablePath;
@ -120,7 +118,6 @@ public class CompleteResultBuilderEntityStandard implements CompleteResultBuilde
public EntityResult buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> 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
);
},

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final List<ArgumentDomainResult<?>> argumentDomainResults = new ArrayList<>( argumentResultBuilders.size() );
@ -62,7 +59,6 @@ public class CompleteResultBuilderInstantiation
argumentResultBuilder.buildResult(
jdbcResultsMetadata,
i,
legacyFetchResolver,
domainResultCreationState
)
);

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
return new BasicFetch<>(
-1,

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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,8 +165,7 @@ public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQue
}
if ( !columnNames.isEmpty() ) {
keyDescriptor.forEachSelectable(
(selectionIndex, selectableMapping) -> {
keyDescriptor.forEachSelectable( (selectionIndex, selectableMapping) -> {
resolveSqlSelection(
columnNames.get( selectionIndex ),
tableGroup.resolveTableReference(
@ -178,8 +176,7 @@ public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQue
selectableMapping,
jdbcResultsMetadata,
domainResultCreationState
);
}
); }
);
}

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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(

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl domainResultCreationStateImpl = impl( domainResultCreationState );

View File

@ -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;

View File

@ -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<O,R> implements DynamicResultBui
}
@Override
public DynamicResultBuilderBasicConverted cacheKeyInstance() {
public DynamicResultBuilderBasicConverted<?,?> cacheKeyInstance() {
return this;
}
@ -92,7 +90,6 @@ public class DynamicResultBuilderBasicConverted<O,R> implements DynamicResultBui
public BasicResult<?> buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final TypeConfiguration typeConfiguration = domainResultCreationState.getSqlAstCreationState()
.getCreationContext()

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final SessionFactoryImplementor sessionFactory = domainResultCreationState.getSqlAstCreationState()
.getCreationContext()

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState);
}

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState );

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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;

View File

@ -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<J>
}
@Override
public DynamicResultBuilderInstantiation cacheKeyInstance() {
return new DynamicResultBuilderInstantiation( this );
public DynamicResultBuilderInstantiation<?> cacheKeyInstance() {
return new DynamicResultBuilderInstantiation<>( this );
}
@Override
public DomainResult<?> buildResult(
JdbcValuesMetadata jdbcResultsMetadata,
int resultPosition,
BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
if ( argumentResultBuilders.isEmpty() ) {
throw new IllegalStateException( "DynamicResultBuilderInstantiation defined no arguments" );
@ -119,7 +117,6 @@ public class DynamicResultBuilderInstantiation<J>
argument.argumentBuilder.buildResult(
jdbcResultsMetadata,
i,
legacyFetchResolver,
domainResultCreationState
)
);

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
assert fetchPath.equals( navigablePath );

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
if ( fetchBuilder != null ) {
return (BasicFetch<?>) fetchBuilder.buildFetch(
parent,
fetchPath,
jdbcResultsMetadata,
legacyFetchResolver,
domainResultCreationState
);
}

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState creationState) {
final DomainResultCreationStateImpl creationStateImpl = impl( creationState );

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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

View File

@ -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<NavigablePath, FetchBuilder> 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<String, String, DynamicFetchBuilderLegacy> 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

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState creationState) {
return parent.generateFetchableFetch(
fetchable,

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState creationState) {
final Fetch fetch = parent.generateFetchableFetch(

View File

@ -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;

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState );

View File

@ -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<String, String, DynamicFetchBuilderLegacy> 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,

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl( domainResultCreationState );
creationStateImpl.disallowPositionalSelections();

View File

@ -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<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver,
DomainResultCreationState domainResultCreationState) {
assert resultPosition == 0;

View File

@ -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 @@
* <li>mapping results to a named entity class with no explicit property mappings</li>
* </ul>
*/
package org.hibernate.query.results.implicit;
package org.hibernate.query.results.internal.implicit;

View File

@ -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.
* <p>
* Subpackages handle different sources of result set mappings:
* <ul>
* <li>{@link org.hibernate.query.results.complete} handles result set mappings which are completely
* known upfront and are faster to resolve.
* <li>{@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.
* <li>{@link org.hibernate.query.results.implicit} handles implicit result set mappings.
* </ul>
* 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
*

View File

@ -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;
/**

View File

@ -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<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap()
addCollection(
@ -119,12 +118,12 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
}
}
);
resultSetMapping.visitLegacyFetchBuilders(
fetchBuilder -> {
alias2Return.put( fetchBuilder.getTableAlias(), fetchBuilder );
// 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<String> 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<String> 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<String, FetchBuilder> 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<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap()

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More