org.apache.openjpa.persistence
Class QueryImpl

java.lang.Object
  extended by org.apache.openjpa.persistence.QueryImpl
All Implemented Interfaces:
Serializable, Query, QueryFlushModes, QueryOperations, OpenJPAQuery

public class QueryImpl
extends Object
implements OpenJPAQuery, Serializable

Implementation of Query interface.

Author:
Marc Prud'hommeaux, Abe White
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.openjpa.kernel.QueryOperations
OP_DELETE, OP_SELECT, OP_UPDATE
 
Fields inherited from interface org.apache.openjpa.kernel.QueryFlushModes
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION
 
Constructor Summary
QueryImpl(EntityManagerImpl em, Query query)
          Constructor; supply factory and delegate.
 
Method Summary
 OpenJPAQuery addAggregateListener(AggregateListener listener)
          Register an aggregate listener for the query.
 OpenJPAQuery addFilterListener(FilterListener listener)
          Register a filter listener for the query.
 OpenJPAQuery closeAll()
          Close all open query results.
 OpenJPAQuery compile()
          Compile the query.
 boolean equals(Object other)
           
 int executeUpdate()
           
 Collection getCandidateCollection()
          Return the candidate collection, or null if 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.
 Query getDelegate()
          Delegate.
 OpenJPAEntityManager getEntityManager()
          The owning entity manage.
 FetchPlan getFetchPlan()
          Fetch plan for controlling the loading of results.
 int getFirstResult()
          Return the 0-based start index for the returned results.
 FlushModeType getFlushMode()
          Return the current flush mode.
 boolean getIgnoreChanges()
          Whether to ignore changes in the current transaction.
 String getLanguage()
          Query language.
 int getMaxResults()
          Return the maximum number of results to retrieve.
 Map getNamedParameters()
          The named parameters for the query; empty map if none or if query uses named parameters.
 int getOperation()
          Query operation type.
 Object[] getPositionalParameters()
          The positional parameters for the query; empty array if none or if query uses named parameters.
 String getQueryString()
          Query string.
 Class getResultClass()
          Query result element type.
 List getResultList()
           
 Object getSingleResult()
          Execute a query that returns a single result.
 int hashCode()
           
 boolean hasPositionalParameters()
          Whether this query has positional parameters.
 boolean hasSubclasses()
          Whether subclasses are included in the query results.
 OpenJPAQuery removeAggregateListener(AggregateListener listener)
          Remove an aggregate listener from the query.
 OpenJPAQuery removeFilterListener(FilterListener listener)
          Remove a filter listener from the query.
 OpenJPAQuery setCandidateCollection(Collection coll)
          Set a collection of candidates.
 OpenJPAQuery setFirstResult(int startPosition)
           
 OpenJPAQuery setFlushMode(FlushModeType flushMode)
           
 OpenJPAQuery setHint(String key, Object value)
           
 OpenJPAQuery setIgnoreChanges(boolean ignore)
          Whether to ignore changes in the current transaction.
 OpenJPAQuery setMaxResults(int max)
           
 OpenJPAQuery setParameter(int position, Calendar value, TemporalType t)
           
 OpenJPAQuery setParameter(int position, Date value, TemporalType type)
           
 OpenJPAQuery setParameter(int position, Object value)
           
 OpenJPAQuery setParameter(String name, Calendar value, TemporalType t)
           
 OpenJPAQuery setParameter(String name, Date value, TemporalType type)
           
 OpenJPAQuery setParameter(String name, Object value)
           
 OpenJPAQuery setParameters(Map params)
          Set parameters.
 OpenJPAQuery setParameters(Object... params)
          Set parameters.
 OpenJPAQuery setResultClass(Class cls)
          Query result element type.
 OpenJPAQuery setSubclasses(boolean subs)
          Whether subclasses are included in the query results.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryImpl

public QueryImpl(EntityManagerImpl em,
                 Query query)
Constructor; supply factory and delegate.

Method Detail

getDelegate

public Query getDelegate()
Delegate.


