public class JtaQuery extends java.lang.Object implements Query
Constructor and Description |
---|
JtaQuery(EntityManager entityManager,
JtaEntityManager jtaEntityManager,
java.lang.reflect.Method method,
java.lang.Object... args) |
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.
|
java.util.Map<java.lang.String,java.lang.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,
java.lang.Class<T> type)
Get the parameter object corresponding to the declared
positional parameter with the given position and type.
|
Parameter<?> |
getParameter(java.lang.String name)
Get the parameter object corresponding to the declared
parameter of the given name.
|
<T> Parameter<T> |
getParameter(java.lang.String name,
java.lang.Class<T> type)
Get the parameter object corresponding to the declared
parameter of the given name and type.
|
java.util.Set<Parameter<?>> |
getParameters()
Get the parameter objects corresponding to the declared
parameters of the query.
|
java.lang.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.
|
java.lang.Object |
getParameterValue(java.lang.String name)
Return the input value bound to the named parameter.
|
java.util.List |
getResultList()
Execute a SELECT query and return the query results
as an untyped List.
|
java.lang.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.
|
protected java.lang.Class<? extends Query> |
queryType() |
Query |
setFirstResult(int i)
Set the position of the first result to retrieve.
|
Query |
setFlushMode(FlushModeType flushModeType)
Set the flush mode type to be used for the query execution.
|
Query |
setHint(java.lang.String s,
java.lang.Object o)
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 i)
Set the maximum number of results to retrieve.
|
Query |
setParameter(int i,
java.util.Calendar calendar,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a positional
parameter. |
Query |
setParameter(int i,
java.util.Date date,
TemporalType temporalType)
Bind an instance of
java.util.Date to a positional parameter. |
Query |
setParameter(int i,
java.lang.Object o)
Bind an argument value to a positional parameter.
|
Query |
setParameter(Parameter<java.util.Calendar> param,
java.util.Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a Parameter object. |
Query |
setParameter(Parameter<java.util.Date> param,
java.util.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(java.lang.String s,
java.util.Calendar calendar,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a named parameter. |
Query |
setParameter(java.lang.String s,
java.util.Date date,
TemporalType temporalType)
Bind an instance of
java.util.Date to a named parameter. |
Query |
setParameter(java.lang.String s,
java.lang.Object o)
Bind an argument value to a named parameter.
|
<T> T |
unwrap(java.lang.Class<T> cls)
Return an object of the specified type to allow access to
the provider-specific API.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getResultStream
public JtaQuery(EntityManager entityManager, JtaEntityManager jtaEntityManager, java.lang.reflect.Method method, java.lang.Object... args)
protected java.lang.Class<? extends Query> queryType()
public java.util.List getResultList()
Query
getResultList
in interface Query
public java.lang.Object getSingleResult()
Query
getSingleResult
in interface Query
public int executeUpdate()
Query
executeUpdate
in interface Query
public Query setMaxResults(int i)
Query
setMaxResults
in interface Query
i
- maximum number of results to retrievepublic Query setFirstResult(int i)
Query
setFirstResult
in interface Query
i
- position of the first result,
numbered from 0public Query setFlushMode(FlushModeType flushModeType)
Query
setFlushMode
in interface Query
flushModeType
- flush modepublic Query setHint(java.lang.String s, java.lang.Object o)
Query
public Query setParameter(java.lang.String s, java.lang.Object o)
Query
setParameter
in interface Query
s
- parameter nameo
- parameter valuepublic Query setParameter(java.lang.String s, java.util.Date date, TemporalType temporalType)
Query
java.util.Date
to a named parameter.setParameter
in interface Query
s
- parameter namedate
- parameter valuetemporalType
- temporal typepublic Query setParameter(java.lang.String s, java.util.Calendar calendar, TemporalType temporalType)
Query
java.util.Calendar
to a named parameter.setParameter
in interface Query
s
- parameter namecalendar
- parameter valuetemporalType
- temporal typepublic Query setParameter(int i, java.lang.Object o)
Query
setParameter
in interface Query
i
- positiono
- parameter valuepublic Query setParameter(int i, java.util.Date date, TemporalType temporalType)
Query
java.util.Date
to a positional parameter.setParameter
in interface Query
i
- positiondate
- parameter valuetemporalType
- temporal typepublic Query setParameter(int i, java.util.Calendar calendar, TemporalType temporalType)
Query
java.util.Calendar
to a positional
parameter.setParameter
in interface Query
i
- positioncalendar
- parameter valuetemporalType
- temporal typepublic int getFirstResult()
Query
setFirstResult
was not applied to the
query object.getFirstResult
in interface Query
public FlushModeType getFlushMode()
Query
getFlushMode
in interface Query
public java.util.Map<java.lang.String,java.lang.Object> getHints()
Query
public LockModeType getLockMode()
Query
getLockMode
in interface Query
public int getMaxResults()
Query
Integer.MAX_VALUE
if setMaxResults
was not
applied to the query object.getMaxResults
in interface Query
public Parameter<?> getParameter(java.lang.String name)
Query
getParameter
in interface Query
name
- parameter namepublic Parameter<?> getParameter(int position)
Query
getParameter
in interface Query
position
- positionpublic <T> Parameter<T> getParameter(java.lang.String name, java.lang.Class<T> type)
Query
getParameter
in interface Query
name
- parameter nametype
- typepublic <T> Parameter<T> getParameter(int position, java.lang.Class<T> type)
Query
getParameter
in interface Query
position
- positiontype
- typepublic <T> T getParameterValue(Parameter<T> param)
Query
getParameterValue
in interface Query
param
- parameter objectpublic java.lang.Object getParameterValue(java.lang.String name)
Query
getParameterValue
in interface Query
name
- parameter namepublic java.lang.Object getParameterValue(int position)
Query
getParameterValue
in interface Query
position
- positionpublic java.util.Set<Parameter<?>> getParameters()
Query
getParameters
in interface Query
public boolean isBound(Parameter<?> param)
Query
public Query setLockMode(LockModeType lockMode)
Query
setLockMode
in interface Query
lockMode
- lock modepublic <T> Query setParameter(Parameter<T> param, T value)
Query
Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuepublic Query setParameter(Parameter<java.util.Calendar> param, java.util.Calendar value, TemporalType temporalType)
Query
java.util.Calendar
to a Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuetemporalType
- temporal typepublic Query setParameter(Parameter<java.util.Date> param, java.util.Date value, TemporalType temporalType)
Query
java.util.Date
to a Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuetemporalType
- temporal typepublic <T> T unwrap(java.lang.Class<T> cls)
Query
PersistenceException
is thrown.