public interface Query
TypedQuery
instead of this interface.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
Modifier and Type | Method and Description |
---|---|
Query |
addView(java.lang.Class<? extends Entity> entityClass,
java.lang.String viewName)
Adds View for this Query instance.
|
Query |
addView(View view)
Adds View for this Query instance.
|
int |
executeUpdate()
Execute an update or delete statement.
|
javax.persistence.Query |
getDelegate() |
java.lang.Object |
getFirstResult()
Execute a SELECT query.
Returns null if there is no result. Returns first result if more than one result. |
java.lang.String |
getQueryString()
Get the query string.
|
java.util.List |
getResultList()
Execute a SELECT query and return the query results as a List.
|
java.lang.Object |
getSingleResult()
Execute a SELECT query that returns a single result.
|
Query |
setCacheable(boolean cacheable)
Indicates that the query results should be cached.
|
Query |
setFirstResult(int startPosition)
Set the position of the first result to retrieve.
|
Query |
setFlushMode(javax.persistence.FlushModeType flushMode)
Set the flush mode type to be used for the query execution.
|
Query |
setLockMode(javax.persistence.LockModeType lockMode)
Set the lock mode type to be used for the query execution.
|
Query |
setMaxResults(int maxResult)
Set the maximum number of results to retrieve.
|
Query |
setParameter(int position,
java.util.Date value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a positional parameter.
|
Query |
setParameter(int position,
java.lang.Object value)
Bind an argument to a positional parameter.
|
Query |
setParameter(int position,
java.lang.Object value,
boolean implicitConversions)
Bind an argument to a positional parameter.
|
Query |
setParameter(java.lang.String name,
java.util.Date value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a named parameter.
|
Query |
setParameter(java.lang.String name,
java.lang.Object value)
Bind an argument to a named parameter.
In the query text, named parameters are marked with colon (e.g. |
Query |
setParameter(java.lang.String name,
java.lang.Object value,
boolean implicitConversions)
Bind an argument to a named parameter.
In the query text, named parameters are marked with colon (e.g. |
Query |
setQueryString(java.lang.String queryString)
Set the query string.
|
Query |
setView(java.lang.Class<? extends Entity> entityClass,
java.lang.String viewName)
Set View for this Query instance.
|
Query |
setView(View view)
Set View for this Query instance.
|
static final java.lang.String NAME
java.lang.String getQueryString()
Query setQueryString(java.lang.String queryString)
queryString
- query stringjava.util.List getResultList()
java.lang.IllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statementjava.lang.Object getSingleResult()
javax.persistence.NoResultException
- if there is no resultjavax.persistence.NonUniqueResultException
- if more than one resultjava.lang.IllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statement@Nullable java.lang.Object getFirstResult()
java.lang.IllegalStateException
- if called for a Java Persistence query language UPDATE or DELETE statementint executeUpdate()
java.lang.IllegalStateException
- if called for a Java Persistence query language SELECT statementjavax.persistence.TransactionRequiredException
- if there is no transactionQuery setMaxResults(int maxResult)
java.lang.IllegalArgumentException
- if argument is negativeQuery setFirstResult(int startPosition)
startPosition
- position of the first result, numbered from 0java.lang.IllegalArgumentException
- if argument is negativeQuery setParameter(java.lang.String name, java.lang.Object value)
:foo
) in JPQL queries or with
number sign in native SQL queries (e.g. #foo
).name
- parameter namevalue
- parameter value. Entity instance replaced with its ID.java.lang.IllegalArgumentException
- if parameter name does not correspond to parameter in query string
or argument is of incorrect typeQuery setParameter(java.lang.String name, java.lang.Object value, boolean implicitConversions)
:foo
) in JPQL queries or with
number sign in native SQL queries (e.g. #foo
).name
- parameter namevalue
- parameter valueimplicitConversions
- whether to make parameter value conversions, e.g. convert an entity to its IDjava.lang.IllegalArgumentException
- if parameter name does not correspond to parameter in query string
or argument is of incorrect typeQuery setParameter(java.lang.String name, java.util.Date value, javax.persistence.TemporalType temporalType)
In the query text, named parameters are marked with colon (e.g. :foo
) in JPQL queries or with
number sign in native SQL queries (e.g. #foo
).
name
- parameter namevalue
- parameter valuetemporalType
- type of Date valuejava.lang.IllegalArgumentException
- if parameter name does not correspond to parameter in query stringQuery setParameter(int position, java.lang.Object value)
In the query text, positional parameters are marked with ?N (e.g. ?1
).
position
- parameter position, starting with 1value
- parameter value. Entity instance replaced with its ID.java.lang.IllegalArgumentException
- if position does not correspond to positional parameter of query
or argument is of incorrect typeQuery setParameter(int position, java.lang.Object value, boolean implicitConversions)
In the query text, positional parameters are marked with ?N (e.g. ?1
).
position
- parameter position, starting with 1value
- parameter valueimplicitConversions
- whether to make parameter value conversions, e.g. convert an entity to its IDjava.lang.IllegalArgumentException
- if position does not correspond to positional parameter of query
or argument is of incorrect typeQuery setParameter(int position, java.util.Date value, javax.persistence.TemporalType temporalType)
?1
).position
- parameter position, starting with 1value
- parameter valuetemporalType
- type of Date valuejava.lang.IllegalArgumentException
- if position does not correspond to positional parameter of queryQuery setLockMode(javax.persistence.LockModeType lockMode)
lockMode
- lock modeQuery setView(@Nullable View view)
view
- view instance. If null, eager fetching is performed according to JPA mappings.Query setView(java.lang.Class<? extends Entity> entityClass, java.lang.String viewName)
entityClass
- entity class to get a view instance by the name providedviewName
- view nameQuery addView(View view)
view
- view instance - must not be nullQuery addView(java.lang.Class<? extends Entity> entityClass, java.lang.String viewName)
entityClass
- entity class to get a view instance by the name providedviewName
- view name - must not be nullQuery setCacheable(boolean cacheable)
Query setFlushMode(javax.persistence.FlushModeType flushMode)
flushMode
- flush modejavax.persistence.Query getDelegate()