X
- Type of the candidate of the querypublic class JPAQuery<X> extends Object implements javax.persistence.TypedQuery<X>
Constructor and Description |
---|
JPAQuery(JPAEntityManager em,
org.datanucleus.store.query.Query query,
String language)
Constructor for a query used by JPA.
|
Modifier and Type | Method and Description |
---|---|
int |
executeUpdate()
Method to execute a (UPDATE/DELETE) query returning the number of changed records.
|
JPAFetchPlan |
getFetchPlan() |
int |
getFirstResult()
The position of the first result the query object was set to retrieve.
|
javax.persistence.FlushModeType |
getFlushMode()
The flush mode in effect for the query execution.
|
Map |
getHints()
Get the hints and associated values that are in effect for the query instance.
|
org.datanucleus.store.query.Query |
getInternalQuery()
Accessor for the internal query.
|
String |
getLanguage()
Accessor for the query language.
|
javax.persistence.LockModeType |
getLockMode() |
int |
getMaxResults()
The maximum number of results the query object was set to retrieve.
|
Object |
getNativeQuery()
Accessor for the native query invoked by this query (if known at this time and supported by the
store plugin).
|
javax.persistence.Parameter<?> |
getParameter(int position) |
<T> javax.persistence.Parameter<T> |
getParameter(int position,
Class<T> type)
Get the positional parameter with the given position and type.
|
javax.persistence.Parameter<?> |
getParameter(String name) |
<T> javax.persistence.Parameter<T> |
getParameter(String name,
Class<T> type)
Get the parameter of the given name and type.
|
Set<javax.persistence.Parameter<?>> |
getParameters()
Get the query parameter objects.
|
Object |
getParameterValue(int position) |
<T> T |
getParameterValue(javax.persistence.Parameter<T> param)
Return the value that has been bound to the parameter.
|
Object |
getParameterValue(String name) |
List |
getResultList()
Method to execute a (SELECT) query statement returning multiple results.
|
X |
getSingleResult()
Method to execute a SELECT statement returning a single result.
|
Set<String> |
getSupportedHints()
Get the names of the hints that are supported for query objects.
|
boolean |
isBound(javax.persistence.Parameter<?> param) |
protected void |
loadParameters() |
javax.persistence.TypedQuery<X> |
setFirstResult(int startPosition)
Method to set the results to start from a particular position.
|
javax.persistence.TypedQuery<X> |
setFlushMode(javax.persistence.FlushModeType mode)
Mutator for the flush mode.
|
javax.persistence.TypedQuery<X> |
setHint(String hintName,
Object value)
Method to add a vendor extension to the query.
|
javax.persistence.TypedQuery<X> |
setLockMode(javax.persistence.LockModeType lock) |
javax.persistence.TypedQuery<X> |
setMaxResults(int max)
Method to set the max number of results to return.
|
javax.persistence.TypedQuery<X> |
setParameter(int position,
Calendar value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Calendar to a positional parameter.
|
javax.persistence.TypedQuery<X> |
setParameter(int position,
Date value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a positional parameter.
|
javax.persistence.TypedQuery<X> |
setParameter(int position,
Object value)
Bind an argument to a positional parameter.
|
JPAQuery<X> |
setParameter(javax.persistence.Parameter<Calendar> param,
Calendar cal,
javax.persistence.TemporalType type) |
javax.persistence.TypedQuery<X> |
setParameter(javax.persistence.Parameter<Date> param,
Date date,
javax.persistence.TemporalType type) |
<T> javax.persistence.TypedQuery<X> |
setParameter(javax.persistence.Parameter<T> param,
T value)
Bind the value of a Parameter object.
|
javax.persistence.TypedQuery<X> |
setParameter(String name,
Calendar value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Calendar to a named parameter.
|
javax.persistence.TypedQuery<X> |
setParameter(String name,
Date value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a named parameter.
|
javax.persistence.TypedQuery<X> |
setParameter(String name,
Object value)
Bind an argument to a named parameter.
|
String |
toString()
Method to return the single-string form of the query.
|
<T> T |
unwrap(Class<T> cls)
Return an object of the specified type to allow access to the provider-specific API.
|
public JPAQuery(JPAEntityManager em, org.datanucleus.store.query.Query query, String language)
em
- Entity Managerquery
- Underlying querylanguage
- Query languagepublic JPAFetchPlan getFetchPlan()
public int executeUpdate()
executeUpdate
in interface javax.persistence.Query
javax.persistence.QueryTimeoutException
- if the query times outpublic List getResultList()
getResultList
in interface javax.persistence.Query
getResultList
in interface javax.persistence.TypedQuery<X>
javax.persistence.QueryTimeoutException
- if the query times outpublic X getSingleResult()
getSingleResult
in interface javax.persistence.Query
getSingleResult
in interface javax.persistence.TypedQuery<X>
javax.persistence.QueryTimeoutException
- if the query times outpublic javax.persistence.TypedQuery<X> setFirstResult(int startPosition)
setFirstResult
in interface javax.persistence.Query
setFirstResult
in interface javax.persistence.TypedQuery<X>
startPosition
- position of first result numbered from 0public javax.persistence.TypedQuery<X> setMaxResults(int max)
setMaxResults
in interface javax.persistence.Query
setMaxResults
in interface javax.persistence.TypedQuery<X>
max
- Number of results maxpublic int getMaxResults()
getMaxResults
in interface javax.persistence.Query
public int getFirstResult()
getFirstResult
in interface javax.persistence.Query
public javax.persistence.TypedQuery<X> setFlushMode(javax.persistence.FlushModeType mode)
setFlushMode
in interface javax.persistence.Query
setFlushMode
in interface javax.persistence.TypedQuery<X>
mode
- Flush modepublic javax.persistence.FlushModeType getFlushMode()
getFlushMode
in interface javax.persistence.Query
public javax.persistence.TypedQuery<X> setHint(String hintName, Object value)
setHint
in interface javax.persistence.Query
setHint
in interface javax.persistence.TypedQuery<X>
hintName
- Name of the "hint"value
- Value for the "hint"IllegalArgumentException
- if the second argument is not valid for the implementationpublic Map getHints()
getHints
in interface javax.persistence.Query
public Set<String> getSupportedHints()
public <T> javax.persistence.TypedQuery<X> setParameter(javax.persistence.Parameter<T> param, T value)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
param
- parameter to be setvalue
- parameter valueIllegalArgumentException
- if parameter does not correspond to a parameter of the querypublic javax.persistence.TypedQuery<X> setParameter(String name, Object value)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
name
- the parameter namevalue
- The value for the paramIllegalArgumentException
- if parameter name does not correspond to parameter in query string
or argument is of incorrect typepublic javax.persistence.TypedQuery<X> setParameter(int position, Object value)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
position
- Parameter positionvalue
- The valueIllegalArgumentException
- if position does not correspond to positional parameter of query
or argument is of incorrect typepublic javax.persistence.TypedQuery<X> setParameter(String name, Date value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
name
- Name of the paramvalue
- Value for the paramtemporalType
- The temporal typeIllegalArgumentException
- if parameter name does not correspond to parameter in query stringpublic javax.persistence.TypedQuery<X> setParameter(String name, Calendar value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
name
- name of the paramvalue
- Value for the paramtemporalType
- The temporal typeIllegalArgumentException
- if parameter name does not correspond to parameter in query stringpublic javax.persistence.TypedQuery<X> setParameter(int position, Date value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
position
- Parameter positionvalue
- Value for the paramtemporalType
- Temporal TypeIllegalArgumentException
- if position does not correspond to positional parameter of querypublic javax.persistence.TypedQuery<X> setParameter(int position, Calendar value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
position
- Parameter positionvalue
- Value for the paramtemporalType
- Temporal typeIllegalArgumentException
- if position does not correspond to positional parameter of querypublic JPAQuery<X> setParameter(javax.persistence.Parameter<Calendar> param, Calendar cal, javax.persistence.TemporalType type)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
public javax.persistence.TypedQuery<X> setParameter(javax.persistence.Parameter<Date> param, Date date, javax.persistence.TemporalType type)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<X>
public org.datanucleus.store.query.Query getInternalQuery()
public <T> T unwrap(Class<T> cls)
unwrap
in interface javax.persistence.Query
cls
- the class of the object to be returned. This is normally either the underlying
Query implementation class or an interface that it implements.javax.persistence.PersistenceException
- if the provider does not support the call.public String getLanguage()
public Set<javax.persistence.Parameter<?>> getParameters()
getParameters
in interface javax.persistence.Query
protected void loadParameters()
public <T> javax.persistence.Parameter<T> getParameter(String name, Class<T> type)
getParameter
in interface javax.persistence.Query
IllegalArgumentException
- if the parameter of the specified name and type doesn't existpublic <T> javax.persistence.Parameter<T> getParameter(int position, Class<T> type)
getParameter
in interface javax.persistence.Query
IllegalArgumentException
- if the parameter with the specified position and type doesn't existpublic javax.persistence.Parameter<?> getParameter(int position)
getParameter
in interface javax.persistence.Query
public javax.persistence.Parameter<?> getParameter(String name)
getParameter
in interface javax.persistence.Query
public <T> T getParameterValue(javax.persistence.Parameter<T> param)
getParameterValue
in interface javax.persistence.Query
param
- parameter objectIllegalStateException
- if the parameter has not been boundpublic Object getParameterValue(int position)
getParameterValue
in interface javax.persistence.Query
public Object getParameterValue(String name)
getParameterValue
in interface javax.persistence.Query
public boolean isBound(javax.persistence.Parameter<?> param)
isBound
in interface javax.persistence.Query
public javax.persistence.LockModeType getLockMode()
getLockMode
in interface javax.persistence.Query
public javax.persistence.TypedQuery<X> setLockMode(javax.persistence.LockModeType lock)
setLockMode
in interface javax.persistence.Query
setLockMode
in interface javax.persistence.TypedQuery<X>
public String toString()
public Object getNativeQuery()
Copyright © 2015. All rights reserved.