public interface Query
| Modifier and Type | Method and Description |
|---|---|
int |
executeUpdate()
Execute an update or delete statement.
|
int |
getFirstResult()
The position of the first result the query object was set to retrieve.
|
FlushModeType |
getFlushMode()
Get the flush mode in effect for the query execution.
|
Map<String,Object> |
getHints()
Get the properties and hints and associated values that are in effect for the query instance.
|
LockModeType |
getLockMode()
Get the current lock mode for the query.
|
int |
getMaxResults()
The maximum number of results the query object was set to retrieve.
|
Parameter<?> |
getParameter(int position)
Get the parameter object corresponding to the declared positional parameter with the given position.
|
<T> Parameter<T> |
getParameter(int position,
Class<T> type)
Get the parameter object corresponding to the declared positional parameter with the given position and type.
|
Parameter<?> |
getParameter(String name)
Get the parameter object corresponding to the declared parameter of the given name.
|
<T> Parameter<T> |
getParameter(String name,
Class<T> type)
Get the parameter object corresponding to the declared parameter of the given name and type.
|
Set<Parameter<?>> |
getParameters()
Get the parameter objects corresponding to the declared parameters of the query.
|
Object |
getParameterValue(int position)
Return the input value bound to the positional parameter.
|
<T> T |
getParameterValue(Parameter<T> param)
Return the input value bound to the parameter.
|
Object |
getParameterValue(String name)
Return the input value bound to the named parameter.
|
List<?> |
getResultList()
Execute a SELECT query and return the query results as an untyped List.
|
Object |
getSingleResult()
Execute a SELECT query that returns a single untyped result.
|
boolean |
isBound(Parameter<?> param)
Return a boolean indicating whether a value has been bound to the parameter.
|
Query |
setFirstResult(int startPosition)
Set the position of the first result to retrieve.
|
Query |
setFlushMode(FlushModeType flushMode)
Set the flush mode type to be used for the query execution.
|
Query |
setHint(String hintName,
Object value)
Set a query property or hint.
|
Query |
setLockMode(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,
Calendar value,
TemporalType temporalType)
Bind an instance of java.util.Calendar to a positional parameter.
|
Query |
setParameter(int position,
Date value,
TemporalType temporalType)
Bind an instance of java.util.Date to a positional parameter.
|
Query |
setParameter(int position,
Object value)
Bind an argument value to a positional parameter.
|
Query |
setParameter(Parameter<Calendar> param,
Calendar value,
TemporalType temporalType)
Bind an instance of java.util.Calendar to a Parameter object.
|
Query |
setParameter(Parameter<Date> param,
Date value,
TemporalType temporalType)
Bind an instance of java.util.Date to a Parameter object.
|
<T> Query |
setParameter(Parameter<T> param,
T value)
Bind the value of a Parameter object.
|
Query |
setParameter(String name,
Calendar value,
TemporalType temporalType)
Bind an instance of java.util.Calendar to a named parameter.
|
Query |
setParameter(String name,
Date value,
TemporalType temporalType)
Bind an instance of java.util.Date to a named parameter.
|
Query |
setParameter(String name,
Object value)
Bind an argument value to a named parameter.
|
<T> T |
unwrap(Class<T> cls)
Return an object of the specified type to allow access to the provider-specific API.
|
int executeUpdate()
IllegalStateException - if called for a Java Persistence query language SELECT statement or for a criteria queryTransactionRequiredException - if there is no transaction or the persistence context has not been joined to the transactionQueryTimeoutException - if the statement execution exceeds the query timeout value set and only the statement is rolled backPersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled backint getFirstResult()
FlushModeType getFlushMode()
Map<String,Object> getHints()
LockModeType getLockMode()
IllegalStateException - if the query is found not to be a Java Persistence query language SELECT query or a Criteria API queryint getMaxResults()
Parameter<?> getParameter(int position)
position - IllegalArgumentException - if the parameter with the specified position does not existIllegalStateException - if invoked on a native query when the implementation does not support this use<T> Parameter<T> getParameter(int position, Class<T> type)
T - the type of the parameterposition - type - IllegalArgumentException - if the parameter with the specified position does not exist or is not assignable to the typeIllegalStateException - if invoked on a native query or Java Persistence query language query when the implementation does not support this useParameter<?> getParameter(String name)
name - IllegalArgumentException - if the parameter of the specified name does not existIllegalStateException - if invoked on a native query when the implementation does not support this use<T> Parameter<T> getParameter(String name, Class<T> type)
T - the type of the parametername - parameter nametype - IllegalArgumentException - if the parameter of the specified name does not exist or is not assignable to the typeIllegalStateException - if invoked on a native query or Java Persistence query language query when the implementation does not support this useSet<Parameter<?>> getParameters()
IllegalStateException - if invoked on a native query when the implementation does not support this useObject getParameterValue(int position)
position - IllegalStateException - if the parameter has not been been boundIllegalArgumentException - if the parameter with the specified position does not exist<T> T getParameterValue(Parameter<T> param)
T - the type of the parameterparam - parameter objectIllegalArgumentException - if the parameter is not a parameter of the queryIllegalStateException - if the parameter has not been been boundObject getParameterValue(String name)
name - parameter nameIllegalStateException - if the parameter has not been been boundIllegalArgumentException - if the parameter of the specified name does not existList<?> getResultList()
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 other than NONE has been been set and there is no transaction or the persistence context has not been
joined to the 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 backObject getSingleResult()
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 other than NONE has been been set and there is no transaction or the persistence context has not been
joined to the 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 backboolean isBound(Parameter<?> param)
param - parameter objectQuery setFirstResult(int startPosition)
startPosition - position of the first result, numbered from 0IllegalArgumentException - if the argument is negativeQuery setFlushMode(FlushModeType flushMode)
flushMode - Query setHint(String hintName, Object value)
hintName - name of the property or hintvalue - IllegalArgumentException - if the second argument is not valid for the implementationQuery setLockMode(LockModeType lockMode)
lockMode - IllegalStateException - if the query is found not to be a Java Persistence query language SELECT query or a Criteria API queryQuery setMaxResults(int maxResult)
maxResult - IllegalArgumentException - if the argument is negativeQuery setParameter(int position, Calendar value, TemporalType temporalType)
position - value - parameter valuetemporalType - IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the value argument is of incorrect typeQuery setParameter(int position, Date value, TemporalType temporalType)
position - value - parameter valuetemporalType - IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the value argument is of incorrect typeQuery setParameter(int position, Object value)
position - value - parameter valueIllegalArgumentException - if position does not correspond to a positional parameter of the query or if the argument is of incorrect typeQuery setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
param - parameter objectvalue - parameter valuetemporalType - IllegalArgumentException - if the parameter does not correspond to a parameter of the queryQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
param - parameter objectvalue - parameter valuetemporalType - IllegalArgumentException - if the parameter does not correspond to a parameter of the query<T> Query setParameter(Parameter<T> param, T value)
T - the type of the parameterparam - parameter objectvalue - parameter valueIllegalArgumentException - if the parameter does not correspond to a parameter of the queryQuery setParameter(String name, Calendar value, TemporalType temporalType)
name - parameter namevalue - parameter valuetemporalType - IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect typeQuery setParameter(String name, Date value, TemporalType temporalType)
name - parameter namevalue - parameter valuetemporalType - IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect typeQuery setParameter(String name, Object value)
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 type<T> T unwrap(Class<T> cls)
T - the type of the classcls - the class of the object to be returned. This is normally either the underlying query implementation class or an interface
that it implements.PersistenceException - if the provider does not support the callCopyright © 2012 Batoo Software & Consultancy. All Rights Reserved.