org.apache.cayenne.query
Class EJBQLQuery

java.lang.Object
  extended by org.apache.cayenne.query.EJBQLQuery
All Implemented Interfaces:
java.io.Serializable, ConfigurationNode, Query, XMLSerializable

public class EJBQLQuery
extends java.lang.Object
implements Query, XMLSerializable

An EJBQL query representation in Cayenne.

Since:
3.0
See Also:
Serialized Form

Field Summary
protected  DataMap dataMap
           
protected  java.lang.String ejbqlStatement
           
protected  EJBQLCompiledExpression expression
           
protected  java.lang.String name
           
protected  java.util.Map<java.lang.String,java.lang.Object> namedParameters
           
protected  java.util.Map<java.lang.Integer,java.lang.Object> positionalParameters
           
 
Constructor Summary
EJBQLQuery()
           
EJBQLQuery(java.lang.String ejbqlStatement)
           
 
Method Summary
<T> T
acceptVisitor(ConfigurationNodeVisitor<T> visitor)
           
 SQLAction createSQLAction(SQLActionVisitor visitor)
          A callback method invoked by Cayenne during the final execution phase of the query run.
 void encodeAsXML(XMLEncoder encoder)
          Prints itself as XML to the provided XMLEncoder.
 java.lang.String[] getCacheGroups()
           
 QueryCacheStrategy getCacheStrategy()
           
 DataMap getDataMap()
           
 java.lang.String getEjbqlStatement()
          Returns an unparsed EJB QL statement used to initialize this query.
 EJBQLCompiledExpression getExpression(EntityResolver resolver)
          Returns lazily initialized EJBQLCompiledExpression for this query EJBQL.
 int getFetchLimit()
          Returns the fetchLimit property indicating the maximum number of rows this query would return.
 int getFetchOffset()
           
 QueryMetadata getMetaData(EntityResolver resolver)
          Returns query runtime parameters.
 java.lang.String getName()
          Returns a symbolic name of the query.
 java.util.Map<java.lang.String,java.lang.Object> getNamedParameters()
          Returns unmodifiable map of combined named and positional parameters.
 int getPageSize()
           
 java.util.Map<java.lang.Integer,java.lang.Object> getPositionalParameters()
           
 int getStatementFetchSize()
           
 void initWithProperties(java.util.Map<java.lang.String,?> properties)
           
 boolean isFetchingDataRows()
           
 void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery)
          A callback method invoked by Cayenne during the routing phase of the query execution.
 void setCacheGroups(java.lang.String... cacheGroups)
           
 void setCacheStrategy(QueryCacheStrategy strategy)
           
 void setDataMap(DataMap dataMap)
           
 void setEjbqlStatement(java.lang.String text)
           
 void setFetchingDataRows(boolean flag)
           
 void setFetchLimit(int fetchLimit)
          Sets the fetchLimit property indicating the maximum number of rows this query would return.
 void setFetchOffset(int fetchOffset)
           
 void setName(java.lang.String name)
           
 void setPageSize(int pageSize)
           
 void setParameter(int position, java.lang.Object object)
          Sets a positional query parameter value.
 void setParameter(java.lang.String name, java.lang.Object object)
          Sets a named query parameter value.
 void setStatementFetchSize(int size)
          Sets statement's fetch size (0 for no default size)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

dataMap

protected DataMap dataMap

ejbqlStatement

protected java.lang.String ejbqlStatement

namedParameters

protected java.util.Map<java.lang.String,java.lang.Object> namedParameters

positionalParameters

protected java.util.Map<java.lang.Integer,java.lang.Object> positionalParameters

expression

protected transient EJBQLCompiledExpression expression
Constructor Detail

EJBQLQuery

public EJBQLQuery(java.lang.String ejbqlStatement)

EJBQLQuery

public EJBQLQuery()
Method Detail

getDataMap

public DataMap getDataMap()
Specified by:
getDataMap in interface Query
Since:
3.1

setDataMap

public void setDataMap(DataMap dataMap)
Since:
3.1