getEntityManager

public OpenJPAEntityManager getEntityManager()
Description copied from interface: OpenJPAQuery
The owning entity manage.

Specified by:
getEntityManager in interface OpenJPAQuery

getLanguage

public String getLanguage()
Description copied from interface: OpenJPAQuery
Query language.

Specified by:
getLanguage in interface OpenJPAQuery

getOperation

public int getOperation()
Description copied from interface: OpenJPAQuery
Query operation type.

Specified by:
getOperation in interface OpenJPAQuery

getFetchPlan

public FetchPlan getFetchPlan()
Description copied from interface: OpenJPAQuery
Fetch plan for controlling the loading of results.

Specified by:
getFetchPlan in interface OpenJPAQuery

getQueryString

public String getQueryString()
Description copied from interface: OpenJPAQuery
Query string.

Specified by:
getQueryString in interface OpenJPAQuery

getIgnoreChanges

public boolean getIgnoreChanges()
Description copied from interface: OpenJPAQuery
Whether to ignore changes in the current transaction.

Specified by:
getIgnoreChanges in interface OpenJPAQuery

setIgnoreChanges

public OpenJPAQuery setIgnoreChanges(boolean ignore)
Description copied from interface: OpenJPAQuery
Whether to ignore changes in the current transaction.

Specified by:
setIgnoreChanges in interface OpenJPAQuery

addFilterListener

public OpenJPAQuery addFilterListener(FilterListener listener)
Description copied from interface: OpenJPAQuery
Register a filter listener for the query.

Specified by:
addFilterListener in interface OpenJPAQuery

removeFilterListener

public OpenJPAQuery removeFilterListener(FilterListener listener)
Description copied from interface: OpenJPAQuery
Remove a filter listener from the query.

Specified by:
removeFilterListener in interface OpenJPAQuery

addAggregateListener

public OpenJPAQuery addAggregateListener(AggregateListener listener)
Description copied from interface: OpenJPAQuery
Register an aggregate listener for the query.

Specified by:
addAggregateListener in interface OpenJPAQuery

removeAggregateListener

public OpenJPAQuery removeAggregateListener(AggregateListener listener)
Description copied from interface: OpenJPAQuery
Remove an aggregate listener from the query.

Specified by:
removeAggregateListener in interface OpenJPAQuery

getCandidateCollection

public Collection getCandidateCollection()
Description copied from interface: OpenJPAQuery
Return the candidate collection, or null if an extent was specified instead of a collection.

Specified by:
getCandidateCollection in interface OpenJPAQuery

setCandidateCollection

public OpenJPAQuery setCandidateCollection(Collection coll)
Description copied from interface: OpenJPAQuery
Set a collection of candidates.

Specified by:
setCandidateCollection in interface OpenJPAQuery

getResultClass

public Class getResultClass()
Description copied from interface: OpenJPAQuery
Query result element type.

Specified by:
getResultClass in interface OpenJPAQuery

setResultClass

public OpenJPAQuery setResultClass(Class cls)
Description copied from interface: OpenJPAQuery
Query result element type.

Specified by:
setResultClass in interface OpenJPAQuery

hasSubclasses

public boolean hasSubclasses()
Description copied from interface: OpenJPAQuery
Whether subclasses are included in the query results.

Specified by:
hasSubclasses in interface OpenJPAQuery

setSubclasses

public OpenJPAQuery setSubclasses(boolean subs)
Description copied from interface: OpenJPAQuery
Whether subclasses are included in the query results.

Specified by:
setSubclasses in interface OpenJPAQuery

getFirstResult

public int getFirstResult()
Description copied from interface: OpenJPAQuery
Return the 0-based start index for the returned results.

Specified by:
getFirstResult in interface OpenJPAQuery

setFirstResult

public OpenJPAQuery setFirstResult(int startPosition)
Specified by:
setFirstResult in interface Query
Specified by:
setFirstResult in interface OpenJPAQuery

getMaxResults

public int getMaxResults()
Description copied from interface: OpenJPAQuery
Return the maximum number of results to retrieve. or Integer.MAX_VALUE for no limit.

Specified by:
getMaxResults in interface OpenJPAQuery

setMaxResults

public OpenJPAQuery setMaxResults(int max)
Specified by:
setMaxResults in interface Query
Specified by:
setMaxResults in interface OpenJPAQuery

compile

public OpenJPAQuery compile()
Description copied from interface: OpenJPAQuery
Compile the query.

Specified by:
compile in interface OpenJPAQuery

getResultList

public List getResultList()
Specified by:
getResultList in interface Query

getSingleResult

public Object getSingleResult()
Execute a query that returns a single result.

Specified by:
getSingleResult in interface Query

executeUpdate

public int executeUpdate()
Specified by:
executeUpdate in interface Query

getFlushMode

public FlushModeType getFlushMode()
Description copied from interface: OpenJPAQuery
Return the current flush mode.

Specified by:
getFlushMode in interface OpenJPAQuery

setFlushMode

public OpenJPAQuery setFlushMode(FlushModeType flushMode)
Specified by:
setFlushMode in interface Query
Specified by:
setFlushMode in interface OpenJPAQuery

setHint

public OpenJPAQuery setHint(String key,
                            Object value)
Specified by:
setHint in interface Query
Specified by:
setHint in interface OpenJPAQuery

setParameter

public OpenJPAQuery setParameter(int position,
                                 Calendar value,
                                 TemporalType t)
Specified by:
setParameter in interface Query
Specified by:
setParameter in interface OpenJPAQuery

setParameter

public OpenJPAQuery setParameter(int position,
                                 Date value,
                                 TemporalType type)
Specified by:
setParameter in interface Query
Specified by:
setParameter in interface OpenJPAQuery

setParameter

public OpenJPAQuery setParameter(int position,
                                 Object value)
Specified by:
setParameter in interface Query
Specified by:
setParameter in interface OpenJPAQuery

setParameter

public OpenJPAQuery setParameter(String name,
                                 Calendar value,
                                 TemporalType t)
Specified by:
setParameter in interface Query
Specified by:
setParameter in interface OpenJPAQuery

setParameter

public OpenJPAQuery setParameter(String name,
                                 Date value,
                                 TemporalType type)
Specified by:
setParameter in interface Query
Specified by:
setParameter in interface OpenJPAQuery

setParameter

public OpenJPAQuery setParameter(String name,
                                 Object value)
Specified by:
setParameter in interface Query
Specified by:
setParameter in interface OpenJPAQuery

hasPositionalParameters

public boolean hasPositionalParameters()
Description copied from interface: OpenJPAQuery
Whether this query has positional parameters.

Specified by:
hasPositionalParameters in interface OpenJPAQuery

getPositionalParameters

public Object[] getPositionalParameters()
Description copied from interface: OpenJPAQuery
The positional parameters for the query; empty array if none or if query uses named parameters.

Specified by:
getPositionalParameters in interface OpenJPAQuery

setParameters

public OpenJPAQuery setParameters(Object... params)
Description copied from interface: OpenJPAQuery
Set parameters.

Specified by:
setParameters in interface OpenJPAQuery

getNamedParameters

public Map getNamedParameters()
Description copied from interface: OpenJPAQuery
The named parameters for the query; empty map if none or if query uses named parameters.

Specified by:
getNamedParameters in interface OpenJPAQuery

setParameters

public OpenJPAQuery setParameters(Map params)
Description copied from interface: OpenJPAQuery
Set parameters.

Specified by:
setParameters in interface OpenJPAQuery

closeAll

public OpenJPAQuery closeAll()
Description copied from interface: OpenJPAQuery
Close all open query results.

Specified by:
closeAll in interface OpenJPAQuery

getDataStoreActions

public String[] getDataStoreActions(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 interface OpenJPAQuery
Parameters:
params - the named parameter map for the query invocation

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object


Copyright © 2006 Apache Software Foundation. All Rights Reserved.