Package org.hibernate.query
Interface QueryProducer
-
- All Known Subinterfaces:
EventSource,QueryProducerImplementor,Session,SessionImplementor,SharedSessionContract,SharedSessionContractImplementor,StatelessSession
- All Known Implementing Classes:
SessionDelegatorBaseImpl,SessionLazyDelegator
public interface QueryProducerContract for things that can produce instances ofQueryandNativeQuery. Implementors includeSessionandStatelessSession. Many operations of the interface have the same or very similar signatures to operations ofEntityManager. They are declared here to allow reuse byStatelessSession.Unlike the corresponding operations of
EntityManager, operations for creating untyped instances ofQueryare all marked as deprecated. Clients must migrate to the use of the equivalent operations which accept aClassand return a typedQuery.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description MutationQuerycreateMutationQuery(CriteriaDelete deleteQuery)Create aMutationQueryfrom the given delete criteria treeMutationQuerycreateMutationQuery(CriteriaUpdate updateQuery)Create aMutationQueryfrom the given update criteria treeMutationQuerycreateMutationQuery(String hqlString)Create a MutationQuery reference for the given HQL insert, update, or delete statement.MutationQuerycreateNamedMutationQuery(String name)Create aMutationQueryinstance for the given named insert, update, or delete HQL query.QuerycreateNamedQuery(String name)Deprecated.<R> Query<R>createNamedQuery(String name, Class<R> resultClass)Create a typedQueryinstance for the given named query.SelectionQuery<?>createNamedSelectionQuery(String name)Create aSelectionQueryinstance for the namedNamedQuery<R> SelectionQuery<R>createNamedSelectionQuery(String name, Class<R> resultType)Create aSelectionQueryinstance for the namedNamedQuerywith the expected result-typeMutationQuerycreateNativeMutationQuery(String sqlString)Create aNativeQueryinstance for the given native (SQL) statementNativeQuerycreateNativeQuery(String sqlString)Deprecated.<R> NativeQuery<R>createNativeQuery(String sqlString, Class<R> resultClass)Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.<R> NativeQuery<R>createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias)Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.NativeQuerycreateNativeQuery(String sqlString, String resultSetMappingName)Deprecated.<R> NativeQuery<R>createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass)Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.QuerycreateQuery(CriteriaDelete deleteQuery)Deprecated.<R> Query<R>createQuery(CriteriaQuery<R> criteriaQuery)Create aQueryfor the given JPACriteriaQueryQuerycreateQuery(CriteriaUpdate updateQuery)Deprecated.QuerycreateQuery(String queryString)Deprecated.usecreateQuery(String, Class),createSelectionQuery(java.lang.String)orcreateMutationQuery(String)depending on intention<R> Query<R>createQuery(String queryString, Class<R> resultClass)Create a typedQueryinstance for the given HQL query string.<R> SelectionQuery<R>createSelectionQuery(CriteriaQuery<R> criteria)Create aSelectionQueryreference for the given Criteria.SelectionQuery<?>createSelectionQuery(String hqlString)Create aSelectionQueryreference for the given HQL.<R> SelectionQuery<R>createSelectionQuery(String hqlString, Class<R> resultType)Create aSelectionQueryreference for the given HQL.NativeQuerygetNamedNativeQuery(String name)Deprecated.NativeQuerygetNamedNativeQuery(String name, String resultSetMapping)Deprecated.QuerygetNamedQuery(String queryName)Deprecated.
-
-
-
Method Detail
-
createQuery
@Deprecated(since="6.0") Query createQuery(String queryString)
Deprecated.usecreateQuery(String, Class),createSelectionQuery(java.lang.String)orcreateMutationQuery(String)depending on intentionCreate aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.- Parameters:
queryString- The HQL query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String)- "API Note:"
- Returns a raw
Querytype instead of a wildcard typeQuery<?>, to match the signature of the JPA methodEntityManager.createQuery(String).
-
createQuery
<R> Query<R> createQuery(String queryString, Class<R> resultClass)
Create a typedQueryinstance for the given HQL query string.The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Parameters:
queryString- The HQL queryresultClass- The type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String,Class)
-
createQuery
<R> Query<R> createQuery(CriteriaQuery<R> criteriaQuery)
Create aQueryfor the given JPACriteriaQuery
-
createQuery
@Deprecated(since="6.0") Query createQuery(CriteriaUpdate updateQuery)
Deprecated.Create aMutationQueryfor the given JPACriteriaUpdate
-
createQuery
@Deprecated(since="6.0") Query createQuery(CriteriaDelete deleteQuery)
Deprecated.Create aMutationQueryfor the given JPACriteriaDelete
-
createNativeQuery
@Deprecated(since="6.0") NativeQuery createNativeQuery(String sqlString)
Deprecated.Create aNativeQueryinstance for the given native (SQL) query- Parameters:
sqlString- a native SQL query string- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String)
-
createNativeQuery
<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass)
Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.If the given class is an entity class, this method is equivalent to
createNativeQuery(sqlString).addEntity("alias1", resultClass).- Parameters:
sqlString- The native (SQL) query stringresultClass- The Java entity type to map results to- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias)
Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.If the given class is an entity class, this method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass).- Parameters:
sqlString- Native (SQL) query stringresultClass- The Java entity type to map results totableAlias- The table alias for columns in the result set- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
@Deprecated(since="6.0") NativeQuery createNativeQuery(String sqlString, String resultSetMappingName)
Deprecated.Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class),SqlResultSetMapping
-
createNativeQuery
<R> NativeQuery<R> createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass)
Create aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class),SqlResultSetMapping
-
createSelectionQuery
SelectionQuery<?> createSelectionQuery(String hqlString)
Create aSelectionQueryreference for the given HQL. Only valid for select queries- Throws:
IllegalSelectQueryException- if the given HQL query is an insert, update or delete query- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
<R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> resultType)
Create aSelectionQueryreference for the given HQL. Only valid for select queries- Throws:
IllegalSelectQueryException- if the given HQL query is an insert, update or delete query- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
<R> SelectionQuery<R> createSelectionQuery(CriteriaQuery<R> criteria)
Create aSelectionQueryreference for the given Criteria.- See Also:
EntityManager.createQuery(CriteriaQuery)
-
createMutationQuery
MutationQuery createMutationQuery(String hqlString)
Create a MutationQuery reference for the given HQL insert, update, or delete statement.- Throws:
IllegalMutationQueryException- if the given HQL query is a select query
-
createMutationQuery
MutationQuery createMutationQuery(CriteriaUpdate updateQuery)
Create aMutationQueryfrom the given update criteria tree
-
createMutationQuery
MutationQuery createMutationQuery(CriteriaDelete deleteQuery)
Create aMutationQueryfrom the given delete criteria tree
-
createNativeMutationQuery
MutationQuery createNativeMutationQuery(String sqlString)
Create aNativeQueryinstance for the given native (SQL) statement- Parameters:
sqlString- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedQuery
@Deprecated(since="6.0") Query createNamedQuery(String name)
Deprecated.Create a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Parameters:
name- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution - Throws:
IllegalArgumentException- if a query has not been defined with the given name or if the query string is found to be invalid- See Also:
EntityManager.createNamedQuery(String)
-
createNamedQuery
<R> Query<R> createNamedQuery(String name, Class<R> resultClass)
Create a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Parameters:
name- the name of a query defined in metadataresultClass- the type of the query result- Returns:
- The
Queryinstance for manipulation and execution - Throws:
IllegalArgumentException- if a query has not been defined with the given name or if the query string is found to be invalid or if the query result is found to not be assignable to the specified type- See Also:
EntityManager.createNamedQuery(String,Class)
-
createNamedSelectionQuery
SelectionQuery<?> createNamedSelectionQuery(String name)
Create aSelectionQueryinstance for the namedNamedQuery- Throws:
IllegalSelectQueryException- if the given HQL query is a select queryUnknownNamedQueryException- if no query has been defined with the given name
-
createNamedSelectionQuery
<R> SelectionQuery<R> createNamedSelectionQuery(String name, Class<R> resultType)
Create aSelectionQueryinstance for the namedNamedQuerywith the expected result-type- Throws:
IllegalSelectQueryException- if the given HQL query is a select queryUnknownNamedQueryException- if no query has been defined with the given name
-
createNamedMutationQuery
MutationQuery createNamedMutationQuery(String name)
Create aMutationQueryinstance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Throws:
IllegalMutationQueryException- if the given HQL query is a select queryUnknownNamedQueryException- if no query has been defined with the given name
-
getNamedQuery
@Deprecated(since="6.0") Query getNamedQuery(String queryName)
Deprecated.Create aQueryinstance for the named query.- Parameters:
queryName- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution - Throws:
IllegalArgumentException- if a query has not been defined with the given name or if the query string is found to be invalid
-
getNamedNativeQuery
@Deprecated(since="6.0") NativeQuery getNamedNativeQuery(String name)
Deprecated.Get aNativeQueryinstance for a named native SQL query- Parameters:
name- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
@Deprecated(since="6.0") NativeQuery getNamedNativeQuery(String name, String resultSetMapping)
Deprecated.Get aNativeQueryinstance for a named native SQL query- Parameters:
name- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
-