org.apache.cayenne.query
Class NamedQuery

java.lang.Object
  extended by org.apache.cayenne.query.IndirectQuery
      extended by org.apache.cayenne.query.NamedQuery
All Implemented Interfaces:
Serializable, Query

public class NamedQuery
extends IndirectQuery

A query that is a reference to a named parameterized query stored in the mapping. The actual query is resolved during execution.

Since:
1.2
See Also:
Serialized Form

Field Summary
protected  boolean forceNoCache
           
protected  org.apache.cayenne.query.BaseQueryMetadata overrideMetadata
           
protected  Map<String,Object> parameters
           
 
Fields inherited from class org.apache.cayenne.query.IndirectQuery
lastResolver, name, replacementQuery
 
Constructor Summary
NamedQuery(String name)
           
NamedQuery(String name, Map<String,?> parameters)
           
NamedQuery(String name, String[] keys, Object[] values)
          Creates NamedQuery with parameters passed as two matching arrays of keys and values.
 
Method Summary
protected  Query createReplacementQuery(EntityResolver resolver)
          Creates a substitute query.
 boolean equals(Object object)
          An object is considered equal to this NamedQuery if it is a NamedQuery with the same queryName and same parameters.
 QueryMetadata getMetaData(EntityResolver resolver)
          Returns the metadata obtained from the replacement query.
 int hashCode()
          Implements a standard hashCode contract considering custom 'equals' implementation.
 void initMetadata(QueryMetadata metadata)
          Initializes metadata overrides.
 boolean isForceNoCache()
           
protected  Query resolveQuery(EntityResolver resolver)
          Returns a query for name, throwing an exception if such query is not mapped in the EntityResolver.
 void setForceNoCache(boolean forcingNoCache)
           
 String toString()
          Overrides toString() outputting a short string with query class and name.
 
Methods inherited from class org.apache.cayenne.query.IndirectQuery
createSQLAction, getName, getReplacementQuery, route, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

parameters

protected Map<String,Object> parameters

forceNoCache

protected boolean forceNoCache

overrideMetadata

protected org.apache.cayenne.query.BaseQueryMetadata overrideMetadata
Constructor Detail

NamedQuery

public NamedQuery(String name)

NamedQuery

public NamedQuery(String name,
                  Map<String,?> parameters)

NamedQuery

public NamedQuery(String name,
                  String[] keys,
                  Object[] values)
Creates NamedQuery with parameters passed as two matching arrays of keys and values.

Method Detail

getMetaData

public QueryMetadata getMetaData(EntityResolver resolver)
Description copied from class: IndirectQuery
Returns the metadata obtained from the replacement query.

Specified by:
getMetaData in interface Query
Overrides:
getMetaData in class IndirectQuery

createReplacementQuery

protected Query createReplacementQuery(EntityResolver resolver)
Description copied from class: IndirectQuery
Creates a substitute query. An implementor is free to provide an arbitrary replacement query.

Specified by:
createReplacementQuery in class IndirectQuery

resolveQuery

protected Query resolveQuery(EntityResolver resolver)
Returns a query for name, throwing an exception if such query is not mapped in the EntityResolver.


toString

public String toString()
Overrides toString() outputting a short string with query class and name.

Overrides:
toString in class Object

initMetadata

public void initMetadata(QueryMetadata metadata)
Initializes metadata overrides. Needed to store the metadata for the remote query proxies that have no access to the actual query.


equals

public boolean equals(Object object)
An object is considered equal to this NamedQuery if it is a NamedQuery with the same queryName and same parameters.

Overrides:
equals in class Object

hashCode

public int hashCode()
Implements a standard hashCode contract considering custom 'equals' implementation.

Overrides:
hashCode in class Object

isForceNoCache

public boolean isForceNoCache()

setForceNoCache

public void setForceNoCache(boolean forcingNoCache)


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