|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.ojb.broker.query.Criteria
Persistent Criteria can be used to retrieve sets of objects based on their attributes Normally each attribute is ANDed together, an OR can be performed by creating a new PersistentCriteria and adding it.
Criteria are used, rather than a simple string, because they can be precompiled for efficiency. This code is based on stuff from COBRA - Java Object Persistence Layer Copyright (C) 1997, 1998 DB Harvey-George eMail: cobra@lowrent.org
| Field Summary | |
static int |
AND
|
protected static int |
IN_LIMIT
|
static int |
NONE
|
static int |
OR
|
static java.lang.String |
PARENT_QUERY_PREFIX
|
(package private) static long |
serialVersionUID
|
| Constructor Summary | |
Criteria()
Constructor declaration |
|
Criteria(SelectionCriteria aSelectionCriteria)
Constructor with a SelectionCriteria |
|
| Method Summary | |
protected java.util.List |
_getGroupby()
Gets the groupby for ReportQueries, the elements are of class Criteria.FieldHelper |
protected java.util.List |
_getOrderby()
Answer the Vector with all orderBy, the elements are of class Criteria.FieldHelper |
void |
addAndCriteria(Criteria pc)
ANDs two sets of criteria together: |
void |
addBetween(java.lang.Object attribute,
java.lang.Object value1,
java.lang.Object value2)
Adds BETWEEN criteria, customer_id between 1 and 10 |
void |
addColumnEqualTo(java.lang.String column,
java.lang.Object value)
Adds and equals (=) criteria, CUST_ID = 10034 attribute will NOT be translated into column name |
void |
addColumnEqualToField(java.lang.String column,
java.lang.Object fieldName)
Adds and equals (=) criteria for field comparison. |
protected void |
addCriteria(Criteria crit)
|
protected void |
addCriteria(java.util.Vector criteria)
|
void |
addEqualTo(java.lang.String attribute,
java.lang.Object value)
Adds and equals (=) criteria, customer_id = 10034 |
void |
addEqualToColumn(java.lang.String attribute,
java.lang.String colName)
Adds and equals (=) criteria for column comparison. |
void |
addEqualToField(java.lang.String attribute,
java.lang.String fieldName)
Adds and equals (=) criteria for field comparison. |
void |
addExists(Query subQuery)
Adds an exists(sub query) |
void |
addGreaterOrEqualThan(java.lang.Object attribute,
java.lang.Object value)
Adds GreaterOrEqual Than (>=) criteria, customer_id >= 10034 |
void |
addGreaterOrEqualThanField(java.lang.String attribute,
java.lang.Object value)
Adds GreaterOrEqual Than (>=) criteria, customer_id >= person_id |
void |
addGreaterThan(java.lang.Object attribute,
java.lang.Object value)
Adds Greater Than (>) criteria, customer_id > 10034 |
void |
addGreaterThanField(java.lang.String attribute,
java.lang.Object value)
Adds Greater Than (>) criteria, customer_id > person_id |
void |
addGroupBy(FieldHelper aField)
Deprecated. use QueryByCriteria#addGroupBy |
void |
addGroupBy(java.lang.String fieldName)
Deprecated. use QueryByCriteria#addGroupBy |
void |
addGroupBy(java.lang.String[] fieldNames)
Deprecated. use QueryByCriteria#addGroupBy |
void |
addIn(java.lang.Object attribute,
Query subQuery)
IN Criteria with SubQuery |
void |
addIn(java.lang.String attribute,
java.util.Collection values)
Adds IN criteria, customer_id in(1,10,33,44) large values are split into multiple InCriteria IN (1,10) OR IN(33, 44) |
void |
addIsNull(java.lang.String attribute)
Adds is Null criteria, customer_id is Null |
void |
addLessOrEqualThan(java.lang.Object attribute,
java.lang.Object value)
Adds LessOrEqual Than (<=) criteria, customer_id <= 10034 |
void |
addLessOrEqualThanField(java.lang.String attribute,
java.lang.Object value)
Adds LessOrEqual Than (<=) criteria, customer_id <= person_id |
void |
addLessThan(java.lang.Object attribute,
java.lang.Object value)
Adds Less Than (<) criteria, customer_id < 10034 |
void |
addLessThanField(java.lang.String attribute,
java.lang.Object value)
Adds Less Than (<) criteria, customer_id < person_id |
void |
addLike(java.lang.Object attribute,
java.lang.Object value)
Adds Like (LIKE) criteria, customer_name LIKE "m%ller" |
void |
addNotBetween(java.lang.Object attribute,
java.lang.Object value1,
java.lang.Object value2)
Adds NOT BETWEEN criteria, customer_id not between 1 and 10 |
void |
addNotEqualTo(java.lang.Object attribute,
java.lang.Object value)
Adds NotEqualTo (<>) criteria, customer_id <> 10034 |
void |
addNotEqualToColumn(java.lang.String attribute,
java.lang.String colName)
Adds and equals (<>) criteria for column comparison. |
void |
addNotEqualToField(java.lang.String attribute,
java.lang.String fieldName)
Adds and equals (=) criteria for field comparison. |
void |
addNotExists(Query subQuery)
Adds a not exists(sub query) |
void |
addNotIn(java.lang.String attribute,
java.util.Collection values)
Adds NOT IN criteria, customer_id not in(1,10,33,44) large values are split into multiple InCriteria NOT IN (1,10) AND NOT IN(33, 44) |
void |
addNotIn(java.lang.String attribute,
Query subQuery)
NOT IN Criteria with SubQuery |
void |
addNotLike(java.lang.String attribute,
java.lang.Object value)
Adds Like (NOT LIKE) criteria, customer_id NOT LIKE 10034 |
void |
addNotNull(java.lang.String attribute)
Adds not Null criteria, customer_id is not Null |
void |
addOrCriteria(Criteria pc)
ORs two sets of criteria together: |
void |
addOrderBy(FieldHelper aField)
Deprecated. use QueryByCriteria#addOrderBy |
void |
addOrderBy(java.lang.String fieldName)
Deprecated. use #addOrderByAscending(String fieldName) |
void |
addOrderBy(java.lang.String fieldName,
boolean sortAscending)
Adds a field for orderBy |
void |
addOrderByAscending(java.lang.String fieldName)
Deprecated. use QueryByCriteria#addOrderByAscending |
void |
addOrderByDescending(java.lang.String fieldName)
Deprecated. use QueryByCriteria#addOrderByDescending |
void |
addPrefetchedRelationship(java.lang.String aName)
Deprecated. use QueryByCriteria#addPrefetchedRelationship |
protected void |
addSelectionCriteria(SelectionCriteria selectionCrit)
|
void |
addSql(java.lang.String anSqlStatment)
Adds freeform SQL criteria, REVERSE(name) like 're%' |
Criteria |
copy(boolean includeGroupBy,
boolean includeOrderBy,
boolean includePrefetchedRelationships)
make a copy of the criteria |
java.lang.String |
getAlias()
|
protected java.util.Vector |
getCriteria()
Get a Vector with all sub criteria |
java.util.Enumeration |
getElements()
Get an Enumeration with all sub criteria |
(package private) java.util.List |
getGroupby()
Gets the groupby for ReportQueries of all Criteria and Sub Criteria the elements are of class FieldHelper |
(package private) java.util.List |
getOrderby()
Answer the orderBy of all Criteria and Sub Criteria the elements are of class Criteria.FieldHelper |
Criteria |
getParentCriteria()
|
(package private) java.util.List |
getPrefetchedRelationships()
Returns the prefetchedRelationships. |
QueryByCriteria |
getQuery()
|
int |
getType()
Answer the type |
boolean |
isEmbraced()
Answer true if embraced, ANDed criteria are embraced |
boolean |
isEmpty()
Answer true if no sub criteria available |
boolean |
isNegative()
|
void |
setAlias(java.lang.String alias)
Sets the alias. |
void |
setEmbraced(boolean embraced)
Set embraced |
void |
setNegative(boolean negative)
Flags the whole Criteria as negative. |
(package private) void |
setParentCriteria(Criteria criteria)
|
(package private) void |
setQuery(QueryByCriteria query)
|
void |
setType(int type)
Set the type |
protected java.util.List |
splitInCriteria(java.lang.Object attribute,
java.util.Collection values,
boolean negative,
int inLimit)
Answer a List of InCriteria based on values, each InCriteria contains only inLimit values |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
static final long serialVersionUID
public static final int OR
public static final int AND
public static final int NONE
public static java.lang.String PARENT_QUERY_PREFIX
protected static final int IN_LIMIT
| Constructor Detail |
public Criteria()
public Criteria(SelectionCriteria aSelectionCriteria)
aSelectionCriteria - | Method Detail |
public Criteria copy(boolean includeGroupBy,
boolean includeOrderBy,
boolean includePrefetchedRelationships)
includeGroupBy - includeOrderBy - includePrefetchedRelationships -
protected void addSelectionCriteria(SelectionCriteria selectionCrit)
protected void addCriteria(Criteria crit)
protected void addCriteria(java.util.Vector criteria)
protected java.util.List splitInCriteria(java.lang.Object attribute,
java.util.Collection values,
boolean negative,
int inLimit)
attribute - values - negative - inLimit - the maximum number of values for IN (-1 for no limit)
public java.util.Enumeration getElements()
protected java.util.Vector getCriteria()
public int getType()
public void setType(int type)
type - public boolean isEmbraced()
public void setEmbraced(boolean embraced)
embraced -
public void addEqualTo(java.lang.String attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the field
public void addColumnEqualTo(java.lang.String column,
java.lang.Object value)
column - The column name to be used without translationvalue - An object representing the value of the column
public void addColumnEqualToField(java.lang.String column,
java.lang.Object fieldName)
column - The column name to be used without translationfieldName - An object representing the value of the field
public void addEqualToField(java.lang.String attribute,
java.lang.String fieldName)
attribute - The field name to be usedfieldName - The field name to compare with
public void addNotEqualToField(java.lang.String attribute,
java.lang.String fieldName)
attribute - The field name to be usedfieldName - The field name to compare with
public void addNotEqualToColumn(java.lang.String attribute,
java.lang.String colName)
attribute - The field name to be usedcolName - The name of the column to compare with
public void addEqualToColumn(java.lang.String attribute,
java.lang.String colName)
attribute - The field name to be usedcolName - The name of the column to compare with
public void addGreaterOrEqualThan(java.lang.Object attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the field
public void addGreaterOrEqualThanField(java.lang.String attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - The field name to compare with
public void addLessOrEqualThan(java.lang.Object attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the field
public void addLessOrEqualThanField(java.lang.String attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - The field name to compare with
public void addLike(java.lang.Object attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the fieldLikeCriteria
public void addNotLike(java.lang.String attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the fieldLikeCriteria
public void addNotEqualTo(java.lang.Object attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the field
public void addGreaterThan(java.lang.Object attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the field
public void addGreaterThanField(java.lang.String attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - The field to compare with
public void addLessThan(java.lang.Object attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - An object representing the value of the field
public void addLessThanField(java.lang.String attribute,
java.lang.Object value)
attribute - The field name to be usedvalue - The field to compare withpublic void addOrderBy(java.lang.String fieldName)
fieldName - The field name to be used
public void addOrderBy(java.lang.String fieldName,
boolean sortAscending)
fieldName - The field name to be usedsortAscending - true for ASCENDING, false for DESCENDINGpublic void addOrderBy(FieldHelper aField)
aField - public void addOrderByAscending(java.lang.String fieldName)
fieldName - The field name to be usedpublic void addOrderByDescending(java.lang.String fieldName)
fieldName - The field name to be usedjava.util.List getOrderby()
protected java.util.List _getOrderby()
public void addOrCriteria(Criteria pc)
active = true AND balance < 0 OR active = true AND overdraft = 0
pc - criteriapublic void addIsNull(java.lang.String attribute)
attribute - The field name to be usedpublic void addNotNull(java.lang.String attribute)
attribute - The field name to be used
public void addBetween(java.lang.Object attribute,
java.lang.Object value1,
java.lang.Object value2)
attribute - The field name to be usedvalue1 - The lower boundaryvalue2 - The upper boundary
public void addNotBetween(java.lang.Object attribute,
java.lang.Object value1,
java.lang.Object value2)
attribute - The field name to be usedvalue1 - The lower boundaryvalue2 - The upper boundary
public void addIn(java.lang.String attribute,
java.util.Collection values)
attribute - The field name to be usedvalues - The value Collection
public void addNotIn(java.lang.String attribute,
java.util.Collection values)
attribute - The field name to be usedvalues - The value Collection
public void addIn(java.lang.Object attribute,
Query subQuery)
attribute - subQuery -
public void addNotIn(java.lang.String attribute,
Query subQuery)
attribute - subQuery - public void addSql(java.lang.String anSqlStatment)
anSqlStatment - The free form SQL-Statementpublic void addAndCriteria(Criteria pc)
pc - criteriapublic void addExists(Query subQuery)
subQuery - sub-querypublic void addNotExists(Query subQuery)
subQuery - sub-querypublic boolean isEmpty()
java.util.List getGroupby()
protected java.util.List _getGroupby()
public void addGroupBy(java.lang.String fieldName)
fieldName - The groupby to setpublic void addGroupBy(FieldHelper aField)
aField - public void addGroupBy(java.lang.String[] fieldNames)
fieldNames - The groupby to setjava.util.List getPrefetchedRelationships()
public void addPrefetchedRelationship(java.lang.String aName)
public java.lang.String getAlias()
public void setAlias(java.lang.String alias)
alias - The alias to setpublic QueryByCriteria getQuery()
void setQuery(QueryByCriteria query)
query - public Criteria getParentCriteria()
void setParentCriteria(Criteria criteria)
criteria - public java.lang.String toString()
public boolean isNegative()
public void setNegative(boolean negative)
negative - The negative to set.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||