- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description List<X>getResultList()Execute a SELECT query and return the query results as a typed List.default Stream<X>getResultStream()Execute a SELECT query and return the query results as a typedjava.util.stream.Stream.XgetSingleResult()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, Object value)Bind an argument value to a positional parameter.TypedQuery<X>setParameter(int position, Calendar value, TemporalType temporalType)Bind an instance ofjava.util.Calendarto a positional parameter.TypedQuery<X>setParameter(int position, Date value, TemporalType temporalType)Bind an instance ofjava.util.Dateto a positional parameter.TypedQuery<X>setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)Bind an instance ofjava.util.Calendarto aParameterobject.TypedQuery<X>setParameter(Parameter<Date> param, Date value, TemporalType temporalType)Bind an instance ofjava.util.Dateto aParameterobject.<T> TypedQuery<X>setParameter(Parameter<T> param, T value)Bind the value of aParameterobject.TypedQuery<X>setParameter(String name, Object value)Bind an argument value to a named parameter.TypedQuery<X>setParameter(String name, Calendar value, TemporalType temporalType)Bind an instance ofjava.util.Calendarto a named parameter.TypedQuery<X>setParameter(String name, Date value, TemporalType temporalType)Bind an instance ofjava.util.Dateto a named parameter.- 
Methods inherited from interface jakarta.persistence.QueryexecuteUpdate, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrap
 
- 
 
- 
- 
- 
Method Detail- 
getResultListList<X> getResultList() Execute a SELECT query and return the query results as a typed List.- Specified by:
- getResultListin interface- Query
- Returns:
- a list of the results
- Throws:
- IllegalStateException- if called for a Java Persistence query language UPDATE or DELETE statement
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- TransactionRequiredException- if a lock mode other than- NONEhas been set and there is no transaction or the persistence context has not been joined to the transaction
- PessimisticLockException- if pessimistic locking fails and the transaction is rolled back
- LockTimeoutException- if pessimistic locking fails and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
getResultStreamdefault Stream<X> getResultStream() Execute a SELECT query and return the query results as a typedjava.util.stream.Stream. By default this method delegates togetResultList().stream(), however persistence provider may choose to override this method to provide additional capabilities.- Specified by:
- getResultStreamin interface- Query
- Returns:
- a stream of the results
- Throws:
- IllegalStateException- if called for a Java Persistence query language UPDATE or DELETE statement
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- TransactionRequiredException- if a lock mode other than- NONEhas been set and there is no transaction or the persistence context has not been joined to the transaction
- PessimisticLockException- if pessimistic locking fails and the transaction is rolled back
- LockTimeoutException- if pessimistic locking fails and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
- Since:
- 2.2
- See Also:
- Stream,- getResultList()
 
 - 
getSingleResultX getSingleResult() Execute a SELECT query that returns a single result.- Specified by:
- getSingleResultin interface- Query
- Returns:
- the result
- Throws:
- NoResultException- if there is no result
- NonUniqueResultException- if more than one result
- IllegalStateException- if called for a Java Persistence query language UPDATE or DELETE statement
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- TransactionRequiredException- if a lock mode other than- NONEhas been set and there is no transaction or the persistence context has not been joined to the transaction
- PessimisticLockException- if pessimistic locking fails and the transaction is rolled back
- LockTimeoutException- if pessimistic locking fails and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
setMaxResultsTypedQuery<X> setMaxResults(int maxResult) Set the maximum number of results to retrieve.- Specified by:
- setMaxResultsin interface- Query
- Parameters:
- maxResult- maximum number of results to retrieve
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the argument is negative
 
 - 
setFirstResultTypedQuery<X> setFirstResult(int startPosition) Set the position of the first result to retrieve.- Specified by:
- setFirstResultin interface- Query
- Parameters:
- startPosition- position of the first result, numbered from 0
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the argument is negative
 
 - 
setHintTypedQuery<X> setHint(String hintName, Object value) Set a query property or hint. The hints elements may be used to specify query properties and hints. Properties defined by this specification must be observed by the provider. Vendor-specific hints that are not recognized by a provider must be 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, this hint may or may not be observed.- Specified by:
- setHintin interface- Query
- Parameters:
- hintName- name of property or hint
- value- value for the property or hint
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the second argument is not valid for the implementation
 
 - 
setParameter<T> TypedQuery<X> setParameter(Parameter<T> param, T value) Bind the value of aParameterobject.- Specified by:
- setParameterin interface- Query
- Parameters:
- param- parameter object
- value- parameter value
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter does not correspond to a parameter of the query
 
 - 
setParameterTypedQuery<X> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) Bind an instance ofjava.util.Calendarto aParameterobject.- Specified by:
- setParameterin interface- Query
- Parameters:
- param- parameter object
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter does not correspond to a parameter of the query
 
 - 
setParameterTypedQuery<X> setParameter(Parameter<Date> param, Date value, TemporalType temporalType) Bind an instance ofjava.util.Dateto aParameterobject.- Specified by:
- setParameterin interface- Query
- Parameters:
- param- parameter object
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter does not correspond to a parameter of the query
 
 - 
setParameterTypedQuery<X> setParameter(String name, Object value) Bind an argument value to a named parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- name- parameter name
- value- parameter value
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or if the argument is of incorrect type
 
 - 
setParameterTypedQuery<X> setParameter(String name, Calendar value, TemporalType temporalType) Bind an instance ofjava.util.Calendarto a named parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- name- parameter name
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
 
 - 
setParameterTypedQuery<X> setParameter(String name, Date value, TemporalType temporalType) Bind an instance ofjava.util.Dateto a named parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- name- parameter name
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
 
 - 
setParameterTypedQuery<X> setParameter(int position, Object value) Bind an argument value to a positional parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- position- position
- value- parameter value
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if position does not correspond to a positional parameter of the query or if the argument is of incorrect type
 
 - 
setParameterTypedQuery<X> setParameter(int position, Calendar value, TemporalType temporalType) Bind an instance ofjava.util.Calendarto a positional parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- position- position
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
 
 - 
setParameterTypedQuery<X> setParameter(int position, Date value, TemporalType temporalType) Bind an instance ofjava.util.Dateto a positional parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- position- position
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
 
 - 
setFlushModeTypedQuery<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:
- setFlushModein interface- Query
- Parameters:
- flushMode- flush mode
- Returns:
- the same query instance
 
 - 
setLockModeTypedQuery<X> setLockMode(LockModeType lockMode) Set the lock mode type to be used for the query execution.- Specified by:
- setLockModein interface- Query
- Parameters:
- lockMode- lock mode
- Returns:
- the same query instance
- Throws:
- IllegalStateException- if the query is found not to be a Jakarta Persistence query language SELECT query or a CriteriaQuery query
 
 
- 
 
-