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>,Serializable,OpenJPAQuery<X>,OpenJPAQuerySPI<X>
public class QueryImpl<X> extends AbstractQuery<X> implements Serializable
Implementation ofQueryinterface.- 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 voidassertOpen()OpenJPAQuery<X>closeAll()Close all open query results.OpenJPAQuery<X>compile()Compile the query.booleanequals(Object other)intexecuteUpdate()Collection<?>getCandidateCollection()Return the candidate collection, ornullif an extent was specified instead of a collection.String[]getDataStoreActions(Map params)Returns a description of the commands that will be sent to the datastore in order to execute this query.QuerygetDelegate()Delegate.OpenJPAEntityManagergetEntityManager()The owning entity manager.FetchPlangetFetchPlan()Fetch plan for controlling the loading of results.intgetFirstResult()Return the 0-based start index for the returned results.jakarta.persistence.FlushModeTypegetFlushMode()Return the current flush mode.Map<String,Object>getHints()Get all the active hints and their values.booleangetIgnoreChanges()Whether to ignore changes in the current transaction.StringgetLanguage()Query language.jakarta.persistence.LockModeTypegetLockMode()intgetMaxResults()Return the maximum number of results to retrieve.QueryOperationTypegetOperation()Query operation type.OrderedMap<Object,Class<?>>getParamTypes()StringgetQueryString()Query string.ClassgetResultClass()Query result element type.ListgetResultList()XgetSingleResult()Execute a query that returns a single result.Set<String>getSupportedHints()Gets hints supported by this query.inthashCode()booleanhasSubclasses()Whether subclasses are included in the query results.protected voidlock()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(Collection coll)Set a collection of candidates.OpenJPAQuery<X>setFirstResult(int startPosition)OpenJPAQuery<X>setFlushMode(jakarta.persistence.FlushModeType flushMode)OpenJPAQuery<X>setHint(String key, 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(Class cls)Query result element type.OpenJPAQuery<X>setSubclasses(boolean subs)Whether subclasses are included in the query results.StringtoString()protected voidunlock()<T> Tunwrap(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:OpenJPAQueryThe owning entity manager.- Specified by:
 getEntityManagerin interfaceOpenJPAQuery<X>
 
- 
getLanguage
public String getLanguage()
Description copied from interface:OpenJPAQueryQuery language.- Specified by:
 getLanguagein interfaceOpenJPAQuery<X>
 
- 
getOperation
public QueryOperationType getOperation()
Description copied from interface:OpenJPAQueryQuery operation type.- Specified by:
 getOperationin interfaceOpenJPAQuery<X>
 
- 
getFetchPlan
public FetchPlan getFetchPlan()
Description copied from interface:OpenJPAQueryFetch plan for controlling the loading of results.- Specified by:
 getFetchPlanin interfaceOpenJPAQuery<X>
 
- 
getQueryString
public String getQueryString()
Description copied from interface:OpenJPAQueryQuery string.- Specified by:
 getQueryStringin interfaceOpenJPAQuery<X>
 
- 
getIgnoreChanges
public boolean getIgnoreChanges()
Description copied from interface:OpenJPAQueryWhether to ignore changes in the current transaction.- Specified by:
 getIgnoreChangesin interfaceOpenJPAQuery<X>
 
- 
setIgnoreChanges
public OpenJPAQuery<X> setIgnoreChanges(boolean ignore)
Description copied from interface:OpenJPAQueryWhether to ignore changes in the current transaction.- Specified by:
 setIgnoreChangesin interfaceOpenJPAQuery<X>
 
- 
addFilterListener
public OpenJPAQuery<X> addFilterListener(FilterListener listener)
Description copied from interface:OpenJPAQuerySPIRegister a filter listener for the query.- Specified by:
 addFilterListenerin interfaceOpenJPAQuery<X>- Specified by:
 addFilterListenerin interfaceOpenJPAQuerySPI<X>
 
- 
removeFilterListener
public OpenJPAQuery<X> removeFilterListener(FilterListener listener)
Description copied from interface:OpenJPAQuerySPIRemove a filter listener from the query.- Specified by:
 removeFilterListenerin interfaceOpenJPAQuery<X>- Specified by:
 removeFilterListenerin interfaceOpenJPAQuerySPI<X>
 
- 
addAggregateListener
public OpenJPAQuery<X> addAggregateListener(AggregateListener listener)
Description copied from interface:OpenJPAQuerySPIRegister an aggregate listener for the query.- Specified by:
 addAggregateListenerin interfaceOpenJPAQuery<X>- Specified by:
 addAggregateListenerin interfaceOpenJPAQuerySPI<X>
 
- 
removeAggregateListener
public OpenJPAQuery<X> removeAggregateListener(AggregateListener listener)
Description copied from interface:OpenJPAQuerySPIRemove an aggregate listener from the query.- Specified by:
 removeAggregateListenerin interfaceOpenJPAQuery<X>- Specified by:
 removeAggregateListenerin interfaceOpenJPAQuerySPI<X>
 
- 
getCandidateCollection
public Collection<?> getCandidateCollection()
Description copied from interface:OpenJPAQueryReturn the candidate collection, ornullif an extent was specified instead of a collection.- Specified by:
 getCandidateCollectionin interfaceOpenJPAQuery<X>
 
- 
setCandidateCollection
public OpenJPAQuery<X> setCandidateCollection(Collection coll)
Description copied from interface:OpenJPAQuerySet a collection of candidates.- Specified by:
 setCandidateCollectionin interfaceOpenJPAQuery<X>
 
- 
getResultClass
public Class getResultClass()
Description copied from interface:OpenJPAQueryQuery result element type.- Specified by:
 getResultClassin interfaceOpenJPAQuery<X>
 
- 
setResultClass
public OpenJPAQuery<X> setResultClass(Class cls)
Description copied from interface:OpenJPAQueryQuery result element type.- Specified by:
 setResultClassin interfaceOpenJPAQuery<X>
 
- 
hasSubclasses
public boolean hasSubclasses()
Description copied from interface:OpenJPAQueryWhether subclasses are included in the query results.- Specified by:
 hasSubclassesin interfaceOpenJPAQuery<X>
 
- 
setSubclasses
public OpenJPAQuery<X> setSubclasses(boolean subs)
Description copied from interface:OpenJPAQueryWhether subclasses are included in the query results.- Specified by:
 setSubclassesin interfaceOpenJPAQuery<X>
 
- 
getFirstResult
public int getFirstResult()
Description copied from interface:OpenJPAQueryReturn the 0-based start index for the returned results.- Specified by:
 getFirstResultin interfaceOpenJPAQuery<X>- Specified by:
 getFirstResultin interfacejakarta.persistence.Query
 
- 
setFirstResult
public OpenJPAQuery<X> setFirstResult(int startPosition)
- Specified by:
 setFirstResultin interfaceOpenJPAQuery<X>- Specified by:
 setFirstResultin interfacejakarta.persistence.Query- Specified by:
 setFirstResultin interfacejakarta.persistence.TypedQuery<X>
 
- 
getMaxResults
public int getMaxResults()
Description copied from interface:OpenJPAQueryReturn the maximum number of results to retrieve. orInteger.MAX_VALUEfor no limit.- Specified by:
 getMaxResultsin interfaceOpenJPAQuery<X>- Specified by:
 getMaxResultsin interfacejakarta.persistence.Query
 
- 
setMaxResults
public OpenJPAQuery<X> setMaxResults(int max)
- Specified by:
 setMaxResultsin interfaceOpenJPAQuery<X>- Specified by:
 setMaxResultsin interfacejakarta.persistence.Query- Specified by:
 setMaxResultsin interfacejakarta.persistence.TypedQuery<X>
 
- 
compile
public OpenJPAQuery<X> compile()
Description copied from interface:OpenJPAQueryCompile the query.- Specified by:
 compilein interfaceOpenJPAQuery<X>
 
- 
getResultList
public List getResultList()
- Specified by:
 getResultListin interfacejakarta.persistence.Query- Specified by:
 getResultListin interfacejakarta.persistence.TypedQuery<X>
 
- 
getSingleResult
public X getSingleResult()
Execute a query that returns a single result.- Specified by:
 getSingleResultin interfacejakarta.persistence.Query- Specified by:
 getSingleResultin interfacejakarta.persistence.TypedQuery<X>
 
- 
executeUpdate
public int executeUpdate()
- Specified by:
 executeUpdatein interfacejakarta.persistence.Query
 
- 
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
Description copied from interface:OpenJPAQueryReturn the current flush mode.- Specified by:
 getFlushModein interfaceOpenJPAQuery<X>- Specified by:
 getFlushModein interfacejakarta.persistence.Query
 
- 
setFlushMode
public OpenJPAQuery<X> setFlushMode(jakarta.persistence.FlushModeType flushMode)
- Specified by:
 setFlushModein interfaceOpenJPAQuery<X>- Specified by:
 setFlushModein interfacejakarta.persistence.Query- Specified by:
 setFlushModein interfacejakarta.persistence.TypedQuery<X>
 
- 
closeAll
public OpenJPAQuery<X> closeAll()
Description copied from interface:OpenJPAQueryClose all open query results.- Specified by:
 closeAllin interfaceOpenJPAQuery<X>
 
- 
getDataStoreActions
public String[] getDataStoreActions(Map params)
Description copied from interface:OpenJPAQueryReturns 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:
 getDataStoreActionsin interfaceOpenJPAQuery<X>- Parameters:
 params- the named parameter map for the query invocation
 
- 
getLockMode
public jakarta.persistence.LockModeType getLockMode()
- Specified by:
 getLockModein 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:
 setLockModein interfacejakarta.persistence.Query- Specified by:
 setLockModein interfacejakarta.persistence.TypedQuery<X>- See Also:
 ignorePreparedQuery()
 
- 
getHints
public Map<String,Object> getHints()
Get all the active hints and their values.- Specified by:
 getHintsin interfacejakarta.persistence.Query
 
- 
setHint
public OpenJPAQuery<X> setHint(String key, Object value)
- Specified by:
 setHintin interfaceOpenJPAQuery<X>- Specified by:
 setHintin interfacejakarta.persistence.Query- Specified by:
 setHintin interfacejakarta.persistence.TypedQuery<X>
 
- 
getSupportedHints
public Set<String> getSupportedHints()
Description copied from interface:OpenJPAQueryGets hints supported by this query.- Specified by:
 getSupportedHintsin interfaceOpenJPAQuery<X>
 
- 
unwrap
public <T> T unwrap(Class<T> cls)
Unwraps this receiver to an instance of the given class, if possible.- Specified by:
 unwrapin interfacejakarta.persistence.Query- Since:
 - 2.0.0
 
 
- 
lock
protected void lock()
- Specified by:
 lockin classAbstractQuery<X>
 
- 
unlock
protected void unlock()
- Specified by:
 unlockin classAbstractQuery<X>
 
- 
assertOpen
protected void assertOpen()
- Specified by:
 assertOpenin classAbstractQuery<X>
 
- 
getParamTypes
public OrderedMap<Object,Class<?>> getParamTypes()
- Specified by:
 getParamTypesin classAbstractQuery<X>- Returns:
 - a map of parameter name to type for this query.
 
 
 - 
 
 -