X
- query result typepublic interface TypedQuery<X> extends Query
Modifier and Type | Method and Description |
---|---|
List<X> |
getResultList()
Execute a SELECT query and return the query results
as a typed List.
|
X |
getSingleResult()
Execute a SELECT query that returns a single result.
|
TypedQuery<X> |
setFirstResult(int startPosition)
Set the position of the first result to retrieve.
|
TypedQuery<X> |
setFlushMode(FlushModeType flushMode)
Set the flush mode type to be used for the query execution.
|
TypedQuery<X> |
setHint(String hintName,
Object value)
Set a query property or hint.
|
TypedQuery<X> |
setLockMode(LockModeType lockMode)
Set the lock mode type to be used for the query execution.
|
TypedQuery<X> |
setMaxResults(int maxResult)
Set the maximum number of results to retrieve.
|
TypedQuery<X> |
setParameter(int position,
Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a positional
parameter. |
TypedQuery<X> |
setParameter(int position,
Date value,
TemporalType temporalType)
Bind an instance of
java.util.Date to a positional parameter. |
TypedQuery<X> |
setParameter(int position,
Object value)
Bind an argument to a positional parameter.
|
TypedQuery<X> |
setParameter(Parameter<Calendar> param,
Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a Parameter object. |
TypedQuery<X> |
setParameter(Parameter<Date> param,
Date value,
TemporalType temporalType)
Bind an instance of
java.util.Date to a Parameter object. |
<T> TypedQuery<X> |
setParameter(Parameter<T> param,
T value)
Bind the value of a
Parameter object. |
TypedQuery<X> |
setParameter(String name,
Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a named parameter. |
TypedQuery<X> |
setParameter(String name,
Date value,
TemporalType temporalType)
Bind an instance of
java.util.Date to a named parameter. |
TypedQuery<X> |
setParameter(String name,
Object value)
Bind an argument to a named parameter.
|
executeUpdate, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrap
List<X> getResultList()
getResultList
in interface Query
IllegalStateException
- if called for a Java
Persistence query language UPDATE or DELETE statementQueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backTransactionRequiredException
- if a lock mode has
been set and there is no transactionPessimisticLockException
- if pessimistic locking
fails and the transaction is rolled backLockTimeoutException
- if pessimistic locking
fails and only the statement is rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backX getSingleResult()
getSingleResult
in interface Query
NoResultException
- if there is no resultNonUniqueResultException
- if more than one resultIllegalStateException
- if called for a Java
Persistence query language UPDATE or DELETE statementQueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backTransactionRequiredException
- if a lock mode has
been set and there is no transactionPessimisticLockException
- if pessimistic locking
fails and the transaction is rolled backLockTimeoutException
- if pessimistic locking
fails and only the statement is rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backTypedQuery<X> setMaxResults(int maxResult)
setMaxResults
in interface Query
maxResult
- maximum number of results to retrieveIllegalArgumentException
- if the argument is negativeTypedQuery<X> setFirstResult(int startPosition)
setFirstResult
in interface Query
startPosition
- position of the first result,
numbered from 0IllegalArgumentException
- if the argument is negativeTypedQuery<X> setHint(String hintName, Object value)
setHint
in interface Query
hintName
- name of property or hintvalue
- value for the property or hintIllegalArgumentException
- if the second argument is not
valid for the implementation<T> TypedQuery<X> setParameter(Parameter<T> param, T value)
Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valueIllegalArgumentException
- if the parameter
does not correspond to a parameter of the
queryTypedQuery<X> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
java.util.Calendar
to a Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter does not
correspond to a parameter of the queryTypedQuery<X> setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
java.util.Date
to a Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter does not
correspond to a parameter of the queryTypedQuery<X> setParameter(String name, Object value)
setParameter
in interface Query
name
- parameter namevalue
- parameter valueIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or if
the argument is of incorrect typeTypedQuery<X> setParameter(String name, Calendar value, TemporalType temporalType)
java.util.Calendar
to a named parameter.setParameter
in interface Query
name
- parameter namevalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or if
the value argument is of incorrect typeTypedQuery<X> setParameter(String name, Date value, TemporalType temporalType)
java.util.Date
to a named parameter.setParameter
in interface Query
name
- parameter namevalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or if
the value argument is of incorrect typeTypedQuery<X> setParameter(int position, Object value)
setParameter
in interface Query
position
- positionvalue
- parameter valueIllegalArgumentException
- if position does not
correspond to a positional parameter of the
query or if the argument is of incorrect typeTypedQuery<X> setParameter(int position, Calendar value, TemporalType temporalType)
java.util.Calendar
to a positional
parameter.setParameter
in interface Query
position
- positionvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if position does not
correspond to a positional parameter of the query
or if the value argument is of incorrect typeTypedQuery<X> setParameter(int position, Date value, TemporalType temporalType)
java.util.Date
to a positional parameter.setParameter
in interface Query
position
- positionvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if position does not
correspond to a positional parameter of the query
or if the value argument is of incorrect typeTypedQuery<X> setFlushMode(FlushModeType flushMode)
setFlushMode
in interface Query
flushMode
- flush modeTypedQuery<X> setLockMode(LockModeType lockMode)
setLockMode
in interface Query
lockMode
- lock modeIllegalStateException
- if the query is found not to
be a Java Persistence query language SELECT query
or a Criteria API queryCopyright © 2016 JBoss by Red Hat. All rights reserved.