6 - SQM based on JPA type system
- further work on `org.hibernate.query` (especially `NamedQueryRepository` and friends) - initial work on `org.hibernate.sql.exec` - initial work on `org.hibernate.sql.results` - SemanticPathPart handling - NamedQueryMemento
This commit is contained in:
parent
536e5e1a12
commit
43c738ec4e
|
@ -24,7 +24,6 @@ import org.hibernate.procedure.internal.NamedCallableQueryMementoImpl;
|
|||
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
|
||||
import org.hibernate.procedure.spi.ParameterStrategy;
|
||||
import org.hibernate.query.procedure.internal.ProcedureParameterImpl;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import javax.persistence.ParameterMode;
|
||||
|
||||
import org.hibernate.BasicQueryContract;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
|
@ -19,7 +18,6 @@ import org.hibernate.boot.spi.AbstractNamedQueryMapping;
|
|||
import org.hibernate.boot.spi.NamedNativeQueryMapping;
|
||||
import org.hibernate.boot.spi.NamedQueryParameterMapping;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
import org.hibernate.query.sql.internal.NamedNativeQueryMementoImpl;
|
||||
import org.hibernate.query.sql.spi.NamedNativeQueryMemento;
|
||||
|
||||
|
|
|
@ -17,9 +17,7 @@ import javax.persistence.ParameterMode;
|
|||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.boot.internal.NamedNativeQueryMappingImpl;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.boot.spi;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
|
||||
/**
|
||||
* Describes a parameter defined in the mapping of a {@link NamedQueryMapping}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.hibernate.procedure.spi.ParameterRegistrationImplementor;
|
|||
import org.hibernate.procedure.spi.ParameterStrategy;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
import org.hibernate.query.spi.AbstractNamedQueryMemento;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
package org.hibernate.query;
|
||||
|
||||
|
@ -14,7 +14,6 @@ import java.util.Calendar;
|
|||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.LockModeType;
|
||||
import javax.persistence.Parameter;
|
||||
|
@ -25,126 +24,340 @@ import org.hibernate.FlushMode;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.SynchronizeableQuery;
|
||||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.metamodel.model.domain.BasicDomainType;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Represents a native (SQL) query.
|
||||
*
|
||||
* Allows the user to define certain aspects about its execution, such as:<ul>
|
||||
* <li>
|
||||
* result-set value mapping (see below)
|
||||
* </li>
|
||||
* <li>
|
||||
* Tables used via {@link #addSynchronizedQuerySpace}, {@link #addSynchronizedEntityName} and
|
||||
* {@link #addSynchronizedEntityClass}. This allows Hibernate to know how to properly deal with
|
||||
* auto-flush checking as well as cached query results if the results of the query are being
|
||||
* cached.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* In terms of result-set mapping, there are 3 approaches to defining:<ul>
|
||||
* <li>
|
||||
* If this represents a named sql query, the mapping could be associated with the query as part
|
||||
* of its metadata
|
||||
* </li>
|
||||
* <li>
|
||||
* A pre-defined (defined in metadata and named) mapping can be associated via {@link org.hibernate.Session#createNativeQuery(String, String)}
|
||||
* </li>
|
||||
* <li>
|
||||
* Defined locally per the various {@link #addEntity}, {@link #addRoot}, {@link #addJoin},
|
||||
* {@link #addFetch} and {@link #addScalar} methods
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface NativeQuery<T> extends Query<T>, SQLQuery<T>, SynchronizeableQuery<T> {
|
||||
public interface NativeQuery<T> extends Query<T>, SynchronizeableQuery {
|
||||
/**
|
||||
* Declare a scalar query result. Hibernate will attempt to automatically
|
||||
* detect the underlying type.
|
||||
* <p/>
|
||||
* Functions like {@code <return-scalar/>} in {@code hbm.xml} or
|
||||
* {@link javax.persistence.ColumnResult} in annotations
|
||||
*
|
||||
* @param columnAlias The column alias in the result-set to be processed
|
||||
* as a scalar result
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addScalar(String columnAlias);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setFlushMode(FlushMode flushMode);
|
||||
/**
|
||||
* Declare a scalar query result.
|
||||
* <p/>
|
||||
* Functions like {@code <return-scalar/>} in {@code hbm.xml} or
|
||||
* {@link javax.persistence.ColumnResult} in annotations
|
||||
*
|
||||
* @param columnAlias The column alias in the result-set to be processed
|
||||
* as a scalar result
|
||||
* @param type The Hibernate type as which to treat the value.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
default NativeQuery<T> addScalar(String columnAlias, Type type) {
|
||||
return addScalar( columnAlias, (BasicDomainType) type );
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setResultSetMapping(String name);
|
||||
/**
|
||||
* Declare a scalar query result.
|
||||
* <p/>
|
||||
* Functions like {@code <return-scalar/>} in {@code hbm.xml} or
|
||||
* {@link javax.persistence.ColumnResult} in annotations
|
||||
*
|
||||
* @param columnAlias The column alias in the result-set to be processed
|
||||
* as a scalar result
|
||||
* @param type The Hibernate type as which to treat the value.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addScalar(String columnAlias, BasicDomainType type);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val);
|
||||
/**
|
||||
* Add a new root return mapping, returning a {@link RootReturn} to allow
|
||||
* further definition.
|
||||
*
|
||||
* @param tableAlias The SQL table alias to map to this entity
|
||||
* @param entityName The name of the entity.
|
||||
*
|
||||
* @return The return config object for further control.
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
RootReturn addRoot(String tableAlias, String entityName);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(Parameter<P> param, P value);
|
||||
/**
|
||||
* Add a new root return mapping, returning a {@link org.hibernate.query.NativeQuery.RootReturn} to allow further definition.
|
||||
*
|
||||
* @param tableAlias The SQL table alias to map to this entity
|
||||
* @param entityType The java type of the entity.
|
||||
*
|
||||
* @return The return config object for further control.
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
RootReturn addRoot(String tableAlias, Class entityType);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, Type type);
|
||||
/**
|
||||
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the
|
||||
* same as the unqualified entity name
|
||||
* <p/>
|
||||
* Use {@link #addRoot} if you need further control of the mapping
|
||||
*
|
||||
* @param entityName The entity name that is the root return of the query.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addEntity(String entityName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object val, Type type);
|
||||
/**
|
||||
* Declare a "root" entity.
|
||||
*
|
||||
* @param tableAlias The SQL table alias
|
||||
* @param entityName The entity name
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addEntity(String tableAlias, String entityName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object val, Type type);
|
||||
/**
|
||||
* Declare a "root" entity, specifying a lock mode.
|
||||
*
|
||||
* @param tableAlias The SQL table alias
|
||||
* @param entityName The entity name
|
||||
* @param lockMode The lock mode for this return.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addEntity(String tableAlias, String entityName, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType);
|
||||
/**
|
||||
* Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the
|
||||
* same as the unqualified entity name
|
||||
*
|
||||
* @param entityType The java type of the entity to add as a root
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addEntity(Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object val, TemporalType temporalType);
|
||||
/**
|
||||
* Declare a "root" entity.
|
||||
*
|
||||
* @param tableAlias The SQL table alias
|
||||
* @param entityType The java type of the entity to add as a root
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addEntity(String tableAlias, Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object val, TemporalType temporalType);
|
||||
/**
|
||||
* Declare a "root" entity, specifying a lock mode.
|
||||
*
|
||||
* @param tableAlias The SQL table alias
|
||||
* @param entityClass The entity Class
|
||||
* @param lockMode The lock mode for this return.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addEntity(String tableAlias, Class entityClass, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType);
|
||||
/**
|
||||
* Declare a join fetch result.
|
||||
*
|
||||
* @param tableAlias The SQL table alias for the data to be mapped to this fetch
|
||||
* @param ownerTableAlias Identify the table alias of the owner of this association. Should match the alias of a
|
||||
* previously added root or fetch
|
||||
* @param joinPropertyName The name of the property being join fetched.
|
||||
*
|
||||
* @return The return config object for further control.
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
|
||||
/**
|
||||
* Declare a join fetch result.
|
||||
*
|
||||
* @param tableAlias The SQL table alias for the data to be mapped to this fetch
|
||||
* @param path The association path ([owner-alias].[property-name]).
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addJoin(String tableAlias, String path);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object value);
|
||||
/**
|
||||
* Declare a join fetch result.
|
||||
*
|
||||
* @param tableAlias The SQL table alias for the data to be mapped to this fetch
|
||||
* @param ownerTableAlias Identify the table alias of the owner of this association. Should match the alias of a
|
||||
* previously added root or fetch
|
||||
* @param joinPropertyName The name of the property being join fetched.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
NativeQuery<T> addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Calendar value, TemporalType temporalType);
|
||||
/**
|
||||
* Declare a join fetch result, specifying a lock mode.
|
||||
*
|
||||
* @param tableAlias The SQL table alias for the data to be mapped to this fetch
|
||||
* @param path The association path ([owner-alias].[property-name]).
|
||||
* @param lockMode The lock mode for this return.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
NativeQuery<T> addJoin(String tableAlias, String path, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Date value, TemporalType temporalType);
|
||||
/**
|
||||
* Simple unification interface for all returns from the various `#addXYZ` methods .
|
||||
* Allows control over the "shape" of that particular part of the fetch graph.
|
||||
*
|
||||
* Some GraphNodes can be query results, while others simply describe a part
|
||||
* of one of the results.
|
||||
*/
|
||||
interface ResultNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object value);
|
||||
/**
|
||||
* ResultNode which can be a query result
|
||||
*/
|
||||
interface ReturnableResultNode extends ResultNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Calendar value, TemporalType temporalType);
|
||||
/**
|
||||
* Allows access to further control how properties within a root or join
|
||||
* fetch are mapped back from the result set. Generally used in composite
|
||||
* value scenarios.
|
||||
*/
|
||||
interface ReturnProperty extends ResultNode {
|
||||
/**
|
||||
* Add a column alias to this property mapping.
|
||||
*
|
||||
* @param columnAlias The column alias.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
ReturnProperty addColumnAlias(String columnAlias);
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Date value, TemporalType temporalType);
|
||||
/**
|
||||
* Allows access to further control how root returns are mapped back from
|
||||
* result sets.
|
||||
*/
|
||||
interface RootReturn extends ReturnableResultNode {
|
||||
/**
|
||||
* Set the lock mode for this return.
|
||||
*
|
||||
* @param lockMode The new lock mode.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
RootReturn setLockMode(LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType);
|
||||
RootReturn addIdColumnAliases(String... aliases);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<LocalDateTime> param, LocalDateTime value, TemporalType temporalType);
|
||||
/**
|
||||
* Name the column alias that identifies the entity's discriminator.
|
||||
*
|
||||
* @param columnAlias The discriminator column alias
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
RootReturn setDiscriminatorAlias(String columnAlias);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<ZonedDateTime> param, ZonedDateTime value, TemporalType temporalType);
|
||||
/**
|
||||
* Add a simple property-to-one-column mapping.
|
||||
*
|
||||
* @param propertyName The name of the property.
|
||||
* @param columnAlias The name of the column
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
RootReturn addProperty(String propertyName, String columnAlias);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<OffsetDateTime> param, OffsetDateTime value, TemporalType temporalType);
|
||||
/**
|
||||
* Add a property, presumably with more than one column.
|
||||
*
|
||||
* @param propertyName The name of the property.
|
||||
*
|
||||
* @return The config object for further control.
|
||||
*/
|
||||
ReturnProperty addProperty(String propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Instant value, TemporalType temporalType);
|
||||
/**
|
||||
* Allows access to further control how join fetch returns are mapped back
|
||||
* from result sets.
|
||||
*/
|
||||
interface FetchReturn extends ResultNode {
|
||||
/**
|
||||
* Set the lock mode for this return.
|
||||
*
|
||||
* @param lockMode The new lock mode.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
FetchReturn setLockMode(LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, LocalDateTime value, TemporalType temporalType);
|
||||
/**
|
||||
* Add a simple property-to-one-column mapping.
|
||||
*
|
||||
* @param propertyName The name of the property.
|
||||
* @param columnAlias The name of the column
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
FetchReturn addProperty(String propertyName, String columnAlias);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, ZonedDateTime value, TemporalType temporalType);
|
||||
/**
|
||||
* Add a property, presumably with more than one column.
|
||||
*
|
||||
* @param propertyName The name of the property.
|
||||
*
|
||||
* @return The config object for further control.
|
||||
*/
|
||||
ReturnProperty addProperty(String propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Instant value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameterList(QueryParameter<P> parameter, Collection<P> values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Collection values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Collection values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Object[] values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Object[] values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setProperties(Object bean);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setProperties(Map bean);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// covariant overrides - SynchronizeableQuery
|
||||
@Override
|
||||
NativeQuery<T> addSynchronizedQuerySpace(String querySpace);
|
||||
|
||||
|
@ -154,50 +367,9 @@ public interface NativeQuery<T> extends Query<T>, SQLQuery<T>, SynchronizeableQu
|
|||
@Override
|
||||
NativeQuery<T> addSynchronizedEntityClass(Class entityClass) throws MappingException;
|
||||
|
||||
@Override
|
||||
boolean isCallable();
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addScalar(String columnAlias);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addScalar(String columnAlias, Type type);
|
||||
|
||||
@Override
|
||||
RootReturn addRoot(String tableAlias, String entityName);
|
||||
|
||||
@Override
|
||||
RootReturn addRoot(String tableAlias, Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addEntity(String entityName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addEntity(String tableAlias, String entityName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addEntity(String tableAlias, String entityName, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addEntity(Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addEntity(String tableAlias, Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addEntity(String tableAlias, Class entityClass, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addJoin(String tableAlias, String path);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> addJoin(String tableAlias, String path, LockMode lockMode);
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// covariant overrides - Query
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setHibernateFlushMode(FlushMode flushMode);
|
||||
|
@ -246,4 +418,165 @@ public interface NativeQuery<T> extends Query<T>, SQLQuery<T>, SynchronizeableQu
|
|||
|
||||
@Override
|
||||
NativeQuery<T> setLockMode(LockModeType lockMode);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setTupleTransformer(TupleTransformer<T> transformer);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setResultListTransformer(ResultListTransformer transformer);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setResultTransformer(ResultTransformer transformer);
|
||||
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object value);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object value);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<LocalDateTime> param, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<ZonedDateTime> param, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<OffsetDateTime> param, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Instant value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Instant value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, LocalDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, ZonedDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, OffsetDateTime value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(Parameter<P> param, P value);
|
||||
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object val, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object val, Type type);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, Type type);
|
||||
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(
|
||||
Parameter<Calendar> param,
|
||||
Calendar value,
|
||||
TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameterList(QueryParameter<P> parameter, Collection<P> values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Collection values);
|
||||
|
||||
@Override
|
||||
default NativeQuery<T> setParameterList(String name, Collection values, Type type) {
|
||||
return setParameterList( name, values, (AllowableParameterType) type );
|
||||
}
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Collection values, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Object[] values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Object[] values, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Object[] values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(String name, Object val, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameter(int position, Object val, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Collection values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(String name, Collection values, Class type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Collection values, Class type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Collection values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Collection values, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Object[] values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Object[] values, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setParameterList(int position, Object[] values);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setProperties(Object bean);
|
||||
|
||||
@Override
|
||||
NativeQuery<T> setProperties(Map bean);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,8 +12,6 @@ import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
|||
/**
|
||||
* Represents a parameter defined in the source (HQL/JPQL or criteria) query.
|
||||
*
|
||||
* NOTE: Consider this contract (and its sub-contracts) as incubating as we transition to 6.0 and SQM
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Incubating
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.query.hql.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
|
@ -17,8 +16,9 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|||
import org.hibernate.query.hql.spi.HqlQueryImplementor;
|
||||
import org.hibernate.query.hql.spi.NamedHqlQueryMemento;
|
||||
import org.hibernate.query.spi.AbstractNamedQueryMemento;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||
import org.hibernate.query.sqm.internal.QuerySqmImpl;
|
||||
import org.hibernate.type.BasicType;
|
||||
|
||||
/**
|
||||
* Definition of a named query, defined in the mapping metadata.
|
||||
|
@ -31,13 +31,16 @@ import org.hibernate.query.sqm.internal.QuerySqmImpl;
|
|||
*/
|
||||
public class NamedHqlQueryMementoImpl extends AbstractNamedQueryMemento implements NamedHqlQueryMemento, Serializable {
|
||||
private final String hqlString;
|
||||
|
||||
private final Integer firstResult;
|
||||
private final Integer maxResults;
|
||||
|
||||
private final LockOptions lockOptions;
|
||||
private final Map<String, String> parameterTypes;
|
||||
|
||||
public NamedHqlQueryMementoImpl(
|
||||
String name,
|
||||
String hqlString,
|
||||
List<ParameterMemento> parameterMementos,
|
||||
Integer firstResult,
|
||||
Integer maxResults,
|
||||
Boolean cacheable,
|
||||
|
@ -49,10 +52,34 @@ public class NamedHqlQueryMementoImpl extends AbstractNamedQueryMemento implemen
|
|||
Integer timeout,
|
||||
Integer fetchSize,
|
||||
String comment,
|
||||
Map<String,String> parameterTypes,
|
||||
Map<String,Object> hints) {
|
||||
super(
|
||||
name,
|
||||
parameterMementos,
|
||||
cacheable,
|
||||
cacheRegion,
|
||||
cacheMode,
|
||||
flushMode,
|
||||
readOnly,
|
||||
timeout,
|
||||
fetchSize,
|
||||
comment,
|
||||
hints
|
||||
);
|
||||
this.hqlString = hqlString;
|
||||
this.firstResult = firstResult;
|
||||
this.maxResults = maxResults;
|
||||
this.lockOptions = lockOptions;
|
||||
this.parameterTypes = parameterTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedHqlQueryMemento makeCopy(String name) {
|
||||
return new NamedHqlQueryMementoImpl(
|
||||
name,
|
||||
hqlString,
|
||||
firstResult,
|
||||
maxResults,
|
||||
cacheable,
|
||||
cacheRegion,
|
||||
cacheMode,
|
||||
|
@ -62,37 +89,9 @@ public class NamedHqlQueryMementoImpl extends AbstractNamedQueryMemento implemen
|
|||
timeout,
|
||||
fetchSize,
|
||||
comment,
|
||||
parameterTypes,
|
||||
hints
|
||||
);
|
||||
this.hqlString = hqlString;
|
||||
this.firstResult = firstResult;
|
||||
this.maxResults = maxResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHqlString() {
|
||||
return hqlString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedHqlQueryMemento makeCopy(String name) {
|
||||
return new NamedHqlQueryMementoImpl(
|
||||
name,
|
||||
getParameterMementos(),
|
||||
getHqlString(),
|
||||
firstResult,
|
||||
maxResults,
|
||||
getCacheable(),
|
||||
getCacheRegion(),
|
||||
getCacheMode(),
|
||||
getFlushMode(),
|
||||
getReadOnly(),
|
||||
getLockOptions(),
|
||||
getTimeout(),
|
||||
getFetchSize(),
|
||||
getComment(),
|
||||
getHints()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,6 +103,17 @@ public class NamedHqlQueryMementoImpl extends AbstractNamedQueryMemento implemen
|
|||
session
|
||||
);
|
||||
|
||||
for ( Map.Entry<String, String> entry : parameterTypes.entrySet() ) {
|
||||
final BasicType hintedType = session.getFactory()
|
||||
.getMetamodel()
|
||||
.getTypeConfiguration()
|
||||
.getBasicTypeRegistry()
|
||||
.getRegisteredType( entry.getValue() );
|
||||
final QueryParameterImplementor<Object> queryParameter = query.getParameterMetadata().getQueryParameter( entry.getKey() );
|
||||
queryParameter.applyAnticipatedType( hintedType );
|
||||
}
|
||||
|
||||
|
||||
if ( firstResult != null ) {
|
||||
query.setFirstResult( firstResult );
|
||||
}
|
||||
|
|
|
@ -17,16 +17,11 @@ import org.hibernate.query.hql.internal.NamedHqlQueryMementoImpl;
|
|||
import org.hibernate.query.spi.NamedQueryMemento;
|
||||
|
||||
/**
|
||||
* NamedQueryMemento for HQL queries
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface NamedHqlQueryMemento extends NamedQueryMemento {
|
||||
String getHqlString();
|
||||
|
||||
@Override
|
||||
default String getQueryString() {
|
||||
return getHqlString();
|
||||
}
|
||||
|
||||
@Override
|
||||
NamedHqlQueryMemento makeCopy(String name);
|
||||
|
||||
|
@ -34,24 +29,27 @@ public interface NamedHqlQueryMemento extends NamedQueryMemento {
|
|||
<T> HqlQueryImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> resultType);
|
||||
|
||||
/**
|
||||
* Delegate used in creating named HQL query mementos for queries defined in
|
||||
* annotations, hbm.xml or orm.xml
|
||||
* Delegate used in creating named HQL query mementos.
|
||||
*
|
||||
* @see org.hibernate.boot.spi.NamedHqlQueryMapping
|
||||
* @see HqlQueryImplementor#toMemento
|
||||
*/
|
||||
class Builder {
|
||||
protected String name;
|
||||
protected String query;
|
||||
protected String queryString;
|
||||
protected boolean cacheable;
|
||||
protected String cacheRegion;
|
||||
protected CacheMode cacheMode;
|
||||
protected Integer timeout;
|
||||
protected Integer fetchSize;
|
||||
protected FlushMode flushMode;
|
||||
protected CacheMode cacheMode;
|
||||
protected boolean readOnly;
|
||||
protected String comment;
|
||||
protected Map parameterTypes;
|
||||
protected LockOptions lockOptions;
|
||||
protected Integer firstResult;
|
||||
protected Integer maxResults;
|
||||
protected Map<String,String> parameterTypes;
|
||||
protected Map<String,Object> hints;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
@ -65,8 +63,8 @@ public interface NamedHqlQueryMemento extends NamedQueryMemento {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setQuery(String query) {
|
||||
this.query = query;
|
||||
public Builder setQuery(String queryString) {
|
||||
this.queryString = queryString;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -112,13 +110,13 @@ public interface NamedHqlQueryMemento extends NamedQueryMemento {
|
|||
|
||||
public Builder addParameterType(String name, String typeName) {
|
||||
if ( this.parameterTypes == null ) {
|
||||
this.parameterTypes = new HashMap();
|
||||
this.parameterTypes = new HashMap<>();
|
||||
}
|
||||
this.parameterTypes.put( name, typeName );
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setParameterTypes(Map parameterTypes) {
|
||||
public Builder setParameterTypes(Map<String,String> parameterTypes) {
|
||||
this.parameterTypes = parameterTypes;
|
||||
return this;
|
||||
}
|
||||
|
@ -141,19 +139,20 @@ public interface NamedHqlQueryMemento extends NamedQueryMemento {
|
|||
public NamedHqlQueryMemento createNamedQueryDefinition() {
|
||||
return new NamedHqlQueryMementoImpl(
|
||||
name,
|
||||
query,
|
||||
queryString,
|
||||
firstResult,
|
||||
maxResults,
|
||||
cacheable,
|
||||
cacheRegion,
|
||||
timeout,
|
||||
lockOptions,
|
||||
fetchSize,
|
||||
flushMode,
|
||||
cacheMode,
|
||||
flushMode,
|
||||
readOnly,
|
||||
lockOptions,
|
||||
timeout,
|
||||
fetchSize,
|
||||
comment,
|
||||
parameterTypes,
|
||||
firstResult,
|
||||
maxResults
|
||||
hints
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,61 +12,51 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.ParameterMode;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.procedure.internal.Util;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
* @author Gavin King
|
||||
*/
|
||||
public abstract class AbstractNamedQueryMemento implements NamedQueryMemento {
|
||||
private final String name;
|
||||
protected final String name;
|
||||
|
||||
private final List<? extends ParameterMemento> parameterMementos;
|
||||
protected final Boolean cacheable;
|
||||
protected final String cacheRegion;
|
||||
protected final CacheMode cacheMode;
|
||||
|
||||
private final Boolean cacheable;
|
||||
private final String cacheRegion;
|
||||
private final CacheMode cacheMode;
|
||||
protected final FlushMode flushMode;
|
||||
protected final Boolean readOnly;
|
||||
|
||||
private final FlushMode flushMode;
|
||||
private final Boolean readOnly;
|
||||
protected final Integer timeout;
|
||||
protected final Integer fetchSize;
|
||||
|
||||
private final LockOptions lockOptions;
|
||||
protected final String comment;
|
||||
|
||||
private final Integer timeout;
|
||||
private final Integer fetchSize;
|
||||
protected final Map<String, Object> hints;
|
||||
|
||||
private final String comment;
|
||||
|
||||
private final Map<String, Object> hints;
|
||||
|
||||
public AbstractNamedQueryMemento(
|
||||
protected AbstractNamedQueryMemento(
|
||||
String name,
|
||||
List<? extends ParameterMemento> parameterMementos,
|
||||
Boolean cacheable,
|
||||
String cacheRegion,
|
||||
CacheMode cacheMode,
|
||||
FlushMode flushMode,
|
||||
Boolean readOnly,
|
||||
LockOptions lockOptions,
|
||||
Integer timeout,
|
||||
Integer fetchSize,
|
||||
String comment,
|
||||
Map<String, Object> hints) {
|
||||
this.name = name;
|
||||
this.parameterMementos = parameterMementos;
|
||||
this.cacheable = cacheable;
|
||||
this.cacheRegion = cacheRegion;
|
||||
this.cacheMode = cacheMode;
|
||||
this.flushMode = flushMode;
|
||||
this.readOnly = readOnly;
|
||||
this.lockOptions = lockOptions;
|
||||
this.timeout = timeout;
|
||||
this.fetchSize = fetchSize;
|
||||
this.comment = comment;
|
||||
|
@ -78,66 +68,10 @@ public abstract class AbstractNamedQueryMemento implements NamedQueryMemento {
|
|||
return name;
|
||||
}
|
||||
|
||||
public List<ParameterMemento> getParameterMementos() {
|
||||
return parameterMementos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getCacheable() {
|
||||
return cacheable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheRegion() {
|
||||
return cacheRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheMode getCacheMode() {
|
||||
return cacheMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlushMode getFlushMode() {
|
||||
return flushMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LockOptions getLockOptions() {
|
||||
return lockOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getFetchSize() {
|
||||
return fetchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
||||
protected Map<String, Object> getHintsCopy() {
|
||||
return Util.copy( hints );
|
||||
}
|
||||
|
||||
protected void applyBaseOptions(QueryImplementor query, SharedSessionContractImplementor session) {
|
||||
getHints().forEach( query::setHint );
|
||||
if ( hints != null ) {
|
||||
hints.forEach( query::setHint );
|
||||
}
|
||||
|
||||
if ( cacheable != null ) {
|
||||
query.setCacheable( cacheable );
|
||||
|
@ -159,10 +93,6 @@ public abstract class AbstractNamedQueryMemento implements NamedQueryMemento {
|
|||
query.setReadOnly( readOnly );
|
||||
}
|
||||
|
||||
if ( lockOptions != null ) {
|
||||
query.setLockOptions( lockOptions );
|
||||
}
|
||||
|
||||
if ( timeout != null ) {
|
||||
query.setTimeout( timeout );
|
||||
}
|
||||
|
@ -179,8 +109,6 @@ public abstract class AbstractNamedQueryMemento implements NamedQueryMemento {
|
|||
protected static abstract class AbstractBuilder<T extends AbstractBuilder> {
|
||||
private final String name;
|
||||
|
||||
private List<ParameterDefinition> parameterDescriptors;
|
||||
|
||||
private Set<String> querySpaces;
|
||||
private Boolean cacheable;
|
||||
private String cacheRegion;
|
||||
|
@ -189,8 +117,6 @@ public abstract class AbstractNamedQueryMemento implements NamedQueryMemento {
|
|||
private FlushMode flushMode;
|
||||
private Boolean readOnly;
|
||||
|
||||
private LockOptions lockOptions;
|
||||
|
||||
private Integer timeout;
|
||||
private Integer fetchSize;
|
||||
|
||||
|
@ -208,40 +134,6 @@ public abstract class AbstractNamedQueryMemento implements NamedQueryMemento {
|
|||
|
||||
protected abstract T getThis();
|
||||
|
||||
public T addParameter(Class javaType, ParameterMode mode) {
|
||||
return addParameter(
|
||||
createPositionalParameter(
|
||||
parameterDescriptors.size() + 1,
|
||||
javaType,
|
||||
mode
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected abstract ParameterDefinition createPositionalParameter(int i, Class javaType, ParameterMode mode);
|
||||
|
||||
public T addParameter(ParameterDefinition parameterDefinition) {
|
||||
if ( parameterDescriptors == null ) {
|
||||
parameterDescriptors = new ArrayList<>();
|
||||
}
|
||||
|
||||
parameterDescriptors.add( parameterDefinition );
|
||||
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public T addParameter(String name, Class javaType, ParameterMode mode) {
|
||||
if ( parameterDescriptors == null ) {
|
||||
parameterDescriptors = new ArrayList<>();
|
||||
}
|
||||
|
||||
parameterDescriptors.add( createNamedParameter( name, javaType, mode ) );
|
||||
|
||||
return getThis();
|
||||
}
|
||||
|
||||
protected abstract ParameterDefinition createNamedParameter(String name, Class javaType, ParameterMode mode);
|
||||
|
||||
|
||||
public T addQuerySpaces(Set<String> querySpaces) {
|
||||
if ( querySpaces == null || querySpaces.isEmpty() ) {
|
||||
|
|
|
@ -6,45 +6,26 @@
|
|||
*/
|
||||
package org.hibernate.query.spi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* Base contract for all named query mementos
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface NamedQueryMemento {
|
||||
/**
|
||||
* The name under which the query is registered
|
||||
*/
|
||||
String getName();
|
||||
|
||||
String getQueryString();
|
||||
|
||||
List<ParameterMemento> getParameterMementos();
|
||||
|
||||
Boolean getCacheable();
|
||||
|
||||
String getCacheRegion();
|
||||
|
||||
CacheMode getCacheMode();
|
||||
|
||||
FlushMode getFlushMode();
|
||||
|
||||
Boolean getReadOnly();
|
||||
|
||||
LockOptions getLockOptions();
|
||||
|
||||
Integer getTimeout();
|
||||
|
||||
Integer getFetchSize();
|
||||
|
||||
String getComment();
|
||||
|
||||
Map<String,Object> getHints();
|
||||
|
||||
/**
|
||||
* Makes a copy of the memento
|
||||
*/
|
||||
NamedQueryMemento makeCopy(String name);
|
||||
|
||||
/**
|
||||
* Convert the memento into an executable query
|
||||
*/
|
||||
<T> QueryImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> resultType);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public interface NamedQueryRepository {
|
|||
NamedHqlQueryMemento getHqlQueryMemento(String queryName);
|
||||
void visitHqlQueryMementos(Consumer<NamedHqlQueryMemento> action);
|
||||
void registerHqlQueryMemento(String name, NamedHqlQueryMemento descriptor);
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// NamedNativeQueryMemento
|
||||
|
||||
|
|
|
@ -1,186 +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.spi;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import javax.persistence.Parameter;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Incubating
|
||||
public interface NativeQueryImplementor<T> extends QueryImplementor<T>, NativeQuery<T> {
|
||||
NativeQueryImplementor setCollectionKey(Serializable key);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// overrides
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addScalar(String columnAlias);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addScalar(String columnAlias, Type type);
|
||||
|
||||
@Override
|
||||
RootReturn addRoot(String tableAlias, String entityName);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addEntity(String entityName);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addEntity(String tableAlias, String entityName);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addEntity(String tableAlias, String entityName, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addEntity(Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addEntity(String tableAlias, Class entityType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addEntity(String tableAlias, Class entityClass, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addJoin(String tableAlias, String path);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addJoin(String tableAlias, String path, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setHibernateFlushMode(FlushMode flushMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setCacheMode(CacheMode cacheMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setCacheable(boolean cacheable);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setCacheRegion(String cacheRegion);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setTimeout(int timeout);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setFetchSize(int fetchSize);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setReadOnly(boolean readOnly);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setLockOptions(LockOptions lockOptions);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setLockMode(String alias, LockMode lockMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setComment(String comment);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addQueryHint(String hint);
|
||||
|
||||
@Override
|
||||
<P> NativeQueryImplementor<T> setParameter(QueryParameter<P> parameter, P val);
|
||||
|
||||
@Override
|
||||
<P> NativeQueryImplementor<T> setParameter(Parameter<P> param, P value);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(String name, Object val);
|
||||
|
||||
@Override
|
||||
<P> NativeQueryImplementor<T> setParameter(QueryParameter<P> parameter, P val, Type type);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(int position, Object val);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(String name, Object val, Type type);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(int position, Object val, Type type);
|
||||
|
||||
@Override
|
||||
<P> NativeQueryImplementor<T> setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(String name, Object val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(int position, Object val, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
<P> NativeQueryImplementor<T> setParameterList(QueryParameter<P> parameter, Collection<P> values);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameterList(String name, Collection values);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameterList(String name, Collection values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameterList(String name, Object[] values, Type type);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameterList(String name, Object[] values);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setProperties(Object bean);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setProperties(Map bean);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(Parameter<Date> param, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(String name, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(String name, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(int position, Calendar value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setParameter(int position, Date value, TemporalType temporalType);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addSynchronizedQuerySpace(String querySpace);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addSynchronizedEntityName(String entityName) throws MappingException;
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> setFlushMode(FlushMode flushMode);
|
||||
|
||||
@Override
|
||||
NativeQueryImplementor<T> addSynchronizedEntityClass(Class entityClass) throws MappingException;
|
||||
}
|
|
@ -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
|
||||
*/
|
||||
package org.hibernate.query.spi;
|
||||
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ParameterMemento {
|
||||
QueryParameter toQueryParameter(SharedSessionContractImplementor session);
|
||||
}
|
|
@ -110,7 +110,7 @@ public class QueryEngine {
|
|||
public void prepare(SessionFactoryImplementor sessionFactory) {
|
||||
//checking for named queries
|
||||
if ( sessionFactory.getSessionFactoryOptions().isNamedQueryStartupCheckingEnabled() ) {
|
||||
final Map<String, HibernateException> errors = namedQueryRepository.checkNamedQueries( queryPlanCache );
|
||||
final Map<String, HibernateException> errors = namedQueryRepository.checkNamedQueries( this );
|
||||
|
||||
if ( !errors.isEmpty() ) {
|
||||
StringBuilder failingQueries = new StringBuilder( "Errors in named queries: " );
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.query.spi;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
|
||||
/**
|
||||
|
@ -14,5 +15,5 @@ import org.hibernate.query.QueryParameter;
|
|||
public interface QueryParameterImplementor<T> extends QueryParameter<T> {
|
||||
void disallowMultiValuedBinding();
|
||||
|
||||
ParameterMemento toMemento();
|
||||
void applyAnticipatedType(AllowableParameterType type);
|
||||
}
|
||||
|
|
|
@ -6,18 +6,15 @@
|
|||
*/
|
||||
package org.hibernate.query.sql.internal;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.query.spi.AbstractNamedQueryMemento;
|
||||
import org.hibernate.query.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
import org.hibernate.query.sql.spi.NamedNativeQueryMemento;
|
||||
import org.hibernate.query.sql.spi.NativeQueryImplementor;
|
||||
|
||||
/**
|
||||
* Keeps details of a named native-sql query
|
||||
|
@ -34,27 +31,23 @@ public class NamedNativeQueryMementoImpl extends AbstractNamedQueryMemento imple
|
|||
String name,
|
||||
String sqlString,
|
||||
String resultSetMappingName,
|
||||
List<ParameterMemento> parameterMementos,
|
||||
Set<String> querySpaces,
|
||||
Boolean cacheable,
|
||||
String cacheRegion,
|
||||
CacheMode cacheMode,
|
||||
FlushMode flushMode,
|
||||
Boolean readOnly,
|
||||
LockOptions lockOptions,
|
||||
Integer timeout,
|
||||
Integer fetchSize,
|
||||
String comment,
|
||||
Map<String,Object> hints) {
|
||||
super(
|
||||
name,
|
||||
parameterMementos,
|
||||
cacheable,
|
||||
cacheRegion,
|
||||
cacheMode,
|
||||
flushMode,
|
||||
readOnly,
|
||||
lockOptions,
|
||||
timeout,
|
||||
fetchSize,
|
||||
comment,
|
||||
|
@ -70,21 +63,6 @@ public class NamedNativeQueryMementoImpl extends AbstractNamedQueryMemento imple
|
|||
return sqlString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString() {
|
||||
return sqlString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResultSetMappingName() {
|
||||
return resultSetMappingName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getQuerySpaces() {
|
||||
return querySpaces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryMemento makeCopy(String name) {
|
||||
return new NamedNativeQueryMementoImpl(
|
||||
|
|
|
@ -53,7 +53,7 @@ import org.hibernate.query.NativeQuery;
|
|||
import org.hibernate.query.ParameterMetadata;
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
import org.hibernate.query.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.sql.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.spi.QueryParameterBindings;
|
||||
import org.hibernate.query.spi.ScrollableResultsImplementor;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.query.sql.spi;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.query.spi.NamedQueryMemento;
|
||||
import org.hibernate.query.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.sql.internal.NamedNativeQueryMementoImpl;
|
||||
|
||||
/**
|
||||
* Descriptor for a named native query in the run-time environment
|
||||
|
@ -20,13 +22,131 @@ import org.hibernate.query.spi.NativeQueryImplementor;
|
|||
public interface NamedNativeQueryMemento extends NamedQueryMemento {
|
||||
String getSqlString();
|
||||
|
||||
String getResultSetMappingName();
|
||||
|
||||
Set<String> getQuerySpaces();
|
||||
|
||||
@Override
|
||||
NamedNativeQueryMemento makeCopy(String name);
|
||||
|
||||
@Override
|
||||
<T> NativeQueryImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> resultType);
|
||||
|
||||
|
||||
/**
|
||||
* Delegate used in creating named HQL query mementos.
|
||||
*
|
||||
* @see org.hibernate.boot.spi.NamedNativeQueryMapping
|
||||
*/
|
||||
class Builder {
|
||||
protected String name;
|
||||
protected String queryString;
|
||||
protected boolean cacheable;
|
||||
protected String cacheRegion;
|
||||
protected CacheMode cacheMode;
|
||||
protected Integer timeout;
|
||||
protected Integer fetchSize;
|
||||
protected FlushMode flushMode;
|
||||
protected boolean readOnly;
|
||||
protected String comment;
|
||||
protected Integer firstResult;
|
||||
protected Integer maxResults;
|
||||
|
||||
private Collection<String> querySpaces;
|
||||
private String resultSetMappingName;
|
||||
private String resultSetMappingClassName;
|
||||
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
public Builder(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Builder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setQuery(String queryString) {
|
||||
this.queryString = queryString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCacheable(boolean cacheable) {
|
||||
this.cacheable = cacheable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCacheRegion(String cacheRegion) {
|
||||
this.cacheRegion = cacheRegion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCacheMode(CacheMode cacheMode) {
|
||||
this.cacheMode = cacheMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setTimeout(Integer timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFetchSize(Integer fetchSize) {
|
||||
this.fetchSize = fetchSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFlushMode(FlushMode flushMode) {
|
||||
this.flushMode = flushMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setComment(String comment) {
|
||||
this.comment = comment;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFirstResult(Integer firstResult) {
|
||||
this.firstResult = firstResult;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaxResults(Integer maxResults) {
|
||||
this.maxResults = maxResults;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setQuerySpaces(Collection<String> querySpaces) {
|
||||
this.querySpaces = querySpaces;
|
||||
}
|
||||
|
||||
public void setResultSetMappingName(String resultSetMappingName) {
|
||||
this.resultSetMappingName = resultSetMappingName;
|
||||
}
|
||||
|
||||
public void setResultSetMappingClassName(String resultSetMappingClassName) {
|
||||
this.resultSetMappingClassName = resultSetMappingClassName;
|
||||
}
|
||||
|
||||
public NamedNativeQueryMemento createNamedQueryDefinition() {
|
||||
return new NamedNativeQueryMementoImpl(
|
||||
name,
|
||||
queryString,
|
||||
cacheable,
|
||||
cacheRegion,
|
||||
timeout,
|
||||
fetchSize,
|
||||
flushMode,
|
||||
cacheMode,
|
||||
readOnly,
|
||||
comment,
|
||||
firstResult,
|
||||
maxResults
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,29 +26,21 @@ import org.hibernate.Incubating;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.hibernate.query.QueryParameter;
|
||||
import org.hibernate.query.ResultListTransformer;
|
||||
import org.hibernate.query.TupleTransformer;
|
||||
import org.hibernate.query.spi.NameableQuery;
|
||||
import org.hibernate.query.spi.ParameterMetadataImplementor;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Incubating
|
||||
public interface NativeQueryImplementor<R> extends QueryImplementor<R>, NativeQuery<R>, NameableQuery {
|
||||
public interface NativeQueryImplementor<R> extends QueryImplementor<R>, NativeQuery<R> {
|
||||
NativeQueryImplementor setCollectionKey(Serializable key);
|
||||
|
||||
@Override
|
||||
NamedNativeQueryMemento toMemento(String name, SessionFactoryImplementor factory);
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// covariant overrides - NativeQuery
|
||||
|
||||
|
@ -166,7 +158,6 @@ public interface NativeQueryImplementor<R> extends QueryImplementor<R>, NativeQu
|
|||
return setParameter( parameter, val, (AllowableParameterType) type );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
<P> NativeQueryImplementor<R> setParameter(QueryParameter<P> parameter, P val, AllowableParameterType type);
|
||||
|
||||
|
@ -181,9 +172,6 @@ public interface NativeQueryImplementor<R> extends QueryImplementor<R>, NativeQu
|
|||
@Override
|
||||
NativeQueryImplementor<R> setParameter(String name, Object val, AllowableParameterType type);
|
||||
|
||||
@Override
|
||||
ParameterMetadataImplementor<QueryParameterImplementor<?>> getParameterMetadata();
|
||||
|
||||
@Override
|
||||
default NativeQueryImplementor<R> setParameter(int position, Object val, Type type) {
|
||||
return setParameter( position, val, (AllowableParameterType) type );
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.hibernate.query.hql.spi.HqlQueryImplementor;
|
|||
import org.hibernate.query.internal.ParameterMetadataImpl;
|
||||
import org.hibernate.query.internal.QueryParameterBindingsImpl;
|
||||
import org.hibernate.query.hql.spi.NamedHqlQueryMemento;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
import org.hibernate.query.spi.NonSelectQueryPlan;
|
||||
import org.hibernate.query.spi.ParameterMetadataImplementor;
|
||||
import org.hibernate.query.spi.QueryOptions;
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.query.sqm.tree.expression;
|
|||
|
||||
import org.hibernate.metamodel.model.domain.AllowableParameterType;
|
||||
import org.hibernate.query.ParameterMetadata;
|
||||
import org.hibernate.query.spi.ParameterMemento;
|
||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.transform;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.query.ResultListTransformer;
|
||||
import org.hibernate.query.TupleTransformer;
|
||||
|
||||
/**
|
||||
* Implementors define a strategy for transforming query results into the
|
||||
|
@ -16,27 +19,12 @@ import java.util.List;
|
|||
* @see org.hibernate.Query#setResultTransformer(ResultTransformer)
|
||||
*
|
||||
* @author Gavin King
|
||||
*
|
||||
* @deprecated ResultTransformer is no longer supported. It has been split
|
||||
* into {@link TupleTransformer} and {@link ResultListTransformer} to define
|
||||
* functional interfaces.
|
||||
*/
|
||||
public interface ResultTransformer extends Serializable {
|
||||
/**
|
||||
* Tuples are the elements making up each "row" of the query result.
|
||||
* The contract here is to transform these elements into the final
|
||||
* row.
|
||||
*
|
||||
* @param tuple The result elements
|
||||
* @param aliases The result aliases ("parallel" array to tuple)
|
||||
* @return The transformed row.
|
||||
*/
|
||||
public Object transformTuple(Object[] tuple, String[] aliases);
|
||||
|
||||
/**
|
||||
* Here we have an opportunity to perform transformation on the
|
||||
* query result as a whole. This might be useful to convert from
|
||||
* one collection type to another or to remove duplicates from the
|
||||
* result, etc.
|
||||
*
|
||||
* @param collection The result.
|
||||
* @return The transformed result.
|
||||
*/
|
||||
public List transformList(List collection);
|
||||
@Deprecated
|
||||
public interface ResultTransformer extends TupleTransformer, ResultListTransformer, Serializable {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue