Named Query javadoc

This commit is contained in:
Steve Ebersole 2020-07-29 12:32:11 -05:00
parent 704896614d
commit dc85c75bce
7 changed files with 36 additions and 38 deletions

View File

@ -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<T> implements SingleIdEntityLoader<T> {
private final EntityMappingType entityDescriptor;
private final NamedQueryProducer namedQueryMemento;
private final NamedQueryMemento namedQueryMemento;
public SingleIdEntityLoaderProvidedQueryImpl(
EntityMappingType entityDescriptor,
@ -38,7 +38,7 @@ public class SingleIdEntityLoaderProvidedQueryImpl<T> implements SingleIdEntityL
}
}
private static NamedQueryProducer resolveNamedQuery(
private static NamedQueryMemento resolveNamedQuery(
String queryName,
SessionFactoryImplementor sf) {
final NamedQueryRepository namedQueryRepository = sf.getQueryEngine().getNamedQueryRepository();

View File

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

View File

@ -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);
<T> QueryImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> javaType);
interface ParameterMemento {
QueryParameterImplementor resolve(SharedSessionContractImplementor session);
}

View File

@ -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);
<T> QueryImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> javaType);
}

View File

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

View File

@ -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<String> querySpaceConsumer, SessionFactoryImplementor sessionFactory);
}

View File

@ -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
<T> NativeQueryImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> resultType);
/**