Package org.apache.openjpa.persistence
Class QueryImpl<X>
- java.lang.Object
-
- org.apache.openjpa.persistence.AbstractQuery<X>
-
- org.apache.openjpa.persistence.QueryImpl<X>
-
- All Implemented Interfaces:
jakarta.persistence.Query
,jakarta.persistence.TypedQuery<X>
,java.io.Serializable
,OpenJPAQuery<X>
,OpenJPAQuerySPI<X>
public class QueryImpl<X> extends AbstractQuery<X> implements java.io.Serializable
Implementation ofQuery
interface.- Author:
- Marc Prud'hommeaux, Abe White
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.persistence.AbstractQuery
_boundParams, _convertPositionalParams, _declaredParams, _em, _qmd, _relaxBindParameterTypeChecking
-
Fields inherited from interface org.apache.openjpa.persistence.OpenJPAQuery
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION, HINT_RESULT_COUNT, OP_DELETE, OP_SELECT, OP_UPDATE
-
-
Constructor Summary
Constructors Constructor Description QueryImpl(EntityManagerImpl em, Query query)
Deprecated.QueryImpl(EntityManagerImpl em, RuntimeExceptionTranslator ret, Query query)
Deprecated.QueryImpl(EntityManagerImpl em, RuntimeExceptionTranslator ret, Query query, QueryMetaData qmd)
Constructor; supply factory exception translator and delegate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OpenJPAQuery<X>
addAggregateListener(AggregateListener listener)
Register an aggregate listener for the query.OpenJPAQuery<X>
addFilterListener(FilterListener listener)
Register a filter listener for the query.protected void
assertOpen()
OpenJPAQuery<X>
closeAll()
Close all open query results.OpenJPAQuery<X>
compile()
Compile the query.boolean
equals(java.lang.Object other)
int
executeUpdate()
java.util.Collection<?>
getCandidateCollection()
Return the candidate collection, ornull
if an extent was specified instead of a collection.java.lang.String[]
getDataStoreActions(java.util.Map params)
Returns a description of the commands that will be sent to the datastore in order to execute this query.Query
getDelegate()
Delegate.OpenJPAEntityManager
getEntityManager()
The owning entity manager.FetchPlan
getFetchPlan()
Fetch plan for controlling the loading of results.int
getFirstResult()
Return the 0-based start index for the returned results.jakarta.persistence.FlushModeType
getFlushMode()
Return the current flush mode.java.util.Map<java.lang.String,java.lang.Object>
getHints()
Get all the active hints and their values.boolean
getIgnoreChanges()
Whether to ignore changes in the current transaction.java.lang.String
getLanguage()
Query language.jakarta.persistence.LockModeType
getLockMode()
int
getMaxResults()
Return the maximum number of results to retrieve.QueryOperationType
getOperation()
Query operation type.OrderedMap<java.lang.Object,java.lang.Class<?>>
getParamTypes()
java.lang.String
getQueryString()
Query string.java.lang.Class
getResultClass()
Query result element type.java.util.List
getResultList()
X
getSingleResult()
Execute a query that returns a single result.java.util.Set<java.lang.String>
getSupportedHints()
Gets hints supported by this query.int
hashCode()
boolean
hasSubclasses()
Whether subclasses are included in the query results.protected void
lock()
OpenJPAQuery<X>
removeAggregateListener(AggregateListener listener)
Remove an aggregate listener from the query.OpenJPAQuery<X>
removeFilterListener(FilterListener listener)
Remove a filter listener from the query.OpenJPAQuery<X>
setCandidateCollection(java.util.Collection coll)
Set a collection of candidates.OpenJPAQuery<X>
setFirstResult(int startPosition)
OpenJPAQuery<X>
setFlushMode(jakarta.persistence.FlushModeType flushMode)
OpenJPAQuery<X>
setHint(java.lang.String key, java.lang.Object value)
OpenJPAQuery<X>
setIgnoreChanges(boolean ignore)
Whether to ignore changes in the current transaction.jakarta.persistence.TypedQuery<X>
setLockMode(jakarta.persistence.LockModeType lockMode)
Sets lock mode on the given query.OpenJPAQuery<X>
setMaxResults(int max)
OpenJPAQuery<X>
setResultClass(java.lang.Class cls)
Query result element type.OpenJPAQuery<X>
setSubclasses(boolean subs)
Whether subclasses are included in the query results.java.lang.String
toString()
protected void
unlock()
<T> T
unwrap(java.lang.Class<T> cls)
Unwraps this receiver to an instance of the given class, if possible.-
Methods inherited from class org.apache.openjpa.persistence.AbstractQuery
declareParameter, getBoundParameterKeys, getDeclaredParameterKeys, getDeclaredParameterKeys, getDeclaredParameters, getNamedParameters, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, getPositionalParameters, getRelaxBindParameterTypeChecking, hasPositionalParameters, isBound, isNative, isProcedure, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameters, setParameters, setRelaxBindParameterTypeChecking
-
-
-
-
Constructor Detail
-
QueryImpl
public QueryImpl(EntityManagerImpl em, RuntimeExceptionTranslator ret, Query query, QueryMetaData qmd)
Constructor; supply factory exception translator and delegate.- Parameters:
em
- The EntityManager which created this queryret
- Exception translator for this queryquery
- The underlying "kernel" query.
-
QueryImpl
@Deprecated public QueryImpl(EntityManagerImpl em, RuntimeExceptionTranslator ret, Query query)
Deprecated.Constructor; supply factory and delegate.
-
QueryImpl
@Deprecated public QueryImpl(EntityManagerImpl em, Query query)
Deprecated.Constructor; supply factory and delegate.
-
-
Method Detail
-
getDelegate
public Query getDelegate()
Delegate.
-
getEntityManager
public OpenJPAEntityManager getEntityManager()
Description copied from interface:OpenJPAQuery
The owning entity manager.- Specified by:
getEntityManager
in interfaceOpenJPAQuery<X>
-
getLanguage
public java.lang.String getLanguage()
Description copied from interface:OpenJPAQuery
Query language.- Specified by:
getLanguage
in interfaceOpenJPAQuery<X>
-
getOperation
public QueryOperationType getOperation()
Description copied from interface:OpenJPAQuery
Query operation type.- Specified by:
getOperation
in interfaceOpenJPAQuery<X>
-
getFetchPlan
public FetchPlan getFetchPlan()
Description copied from interface:OpenJPAQuery
Fetch plan for controlling the loading of results.- Specified by:
getFetchPlan
in interfaceOpenJPAQuery<X>
-
getQueryString
public java.lang.String getQueryString()
Description copied from interface:OpenJPAQuery
Query string.- Specified by:
getQueryString
in interfaceOpenJPAQuery<X>
-
getIgnoreChanges
public boolean getIgnoreChanges()
Description copied from interface:OpenJPAQuery
Whether to ignore changes in the current transaction.- Specified by:
getIgnoreChanges
in interfaceOpenJPAQuery<X>
-
setIgnoreChanges
public OpenJPAQuery<X> setIgnoreChanges(boolean ignore)
Description copied from interface:OpenJPAQuery
Whether to ignore changes in the current transaction.- Specified by:
setIgnoreChanges
in interfaceOpenJPAQuery<X>
-
addFilterListener
public OpenJPAQuery<X> addFilterListener(FilterListener listener)
Description copied from interface:OpenJPAQuerySPI
Register a filter listener for the query.- Specified by:
addFilterListener
in interfaceOpenJPAQuery<X>
- Specified by:
addFilterListener
in interfaceOpenJPAQuerySPI<X>
-
removeFilterListener
public OpenJPAQuery<X> removeFilterListener(FilterListener listener)
Description copied from interface:OpenJPAQuerySPI
Remove a filter listener from the query.- Specified by:
removeFilterListener
in interfaceOpenJPAQuery<X>
- Specified by:
removeFilterListener
in interfaceOpenJPAQuerySPI<X>
-
addAggregateListener
public OpenJPAQuery<X> addAggregateListener(AggregateListener listener)
Description copied from interface:OpenJPAQuerySPI
Register an aggregate listener for the query.- Specified by:
addAggregateListener
in interfaceOpenJPAQuery<X>
- Specified by:
addAggregateListener
in interfaceOpenJPAQuerySPI<X>
-
removeAggregateListener
public OpenJPAQuery<X> removeAggregateListener(AggregateListener listener)
Description copied from interface:OpenJPAQuerySPI
Remove an aggregate listener from the query.- Specified by:
removeAggregateListener
in interfaceOpenJPAQuery<X>
- Specified by:
removeAggregateListener
in interfaceOpenJPAQuerySPI<X>
-
getCandidateCollection
public java.util.Collection<?> getCandidateCollection()
Description copied from interface:OpenJPAQuery
Return the candidate collection, ornull
if an extent was specified instead of a collection.- Specified by:
getCandidateCollection
in interfaceOpenJPAQuery<X>
-
setCandidateCollection
public OpenJPAQuery<X> setCandidateCollection(java.util.Collection coll)
Description copied from interface:OpenJPAQuery
Set a collection of candidates.- Specified by:
setCandidateCollection
in interfaceOpenJPAQuery<X>
-
getResultClass
public java.lang.Class getResultClass()
Description copied from interface:OpenJPAQuery
Query result element type.- Specified by:
getResultClass
in interfaceOpenJPAQuery<X>
-
setResultClass
public OpenJPAQuery<X> setResultClass(java.lang.Class cls)
Description copied from interface:OpenJPAQuery
Query result element type.- Specified by:
setResultClass
in interfaceOpenJPAQuery<X>
-
hasSubclasses
public boolean hasSubclasses()
Description copied from interface:OpenJPAQuery
Whether subclasses are included in the query results.- Specified by:
hasSubclasses
in interfaceOpenJPAQuery<X>
-
setSubclasses
public OpenJPAQuery<X> setSubclasses(boolean subs)
Description copied from interface:OpenJPAQuery
Whether subclasses are included in the query results.- Specified by:
setSubclasses
in interfaceOpenJPAQuery<X>
-
getFirstResult
public int getFirstResult()
Description copied from interface:OpenJPAQuery
Return the 0-based start index for the returned results.- Specified by:
getFirstResult
in interfaceOpenJPAQuery<X>
- Specified by:
getFirstResult
in interfacejakarta.persistence.Query
-
setFirstResult
public OpenJPAQuery<X> setFirstResult(int startPosition)
- Specified by:
setFirstResult
in interfaceOpenJPAQuery<X>
- Specified by:
setFirstResult
in interfacejakarta.persistence.Query
- Specified by:
setFirstResult
in interfacejakarta.persistence.TypedQuery<X>
-
getMaxResults
public int getMaxResults()
Description copied from interface:OpenJPAQuery
Return the maximum number of results to retrieve. orInteger.MAX_VALUE
for no limit.- Specified by:
getMaxResults
in interfaceOpenJPAQuery<X>
- Specified by:
getMaxResults
in interfacejakarta.persistence.Query
-
setMaxResults
public OpenJPAQuery<X> setMaxResults(int max)
- Specified by:
setMaxResults
in interfaceOpenJPAQuery<X>
- Specified by:
setMaxResults
in interfacejakarta.persistence.Query
- Specified by:
setMaxResults
in interfacejakarta.persistence.TypedQuery<X>
-
compile
public OpenJPAQuery<X> compile()
Description copied from interface:OpenJPAQuery
Compile the query.- Specified by:
compile
in interfaceOpenJPAQuery<X>
-
getResultList
public java.util.List getResultList()
- Specified by:
getResultList
in interfacejakarta.persistence.Query
- Specified by:
getResultList
in interfacejakarta.persistence.TypedQuery<X>
-
getSingleResult
public X getSingleResult()
Execute a query that returns a single result.- Specified by:
getSingleResult
in interfacejakarta.persistence.Query
- Specified by:
getSingleResult
in interfacejakarta.persistence.TypedQuery<X>
-
executeUpdate
public int executeUpdate()
- Specified by:
executeUpdate
in interfacejakarta.persistence.Query
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
Description copied from interface:OpenJPAQuery
Return the current flush mode.- Specified by:
getFlushMode
in interfaceOpenJPAQuery<X>
- Specified by:
getFlushMode
in interfacejakarta.persistence.Query
-
setFlushMode
public OpenJPAQuery<X> setFlushMode(jakarta.persistence.FlushModeType flushMode)
- Specified by:
setFlushMode
in interfaceOpenJPAQuery<X>
- Specified by:
setFlushMode
in interfacejakarta.persistence.Query
- Specified by:
setFlushMode
in interfacejakarta.persistence.TypedQuery<X>
-
closeAll
public OpenJPAQuery<X> closeAll()
Description copied from interface:OpenJPAQuery
Close all open query results.- Specified by:
closeAll
in interfaceOpenJPAQuery<X>
-
getDataStoreActions
public java.lang.String[] getDataStoreActions(java.util.Map params)
Description copied from interface:OpenJPAQuery
Returns a description of the commands that will be sent to the datastore in order to execute this query. This will typically be in the native query language of the database (e.g., SQL).- Specified by:
getDataStoreActions
in interfaceOpenJPAQuery<X>
- Parameters:
params
- the named parameter map for the query invocation
-
getLockMode
public jakarta.persistence.LockModeType getLockMode()
- Specified by:
getLockMode
in interfacejakarta.persistence.Query
-
setLockMode
public jakarta.persistence.TypedQuery<X> setLockMode(jakarta.persistence.LockModeType lockMode)
Sets lock mode on the given query. If the target query has been prepared and cached, then ignores the cached version.- Specified by:
setLockMode
in interfacejakarta.persistence.Query
- Specified by:
setLockMode
in interfacejakarta.persistence.TypedQuery<X>
- See Also:
ignorePreparedQuery()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
getHints
public java.util.Map<java.lang.String,java.lang.Object> getHints()
Get all the active hints and their values.- Specified by:
getHints
in interfacejakarta.persistence.Query
-
setHint
public OpenJPAQuery<X> setHint(java.lang.String key, java.lang.Object value)
- Specified by:
setHint
in interfaceOpenJPAQuery<X>
- Specified by:
setHint
in interfacejakarta.persistence.Query
- Specified by:
setHint
in interfacejakarta.persistence.TypedQuery<X>
-
getSupportedHints
public java.util.Set<java.lang.String> getSupportedHints()
Description copied from interface:OpenJPAQuery
Gets hints supported by this query.- Specified by:
getSupportedHints
in interfaceOpenJPAQuery<X>
-
unwrap
public <T> T unwrap(java.lang.Class<T> cls)
Unwraps this receiver to an instance of the given class, if possible.- Specified by:
unwrap
in interfacejakarta.persistence.Query
- Since:
- 2.0.0
-
lock
protected void lock()
- Specified by:
lock
in classAbstractQuery<X>
-
unlock
protected void unlock()
- Specified by:
unlock
in classAbstractQuery<X>
-
assertOpen
protected void assertOpen()
- Specified by:
assertOpen
in classAbstractQuery<X>
-
getParamTypes
public OrderedMap<java.lang.Object,java.lang.Class<?>> getParamTypes()
- Specified by:
getParamTypes
in classAbstractQuery<X>
- Returns:
- a map of parameter name to type for this query.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-