acceptVisitor

public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
Specified by:
acceptVisitor in interface ConfigurationNode

initWithProperties

public void initWithProperties(java.util.Map<java.lang.String,?> properties)

getMetaData

public QueryMetadata getMetaData(EntityResolver resolver)
Description copied from interface: Query
Returns query runtime parameters. The method is called at various stages of the execution by Cayenne access stack to retrieve query parameters. EntityResolver instance is passed to this method, meaning that the query doesn't need to store direct references to Cayenne mapping objects and can resolve them at runtime.

Specified by:
getMetaData in interface Query

isFetchingDataRows

public boolean isFetchingDataRows()

setFetchingDataRows

public void setFetchingDataRows(boolean flag)

getCacheGroups

public java.lang.String[] getCacheGroups()

getCacheStrategy

public QueryCacheStrategy getCacheStrategy()

setCacheGroups

public void setCacheGroups(java.lang.String... cacheGroups)

setCacheStrategy

public void setCacheStrategy(QueryCacheStrategy strategy)

route

public void route(QueryRouter router,
                  EntityResolver resolver,
                  Query substitutedQuery)
Description copied from interface: Query
A callback method invoked by Cayenne during the routing phase of the query execution. Mapping of DataNodes is provided by QueryRouter. Query should use a QueryRouter.route(QueryEngine, Query, Query) callback method to route itself. Query can create one or more substitute queries or even provide its own QueryEngine to execute itself.

Specified by:
route in interface Query

createSQLAction

public SQLAction createSQLAction(SQLActionVisitor visitor)
Description copied from interface: Query
A callback method invoked by Cayenne during the final execution phase of the query run. A concrete query implementation is given a chance to decide how it should be handled. Implementors can pick an appropriate method of the SQLActionVisitor to handle itself, create a custom SQLAction of its own, or substitute itself with another query that should be used for SQLAction construction.

Specified by:
createSQLAction in interface Query

getEjbqlStatement

public java.lang.String getEjbqlStatement()
Returns an unparsed EJB QL statement used to initialize this query.


getExpression

public EJBQLCompiledExpression getExpression(EntityResolver resolver)
                                      throws EJBQLException
Returns lazily initialized EJBQLCompiledExpression for this query EJBQL.

Throws:
EJBQLException

getName

public java.lang.String getName()
Description copied from interface: Query
Returns a symbolic name of the query. The name is normally used as a key to find queries stored in the DataMap.

Specified by:
getName in interface Query

setName

public void setName(java.lang.String name)

getNamedParameters

public java.util.Map<java.lang.String,java.lang.Object> getNamedParameters()
Returns unmodifiable map of combined named and positional parameters. Positional parameter keys are Integers, while named parameter keys are strings.


getPositionalParameters

public java.util.Map<java.lang.Integer,java.lang.Object> getPositionalParameters()

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object object)
Sets a named query parameter value.


setParameter

public void setParameter(int position,
                         java.lang.Object object)
Sets a positional query parameter value. Note that parameter indexes are starting from 1.


getFetchLimit

public int getFetchLimit()
Returns the fetchLimit property indicating the maximum number of rows this query would return.


setFetchLimit

public void setFetchLimit(int fetchLimit)
Sets the fetchLimit property indicating the maximum number of rows this query would return.


getFetchOffset

public int getFetchOffset()

setFetchOffset

public void setFetchOffset(int fetchOffset)

encodeAsXML

public void encodeAsXML(XMLEncoder encoder)
Description copied from interface: XMLSerializable
Prints itself as XML to the provided XMLEncoder.

Specified by:
encodeAsXML in interface XMLSerializable

setEjbqlStatement

public void setEjbqlStatement(java.lang.String text)

getPageSize

public int getPageSize()

setPageSize

public void setPageSize(int pageSize)

setStatementFetchSize

public void setStatementFetchSize(int size)
Sets statement's fetch size (0 for no default size)

Since:
3.0

getStatementFetchSize

public int getStatementFetchSize()
Returns:
statement's fetch size
Since:
3.0


Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.