to.etc.webapp.query
Class QCriteria<T>

java.lang.Object
  extended by to.etc.webapp.query.QRestrictor<T>
      extended by to.etc.webapp.query.QCriteriaQueryBase<T>
          extended by to.etc.webapp.query.QCriteria<T>

public class QCriteria<T>
extends QCriteriaQueryBase<T>

Represents the selection of a list of persistent entity classes from the database. A QCriteria has a fixed type (the type of the class being selected) and maintains the list of conditions (criteria's) that the selection must hold. This is a concrete representation of something representing a query tree. To use a QCriteria in an actual query you need a translator which translates the QCriteria tree into something for the target persistence layer. Implementations of such a translator for Hibernate and SPF exist.

Author:
Frits Jalvingh Created on Jun 24, 2008

Method Summary
 QCriteria<T> add(QOperatorNode r)
          
 QCriteria<T> add(QOrder r)
          Add an order clause to the list of sort items.
 QCriteria<T> ascending(java.lang.String property)
          Add a property to do an ascending sort on.
 QCriteria<T> between(java.lang.String property, java.lang.Object a, java.lang.Object b)
          Compare the value of a property with two literal bounds.
static
<U> QCriteria<U>
create(java.lang.Class<U> clz)
          Create a QCriteria to select a set of the specified class.
static
<U> QCriteria<U>
create(ICriteriaTableDef<U> root)
          EXPERIMENTAL Create a QCriteria on some metadata structured data.
 QCriteria<T> descending(java.lang.String property)
          Add a property to do a descending sort on.
 QCriteria<T> eq(java.lang.String property, double value)
          Compare a property with some literal object value.
 QCriteria<T> eq(java.lang.String property, long value)
          Compare a property with some literal object value.
 QCriteria<T> eq(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QCriteria<T> ge(java.lang.String property, double value)
          Compare a property with some literal object value.
 QCriteria<T> ge(java.lang.String property, long value)
          Compare a property with some literal object value.
 QCriteria<T> ge(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QCriteria<T> gt(java.lang.String property, double value)
          Compare a property with some literal object value.
 QCriteria<T> gt(java.lang.String property, long value)
          Compare a property with some literal object value.
 QCriteria<T> gt(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QCriteria<T> ilike(java.lang.String property, java.lang.Object value)
          Do a case-independent 'like' comparison.
 QCriteria<T> isnotnull(java.lang.String property)
          Add the restriction that the property specified must be not-null.
 QCriteria<T> isnull(java.lang.String property)
          Add the restriction that the property specified must be null.
 QCriteria<T> le(java.lang.String property, double value)
          Compare a property with some literal object value.
 QCriteria<T> le(java.lang.String property, long value)
          Compare a property with some literal object value.
 QCriteria<T> le(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QCriteria<T> like(java.lang.String property, java.lang.Object value)
          Do a 'like' comparison.
 QCriteria<T> limit(int limit)
          Limit the #of rows to the specified count.
 QCriteria<T> lt(java.lang.String property, double value)
          Compare a property with some literal object value.
 QCriteria<T> lt(java.lang.String property, long value)
          Compare a property with some literal object value.
 QCriteria<T> lt(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QCriteria<T> ne(java.lang.String property, double value)
          Compare a property with some literal object value.
 QCriteria<T> ne(java.lang.String property, long value)
          Compare a property with some literal object value.
 QCriteria<T> ne(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QCriteria<T> or(QOperatorNode a1, QOperatorNode a2, QOperatorNode... a)
          Deprecated. 
 QCriteria<T> sqlCondition(java.lang.String sql)
          Add a restriction specified in bare SQL.
 QCriteria<T> start(int start)
          Start returning rows at the specified index in the result set (0-based).
 java.lang.String toString()
           
 void visit(QNodeVisitor v)
          Visit everything in this QCriteria.
 
Methods inherited from class to.etc.webapp.query.QCriteriaQueryBase
addColumn, addPropertySelection, avg, avg, count, count, countDistinct, countDistinct, distinct, distinct, getColumnList, getLimit, getOption, getOrder, getRestrictions, getStart, getTimeout, hasOption, max, max, min, min, selectProperty, selectProperty, setOption, setRestrictions, setTimeout, sum, sum
 
Methods inherited from class to.etc.webapp.query.QRestrictor
and, exists, getBaseClass, getMetaTable, getReturnClass, hasRestrictions, internalAdd, or
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static <U> QCriteria<U> create(java.lang.Class<U> clz)
Create a QCriteria to select a set of the specified class. When used on it's own without added criteria this selects all possible items.

Type Parameters:
U -
Parameters:
clz -
Returns:

create

public static <U> QCriteria<U> create(ICriteriaTableDef<U> root)
EXPERIMENTAL Create a QCriteria on some metadata structured data.

Type Parameters:
U -
Parameters:
root -
Returns:

visit

public void visit(QNodeVisitor v)
           throws java.lang.Exception
Visit everything in this QCriteria.

Parameters:
v -
Throws:
java.lang.Exception

add

public QCriteria<T> add(QOperatorNode r)

Overrides:
add in class QRestrictor<T>
See Also:
QRestrictor.add(to.etc.webapp.query.QOperatorNode)

add

public QCriteria<T> add(QOrder r)
Add an order clause to the list of sort items.

Overrides:
add in class QCriteriaQueryBase<T>
Returns:
See Also:
QCriteriaQueryBase.add(to.etc.webapp.query.QOrder)

ascending

public QCriteria<T> ascending(java.lang.String property)
Add a property to do an ascending sort on.

Overrides:
ascending in class QCriteriaQueryBase<T>
Returns:
See Also:
QCriteriaQueryBase.ascending(java.lang.String)

between

public QCriteria<T> between(java.lang.String property,
                            java.lang.Object a,
                            java.lang.Object b)
Compare the value of a property with two literal bounds.

Overrides:
between in class QRestrictor<T>
Returns:
See Also:
QRestrictor.between(java.lang.String, java.lang.Object, java.lang.Object)

descending

public QCriteria<T> descending(java.lang.String property)
Add a property to do a descending sort on.

Overrides:
descending in class QCriteriaQueryBase<T>
Returns:
See Also:
QCriteriaQueryBase.descending(java.lang.String)

eq

public QCriteria<T> eq(java.lang.String property,
                       double value)
Compare a property with some literal object value.

Overrides:
eq in class QRestrictor<T>
Returns:
See Also:
QRestrictor.eq(java.lang.String, double)

eq

public QCriteria<T> eq(java.lang.String property,
                       long value)
Compare a property with some literal object value.

Overrides:
eq in class QRestrictor<T>
Returns:
See Also:
QRestrictor.eq(java.lang.String, long)

eq

public QCriteria<T> eq(java.lang.String property,
                       java.lang.Object value)
Compare a property with some literal object value.

Overrides:
eq in class QRestrictor<T>
Returns:
See Also:
QRestrictor.eq(java.lang.String, java.lang.Object)

ge

public QCriteria<T> ge(java.lang.String property,
                       double value)
Compare a property with some literal object value.

Overrides:
ge in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ge(java.lang.String, double)

ge

public QCriteria<T> ge(java.lang.String property,
                       long value)
Compare a property with some literal object value.

Overrides:
ge in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ge(java.lang.String, long)

ge

public QCriteria<T> ge(java.lang.String property,
                       java.lang.Object value)
Compare a property with some literal object value.

Overrides:
ge in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ge(java.lang.String, java.lang.Object)

gt

public QCriteria<T> gt(java.lang.String property,
                       double value)
Compare a property with some literal object value.

Overrides:
gt in class QRestrictor<T>
Returns:
See Also:
QRestrictor.gt(java.lang.String, double)

gt

public QCriteria<T> gt(java.lang.String property,
                       long value)
Compare a property with some literal object value.

Overrides:
gt in class QRestrictor<T>
Returns:
See Also:
QRestrictor.gt(java.lang.String, long)

gt

public QCriteria<T> gt(java.lang.String property,
                       java.lang.Object value)
Compare a property with some literal object value.

Overrides:
gt in class QRestrictor<T>
Returns:
See Also:
QRestrictor.gt(java.lang.String, java.lang.Object)

ilike

public QCriteria<T> ilike(java.lang.String property,
                          java.lang.Object value)
Do a case-independent 'like' comparison. The wildcard marks here are always %; a literal % is to be presented as \%. The comparison is case-independent.

Overrides:
ilike in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ilike(java.lang.String, java.lang.Object)

isnotnull

public QCriteria<T> isnotnull(java.lang.String property)
Add the restriction that the property specified must be not-null.

Overrides:
isnotnull in class QRestrictor<T>
Returns:
See Also:
QRestrictor.isnotnull(java.lang.String)

isnull

public QCriteria<T> isnull(java.lang.String property)
Add the restriction that the property specified must be null.

Overrides:
isnull in class QRestrictor<T>
Returns:
See Also:
QRestrictor.isnull(java.lang.String)

le

public QCriteria<T> le(java.lang.String property,
                       double value)
Compare a property with some literal object value.

Overrides:
le in class QRestrictor<T>
Returns:
See Also:
QRestrictor.le(java.lang.String, double)

le

public QCriteria<T> le(java.lang.String property,
                       long value)
Compare a property with some literal object value.

Overrides:
le in class QRestrictor<T>
Returns:
See Also:
QRestrictor.le(java.lang.String, long)

le

public QCriteria<T> le(java.lang.String property,
                       java.lang.Object value)
Compare a property with some literal object value.

Overrides:
le in class QRestrictor<T>
Returns:
See Also:
QRestrictor.le(java.lang.String, java.lang.Object)

like

public QCriteria<T> like(java.lang.String property,
                         java.lang.Object value)
Do a 'like' comparison. The wildcard marks here are always %; a literal % is to be presented as \%. The comparison is case-dependent.

Overrides:
like in class QRestrictor<T>
Returns:
See Also:
QRestrictor.like(java.lang.String, java.lang.Object)

lt

public QCriteria<T> lt(java.lang.String property,
                       double value)
Compare a property with some literal object value.

Overrides:
lt in class QRestrictor<T>
Returns:
See Also:
QRestrictor.lt(java.lang.String, double)

lt

public QCriteria<T> lt(java.lang.String property,
                       long value)
Compare a property with some literal object value.

Overrides:
lt in class QRestrictor<T>
Returns:
See Also:
QRestrictor.lt(java.lang.String, long)

lt

public QCriteria<T> lt(java.lang.String property,
                       java.lang.Object value)
Compare a property with some literal object value.

Overrides:
lt in class QRestrictor<T>
Returns:
See Also:
QRestrictor.lt(java.lang.String, java.lang.Object)

ne

public QCriteria<T> ne(java.lang.String property,
                       double value)
Compare a property with some literal object value.

Overrides:
ne in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ne(java.lang.String, double)

ne

public QCriteria<T> ne(java.lang.String property,
                       long value)
Compare a property with some literal object value.

Overrides:
ne in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ne(java.lang.String, long)

ne

public QCriteria<T> ne(java.lang.String property,
                       java.lang.Object value)
Compare a property with some literal object value.

Overrides:
ne in class QRestrictor<T>
Returns:
See Also:
QRestrictor.ne(java.lang.String, java.lang.Object)

or

@Deprecated
public QCriteria<T> or(QOperatorNode a1,
                                  QOperatorNode a2,
                                  QOperatorNode... a)
Deprecated. 

Add a set of OR nodes to the set.

Overrides:
or in class QRestrictor<T>
Returns:
See Also:
to.etc.webapp.query.QCriteriaQueryBase#or(to.etc.webapp.query.QOperatorNode[])

sqlCondition

public QCriteria<T> sqlCondition(java.lang.String sql)
Add a restriction specified in bare SQL. This is implementation-dependent.

Overrides:
sqlCondition in class QRestrictor<T>
Returns:
See Also:
QRestrictor.sqlCondition(java.lang.String)

limit

public QCriteria<T> limit(int limit)
Limit the #of rows to the specified count.

Overrides:
limit in class QCriteriaQueryBase<T>
Returns:
See Also:
QCriteriaQueryBase.limit(int)

start

public QCriteria<T> start(int start)
Start returning rows at the specified index in the result set (0-based).

Overrides:
start in class QCriteriaQueryBase<T>
Returns:
See Also:
QCriteriaQueryBase.start(int)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object