From dc85c75bce52d0744bd71b63b9d79bae80b4219c Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 29 Jul 2020 12:32:11 -0500 Subject: [PATCH] Named Query javadoc --- ...SingleIdEntityLoaderProvidedQueryImpl.java | 6 +++--- .../query/hql/spi/NamedHqlQueryMemento.java | 4 ++-- .../query/named/NamedQueryMemento.java | 21 ++++++++++++------- .../query/named/NamedQueryProducer.java | 21 ------------------- .../query/named/NamedQueryRepository.java | 4 ++++ .../named/NamedResultSetMappingMemento.java | 8 +++++++ .../sql/spi/NamedNativeQueryMemento.java | 10 +++++---- 7 files changed, 36 insertions(+), 38 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryProducer.java diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java index 5142b1963c..ab4a61fce5 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java @@ -11,7 +11,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.loader.ast.spi.SingleIdEntityLoader; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.query.named.NamedQueryProducer; +import org.hibernate.query.named.NamedQueryMemento; import org.hibernate.query.named.NamedQueryRepository; import org.hibernate.query.spi.QueryImplementor; import org.hibernate.query.sql.spi.NamedNativeQueryMemento; @@ -24,7 +24,7 @@ import org.hibernate.query.sql.spi.NamedNativeQueryMemento; */ public class SingleIdEntityLoaderProvidedQueryImpl implements SingleIdEntityLoader { private final EntityMappingType entityDescriptor; - private final NamedQueryProducer namedQueryMemento; + private final NamedQueryMemento namedQueryMemento; public SingleIdEntityLoaderProvidedQueryImpl( EntityMappingType entityDescriptor, @@ -38,7 +38,7 @@ public class SingleIdEntityLoaderProvidedQueryImpl implements SingleIdEntityL } } - private static NamedQueryProducer resolveNamedQuery( + private static NamedQueryMemento resolveNamedQuery( String queryName, SessionFactoryImplementor sf) { final NamedQueryRepository namedQueryRepository = sf.getQueryEngine().getNamedQueryRepository(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/spi/NamedHqlQueryMemento.java b/hibernate-core/src/main/java/org/hibernate/query/hql/spi/NamedHqlQueryMemento.java index 1295e459b6..388006893b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/spi/NamedHqlQueryMemento.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/spi/NamedHqlQueryMemento.java @@ -15,14 +15,14 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.query.hql.internal.NamedHqlQueryMementoImpl; import org.hibernate.query.named.AbstractNamedQueryMemento; import org.hibernate.query.named.NameableQuery; -import org.hibernate.query.named.NamedQueryProducer; +import org.hibernate.query.named.NamedQueryMemento; /** * NamedQueryMemento for HQL queries * * @author Steve Ebersole */ -public interface NamedHqlQueryMemento extends NamedQueryProducer { +public interface NamedHqlQueryMemento extends NamedQueryMemento { /** * Informational access to the HQL query string */ diff --git a/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryMemento.java b/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryMemento.java index 0ffb478a90..de73f3b5be 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryMemento.java +++ b/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryMemento.java @@ -12,12 +12,14 @@ import org.hibernate.CacheMode; import org.hibernate.FlushMode; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.query.spi.QueryEngine; +import org.hibernate.query.spi.QueryImplementor; import org.hibernate.query.spi.QueryParameterImplementor; /** - * Named Query mementos are stored in the QueryEngine's - * {@link NamedQueryRepository}. This is the base contract - * for all specific types of named query mementos + * The runtime representation of named queries. They are stored in and + * available through the QueryEngine's {@link NamedQueryRepository}. + * + * This is the base contract for all specific types of named query mementos * * @author Steve Ebersole */ @@ -27,11 +29,6 @@ public interface NamedQueryMemento { */ String getRegistrationName(); - /** - * Makes a copy of the memento - */ - NamedQueryMemento makeCopy(String name); - Boolean getCacheable(); String getCacheRegion(); @@ -52,6 +49,14 @@ public interface NamedQueryMemento { void validate(QueryEngine queryEngine); + /** + * Makes a copy of the memento using the specified registration name + */ + NamedQueryMemento makeCopy(String name); + + QueryImplementor toQuery(SharedSessionContractImplementor session); + QueryImplementor toQuery(SharedSessionContractImplementor session, Class javaType); + interface ParameterMemento { QueryParameterImplementor resolve(SharedSessionContractImplementor session); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryProducer.java b/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryProducer.java deleted file mode 100644 index bb02102496..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryProducer.java +++ /dev/null @@ -1,21 +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 - */ -package org.hibernate.query.named; - -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.query.spi.QueryImplementor; - -/** - * Specialization of NamedQueryMemento for mementos which can produce - * {@link org.hibernate.query.spi.QueryImplementor} implementations - * - * @author Steve Ebersole - */ -public interface NamedQueryProducer extends NamedQueryMemento { - QueryImplementor toQuery(SharedSessionContractImplementor session); - QueryImplementor toQuery(SharedSessionContractImplementor session, Class javaType); -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryRepository.java b/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryRepository.java index 6c68960419..adc0ec594c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryRepository.java +++ b/hibernate-core/src/main/java/org/hibernate/query/named/NamedQueryRepository.java @@ -20,6 +20,10 @@ import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.sql.spi.NamedNativeQueryMemento; /** + * Repository for references to named things related with queries. This includes + * named HQL, JPAQL, native and procedure queries as well as named result-set + * mappings + * * @author Steve Ebersole */ @Incubating diff --git a/hibernate-core/src/main/java/org/hibernate/query/named/NamedResultSetMappingMemento.java b/hibernate-core/src/main/java/org/hibernate/query/named/NamedResultSetMappingMemento.java index a93ea16e55..ff77061b39 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/named/NamedResultSetMappingMemento.java +++ b/hibernate-core/src/main/java/org/hibernate/query/named/NamedResultSetMappingMemento.java @@ -28,7 +28,15 @@ import org.hibernate.query.results.ResultSetMapping; */ @Incubating public interface NamedResultSetMappingMemento { + /** + * The name associated with this memento + */ String getName(); + /** + * Resolve this memento. Generally speaking, this involves building ResultBuilder instances for + * each defined result and registering them with the passed `resultSetMapping`. Any known + * query spaces should be passed to the `querySpaceConsumer` + */ void resolve(ResultSetMapping resultSetMapping, Consumer querySpaceConsumer, SessionFactoryImplementor sessionFactory); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NamedNativeQueryMemento.java b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NamedNativeQueryMemento.java index e22647045e..b2dae89ec0 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NamedNativeQueryMemento.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NamedNativeQueryMemento.java @@ -8,12 +8,12 @@ package org.hibernate.query.sql.spi; import java.util.Set; -import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.query.NamedNativeQueryDefinition; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.query.named.AbstractNamedQueryMemento; -import org.hibernate.query.named.NamedQueryProducer; +import org.hibernate.query.named.NamedQueryMemento; import org.hibernate.query.sql.internal.NamedNativeQueryMementoImpl; /** @@ -21,7 +21,7 @@ import org.hibernate.query.sql.internal.NamedNativeQueryMementoImpl; * * @author Steve Ebersole */ -public interface NamedNativeQueryMemento extends NamedQueryProducer { +public interface NamedNativeQueryMemento extends NamedQueryMemento { /** * Informational access to the SQL query string */ @@ -35,11 +35,13 @@ public interface NamedNativeQueryMemento extends NamedQueryProducer { /** * Convert the memento into an untyped executable query */ - NativeQueryImplementor toQuery(SharedSessionContractImplementor session); + @Override + NativeQueryImplementor toQuery(SharedSessionContractImplementor session); /** * Convert the memento into a typed executable query */ + @Override NativeQueryImplementor toQuery(SharedSessionContractImplementor session, Class resultType); /**