EclipseLink 2.0.0_ 2.0.0.v20090626-r4569 API Reference

javax.persistence
Interface TypedQuery<X>

All Superinterfaces:
Query
All Known Subinterfaces:
JpaQuery<X>

public interface TypedQuery<X>
extends Query


Method Summary
 java.util.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(java.lang.String hintName, java.lang.Object value)
          Set a query 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.
<T> TypedQuery<X>
setParameter(Parameter<T> param, T value)
          Set the value of a Parameter object.
 
Methods inherited from interface javax.persistence.Query
executeUpdate, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameters, getParameterValue, getSupportedHints, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, unwrap
 

Method Detail

getResultList

java.util.List<X> getResultList()
Execute a SELECT query and return the query results as a typed List.

Specified by:
getResultList in interface Query
Returns:
a list of the results
Throws:
java.lang.IllegalStateException - if called for a Java Persistence query language UPDATE or DELETE statement
QueryTimeoutException - if the query execution exceeds the query timeout value set
TransactionRequiredException - if a lock mode has been set and there is no transaction
PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled back

getSingleResult

X getSingleResult()
Execute a SELECT query that returns a single result.

Specified by:
getSingleResult in interface Query
Returns:
the result
Throws:
NoResultException - if there is no result
NonUniqueResultException - if more than one result
java.lang.IllegalStateException - if called for a Java Persistence query language UPDATE or DELETE statement
QueryTimeoutException - if the query execution exceeds the query timeout value set
TransactionRequiredException - if a lock mode has been set and there is no transaction
PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled back

setMaxResults

TypedQuery<X> setMaxResults(int maxResult)
Set the maximum number of results to retrieve.

Specified by:
setMaxResults in interface Query
Parameters:
maxResult -
Returns:
the same query instance
Throws:
java.lang.IllegalArgumentException - if argument is negative

setFirstResult

TypedQuery<X> setFirstResult(int startPosition)
Set the position of the first result to retrieve.

Specified by:
setFirstResult in interface Query
Parameters:
start - position of the first result, numbered from 0
Returns:
the same query instance
Throws:
java.lang.IllegalArgumentException - if argument is negative

setHint

TypedQuery<X> setHint(java.lang.String hintName,
                      java.lang.Object value)
Set a query hint. If a vendor-specific hint is not recognized, it is silently ignored. Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.

Specified by:
setHint in interface Query
Parameters:
hintName -
value -
Returns:
the same query instance
Throws:
java.lang.IllegalArgumentException - if the second argument is not valid for the implementation

setParameter

<T> TypedQuery<X> setParameter(Parameter<T> param,
                               T value)
Set the value of a Parameter object.

Specified by:
setParameter in interface Query
Parameters:
param - parameter to be set
value - parameter value
Returns:
query instance
Throws:
java.lang.IllegalArgumentException - if parameter does not correspond to a parameter of the query

setFlushMode

TypedQuery<X> setFlushMode(FlushModeType flushMode)
Set the flush mode type to be used for the query execution. The flush mode type applies to the query regardless of the flush mode type in use for the entity manager.

Specified by:
setFlushMode in interface Query
Parameters:
flushMode -

setLockMode

TypedQuery<X> setLockMode(LockModeType lockMode)
Set the lock mode type to be used for the query execution.

Specified by:
setLockMode in interface Query
Parameters:
lockMode -
Throws:
java.lang.IllegalStateException - if the query is found not to be a Java Persistence query language SELECT query or a Criteria API query

EclipseLink 2.0.0_ 2.0.0.v20090626-r4569 API Reference