Top Description Methods
org.hibernate.query

public Interface QueryProducer

Known Direct Subinterfaces
org.hibernate.query.spi.QueryProducerImplementor, org.hibernate.jpa.HibernateEntityManager, org.hibernate.SharedSessionContract
Imports
org.hibernate.SQLQuery, javax.persistence.criteria.CriteriaDelete, .CriteriaQuery, .CriteriaUpdate

Contract for things that can produce Query instances. Expected implementors include Session and StatelessSession.

It defines these query creation methods in the signature defined by EntityManager. In a way it defines a subset of the EntityManager contract to be reused by both Session and StatelessSession.

Author
Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public Query<R>

Returns:

The Query instance for manipulation and execution
createNamedQuery
(String
the name of a pre-defined, named query
name
)

Deprecated as a consequence of Query being deprecated.
The JPA-defined named query creation method.
public <R> Query<R>

Returns:

The Query instance for manipulation and execution
createNamedQuery
(String
the name of a query defined in metadata
name
,
Class<R>
the type of the query result
resultClass
)

Deprecated as a consequence of Query being deprecated.
The JPA-defined named, typed query creation method.
public NativeQuery<T>

Returns:

The NativeQuery instance for manipulation and execution
createNativeQuery
(String
a native SQL query string
sqlString
)

Deprecated as a consequence of NativeQuery being deprecated.
Create a NativeQuery instance for the given native (SQL) query
public <R> NativeQuery<R>

Returns:

The NativeQuery instance for manipulation and execution
createNativeQuery
(String
Native (SQL) query string
sqlString
,
Class<R>
The Java entity type to map results to
resultClass
)

Deprecated as a consequence of NativeQuery being deprecated.
Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.
public NativeQuery<T>

Returns:

The NativeQuery instance for manipulation and execution
createNativeQuery
(String
Native (SQL) query string
sqlString
,
String
The explicit (named) result mapping
resultSetMapping
)

Deprecated as a consequence of NativeQuery being deprecated.
Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.
public Query<R>

Returns:

The Query instance for manipulation and execution
createQuery
(String
The HQL/JPQL query
queryString
)

Deprecated as a consequence of Query being deprecated.
Create a Query instance for the given HQL/JPQL query string.
public <R> Query<R>

Returns:

The Query instance for manipulation and execution
createQuery
(String
The HQL/JPQL query
queryString
,
Class<R>
The type of the query result
resultClass
)

Deprecated as a consequence of Query being deprecated.
Create a typed Query instance for the given HQL/JPQL query string.
public <T> Query<T>
createQuery(CriteriaQuery<T> criteriaQuery)

Deprecated as a consequence of Query being deprecated.
public Query<R>
createQuery(CriteriaUpdate<T> updateQuery)

Deprecated as a consequence of Query being deprecated.
public Query<R>
createQuery(CriteriaDelete<T> deleteQuery)

Deprecated as a consequence of Query being deprecated.
public default SQLQuery<T>

Returns:

The query instance for manipulation and execution
createSQLQuery
(String
The SQL query
queryString
)

Deprecated (since 5.2) use createNativeQuery(String) instead
Create a NativeQuery instance for the given SQL query string.
public NativeQuery<T>

Returns:

The NativeQuery instance for manipulation and execution
getNamedNativeQuery
(String
The name of the pre-defined query
name
)

Deprecated as a consequence of NativeQuery being deprecated.
Get a NativeQuery instance for a named native SQL query
public Query<R>

Returns:

The Query instance for manipulation and execution
getNamedQuery
(String
the name of a pre-defined, named query
queryName
)

Deprecated as a consequence of Query being deprecated.
Create a Query instance for the named query.
public default Query<R>

Returns:

The NativeQuery instance for manipulation and execution
getNamedSQLQuery
(String
The name of the pre-defined query
name
)

Deprecated (since 5.2) use getNamedNativeQuery(String) instead
Get a NativeQuery instance for a named native SQL query

Method Detail

createNamedQueryback to summary
public Query<R> createNamedQuery(String name)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

The JPA-defined named query creation method. This form can represent an HQL/JPQL query or a native query.

Parameters
name:String

the name of a pre-defined, named query

Returns:Query<R>

The Query instance for manipulation and execution

Exceptions
IllegalArgumentException:
if a query has not been defined with the given name or if the query string is found to be invalid
See Also
javax.persistence.EntityManager#createNamedQuery(String)
createNamedQueryback to summary
public <R> Query<R> createNamedQuery(String name, Class<R> resultClass)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

The JPA-defined named, typed query creation method. This form can only represent an HQL/JPQL query (not a native query).

Parameters
name:String

the name of a query defined in metadata

resultClass:Class<R>

the type of the query result

Returns:Query<R>

The Query instance for manipulation and execution

Exceptions
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
javax.persistence.EntityManager#createNamedQuery(String, Class)
createNativeQueryback to summary
public NativeQuery<T> createNativeQuery(String sqlString)

Deprecated

as a consequence of NativeQuery being deprecated. See corresponding docs for further information.

Create a NativeQuery instance for the given native (SQL) query

Parameters
sqlString:String

a native SQL query string

Returns:NativeQuery<T>

The NativeQuery instance for manipulation and execution

See Also
javax.persistence.EntityManager#createNativeQuery(String)
createNativeQueryback to summary
public <R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass)

Deprecated

as a consequence of NativeQuery being deprecated. See corresponding docs for further information.

Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.

Parameters
sqlString:String

Native (SQL) query string

resultClass:Class<R>

The Java entity type to map results to

Returns:NativeQuery<R>

The NativeQuery instance for manipulation and execution

See Also
javax.persistence.EntityManager#createNativeQuery(String, Class)
createNativeQueryback to summary
public NativeQuery<T> createNativeQuery(String sqlString, String resultSetMapping)

Deprecated

as a consequence of NativeQuery being deprecated. See corresponding docs for further information.

Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.

Parameters
sqlString:String

Native (SQL) query string

resultSetMapping:String

The explicit (named) result mapping

Returns:NativeQuery<T>

The NativeQuery instance for manipulation and execution

See Also
javax.persistence.EntityManager#createNativeQuery(String, Class), javax.persistence.SqlResultSetMapping
createQueryback to summary
public Query<R> createQuery(String queryString)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

Create a Query instance for the given HQL/JPQL query string.

Parameters
queryString:String

The HQL/JPQL query

Returns:Query<R>

The Query instance for manipulation and execution

See Also
javax.persistence.EntityManager#createQuery(String)
createQueryback to summary
public <R> Query<R> createQuery(String queryString, Class<R> resultClass)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

Create a typed Query instance for the given HQL/JPQL query string.

Parameters
queryString:String

The HQL/JPQL query

resultClass:Class<R>

The type of the query result

Returns:Query<R>

The Query instance for manipulation and execution

See Also
javax.persistence.EntityManager#createQuery(String, Class)
createQueryback to summary
public <T> Query<T> createQuery(CriteriaQuery<T> criteriaQuery)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

createQueryback to summary
public Query<R> createQuery(CriteriaUpdate<T> updateQuery)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

createQueryback to summary
public Query<R> createQuery(CriteriaDelete<T> deleteQuery)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

createSQLQueryback to summary
public default SQLQuery<T> createSQLQuery(String queryString)

Deprecated

(since 5.2) use createNativeQuery(String) instead

Create a NativeQuery instance for the given SQL query string.

Parameters
queryString:String

The SQL query

Returns:SQLQuery<T>

The query instance for manipulation and execution

Annotations
@Deprecated
getNamedNativeQueryback to summary
public NativeQuery<T> getNamedNativeQuery(String name)

Deprecated

as a consequence of NativeQuery being deprecated. See corresponding docs for further information.

Get a NativeQuery instance for a named native SQL query

Parameters
name:String

The name of the pre-defined query

Returns:NativeQuery<T>

The NativeQuery instance for manipulation and execution

getNamedQueryback to summary
public Query<R> getNamedQuery(String queryName)

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

Create a Query instance for the named query.

Parameters
queryName:String

the name of a pre-defined, named query

Returns:Query<R>

The Query instance for manipulation and execution

Exceptions
IllegalArgumentException:
if a query has not been defined with the given name or if the query string is found to be invalid
getNamedSQLQueryback to summary
public default Query<R> getNamedSQLQuery(String name)

Deprecated

(since 5.2) use getNamedNativeQuery(String) instead

Get a NativeQuery instance for a named native SQL query

Parameters
name:String

The name of the pre-defined query

Returns:Query<R>

The NativeQuery instance for manipulation and execution

Annotations
@Deprecated