|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.ojb.broker.query.AbstractQueryImpl org.apache.ojb.broker.query.QueryByCriteria
public class QueryByCriteria
represents a search by criteria. "find all articles where article.price > 100" could be represented as: Criteria crit = new Criteria(); crit.addGreaterThan("price", new Double(100)); Query qry = new QueryByCriteria(Article.class, crit); The PersistenceBroker can retrieve Objects by Queries as follows: PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(); Collection col = broker.getCollectionByQuery(qry); Creation date: (24.01.2001 21:45:46)
Field Summary | |
---|---|
static Criteria |
CRITERIA_SELECT_ALL
handy criteria that can be used to select all instances of a class. |
private Criteria |
m_criteria
|
private boolean |
m_distinct
|
private List |
m_groupby
|
private Criteria |
m_havingCriteria
|
private String |
m_objectProjectionAttribute
|
private List |
m_orderby
|
private Map |
m_pathClasses
|
private Collection |
m_pathOuterJoins
|
private List |
m_prefetchedRelationships
|
Fields inherited from class org.apache.ojb.broker.query.AbstractQueryImpl |
---|
m_baseClass, m_searchClass, serialVersionUID |
Fields inherited from interface org.apache.ojb.broker.query.Query |
---|
NO_END_AT_INDEX, NO_START_AT_INDEX, NOT_SCROLLABLE, SCROLLABLE |
Constructor Summary | |
---|---|
QueryByCriteria(Class aClassToSearchFrom)
Build a Query based on a Class Object. |
|
QueryByCriteria(Class targetClass,
Criteria criteria)
Build a Query for class targetClass with criteria. |
|
QueryByCriteria(Class targetClass,
Criteria criteria,
boolean distinct)
Build a Query for class targetClass with criteria. |
|
QueryByCriteria(Class targetClass,
Criteria whereCriteria,
Criteria havingCriteria)
Build a Query for class targetClass with criteria. |
|
QueryByCriteria(Class targetClass,
Criteria whereCriteria,
Criteria havingCriteria,
boolean distinct)
Build a Query for class targetClass with criteria. |
|
QueryByCriteria(Object anObject)
Build a Query based on anObject all non null values are used as EqualToCriteria |
|
QueryByCriteria(Object anObject,
boolean distinct)
Build a Query based on anObject all non null values are used as EqualToCriteria |
Method Summary | |
---|---|
void |
addGroupBy(FieldHelper aField)
Adds a field for groupby |
void |
addGroupBy(String fieldName)
Adds a groupby fieldName for ReportQueries. |
void |
addGroupBy(String[] fieldNames)
Adds an array of groupby fieldNames for ReportQueries. |
void |
addOrderBy(FieldHelper aField)
Adds a field for orderBy |
void |
addOrderBy(String fieldName)
Deprecated. use #addOrderByAscending(String fieldName) |
void |
addOrderBy(String fieldName,
boolean sortAscending)
Adds a field for orderBy |
void |
addOrderByAscending(String fieldName)
Adds a field for orderBy ASCENDING |
void |
addOrderByDescending(String fieldName)
Adds a field for orderBy DESCENDING |
void |
addPathClass(String aPath,
Class aClass)
Add a hint Class for a path. |
void |
addPrefetchedRelationship(String aName)
add the name of aRelationship for prefetched read |
private static Criteria |
buildCriteria(Object anExample)
Build Criteria based on example object all non null values are used as EqualToCriteria |
List |
getClassesForPath(String aPath)
Get the a List of Class objects used as hints for a path |
Criteria |
getCriteria()
return the criteria of the query if present or null. |
List |
getGroupBy()
Gets the groupby for ReportQueries of all Criteria and Sub Criteria the elements are of class FieldHelper |
Criteria |
getHavingCriteria()
return the criteria of the query if present or null. |
String |
getObjectProjectionAttribute()
|
List |
getOrderBy()
Answer the orderBy of all Criteria and Sub Criteria the elements are of class FieldHelper |
Collection |
getOuterJoinPaths()
Get a Collection containing all Paths having an Outer-Joins-Setting |
Map |
getPathClasses()
Gets the pathClasses. |
List |
getPrefetchedRelationships()
Returns the names of Relationships to be prefetched |
boolean |
isDistinct()
Gets the distinct. |
boolean |
isPathOuterJoin(String aPath)
Answer true if outer join for path should be used. |
void |
setCriteria(Criteria criteria)
Sets the criteria. |
void |
setDistinct(boolean distinct)
Sets the distinct. |
void |
setHavingCriteria(Criteria havingCriteria)
Sets the havingCriteria. |
void |
setObjectProjectionAttribute(String objectProjectionAttribute)
Use this method to query some related class by object references, for example query.setObjectProjectionAttribute("ref1.ref2.ref3"); |
void |
setObjectProjectionAttribute(String objectProjectionAttribute,
Class objectProjectionClass)
|
void |
setPathClass(String aPath,
Class aClass)
Set the Class for a path. |
void |
setPathOuterJoin(String aPath)
Force outer join for the last segment of the path. |
String |
toString()
Insert the method's description here. |
Methods inherited from class org.apache.ojb.broker.query.AbstractQueryImpl |
---|
fullSize, fullSize, getBaseClass, getEndAtIndex, getExampleObject, getFetchSize, getSearchClass, getStartAtIndex, getWithExtents, setEndAtIndex, setFetchSize, setStartAtIndex, setWithExtents, usePaging |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Criteria m_criteria
private boolean m_distinct
private Map m_pathClasses
private Criteria m_havingCriteria
private String m_objectProjectionAttribute
private List m_orderby
private List m_groupby
private List m_prefetchedRelationships
private Collection m_pathOuterJoins
public static final Criteria CRITERIA_SELECT_ALL
Constructor Detail |
---|
public QueryByCriteria(Class targetClass, Criteria whereCriteria, Criteria havingCriteria, boolean distinct)
public QueryByCriteria(Class targetClass, Criteria whereCriteria, Criteria havingCriteria)
public QueryByCriteria(Class targetClass, Criteria criteria)
public QueryByCriteria(Class targetClass, Criteria criteria, boolean distinct)
public QueryByCriteria(Object anObject, boolean distinct)
public QueryByCriteria(Object anObject)
public QueryByCriteria(Class aClassToSearchFrom)
aClassToSearchFrom
- the class to search fromMethod Detail |
---|
private static Criteria buildCriteria(Object anExample)
public void addPathClass(String aPath, Class aClass)
aPath
- the path segment ie: allArticlesInGroupaClass
- the Class ie: CdArticleorg.apache.ojb.broker.QueryTest#testInversePathExpression()
public void setPathClass(String aPath, Class aClass)
aPath
- the path segment ie: allArticlesInGroupaClass
- the Class ie: CdArticleorg.apache.ojb.broker.QueryTest#testInversePathExpression()
,
addPathClass(java.lang.String, java.lang.Class)
public List getClassesForPath(String aPath)
aPath
- the path segment ie: allArticlesInGroup
addPathClass(java.lang.String, java.lang.Class)
,
org.apache.ojb.broker.QueryTest#testInversePathExpression()
public boolean isPathOuterJoin(String aPath)
aPath
- the path to query the outer join setting for
public void setPathOuterJoin(String aPath)
aPath
- force outer join to the last segment of this pathpublic Criteria getCriteria()
Query
getCriteria
in interface Query
getCriteria
in class AbstractQueryImpl
public Criteria getHavingCriteria()
Query
getHavingCriteria
in interface Query
getHavingCriteria
in class AbstractQueryImpl
public String toString()
toString
in class Object
public boolean isDistinct()
isDistinct
in interface Query
isDistinct
in class AbstractQueryImpl
public void setDistinct(boolean distinct)
distinct
- The distinct to setpublic Map getPathClasses()
public void setCriteria(Criteria criteria)
criteria
- The criteria to setpublic void setHavingCriteria(Criteria havingCriteria)
havingCriteria
- The havingCriteria to setpublic void addGroupBy(String fieldName)
fieldName
- The groupby to setpublic void addGroupBy(FieldHelper aField)
aField
- public void addGroupBy(String[] fieldNames)
fieldNames
- The groupby to setpublic List getGroupBy()
Query
getGroupBy
in interface Query
getGroupBy
in class AbstractQueryImpl
Query.getGroupBy()
public void addOrderBy(String fieldName, boolean sortAscending)
fieldName
- The field name to be usedsortAscending
- true for ASCENDING, false for DESCENDINGpublic void addOrderBy(String fieldName)
fieldName
- The field name to be usedpublic void addOrderBy(FieldHelper aField)
aField
- public void addOrderByAscending(String fieldName)
fieldName
- The field name to be usedpublic void addOrderByDescending(String fieldName)
fieldName
- The field name to be usedpublic List getOrderBy()
Query
getOrderBy
in interface Query
getOrderBy
in class AbstractQueryImpl
Query.getOrderBy()
public void addPrefetchedRelationship(String aName)
public List getPrefetchedRelationships()
Query
getPrefetchedRelationships
in interface Query
getPrefetchedRelationships
in class AbstractQueryImpl
public Collection getOuterJoinPaths()
public String getObjectProjectionAttribute()
public void setObjectProjectionAttribute(String objectProjectionAttribute)
public void setObjectProjectionAttribute(String objectProjectionAttribute, Class objectProjectionClass)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |