org.jaffa.persistence
Class Criteria

java.lang.Object
  extended byorg.jaffa.persistence.Criteria
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AtomicCriteria

public class Criteria
extends Object
implements Serializable

This object is used by the persistence layer to query the underlying store.

See Also:
Serialized Form

Nested Class Summary
 class Criteria.AtomicCriteriaEntry
          The class is used by the Criteria to add an AtomicCriteria object to its collection of criteria entries.
 class Criteria.CriteriaEntry
          This class is used by the Criteria for each criteria entry.
 class Criteria.OrderBy
          This class is used by the Criteria for each order by element.
 
Field Summary
static int LOCKING_OPTIMISTIC
          Use this static to indicate optimistic locking on a query.
static int LOCKING_PARANOID
          Use this static to indicate paranoid locking on a query.
static int LOCKING_PESSIMISTIC
          Use this static to indicate pessimistic locking on a query.
static int LOCKING_READ_ONLY
          Use this static to indicate that the persistent object cannot be modified.
static int ORDER_BY_ASC
          The static to be used in OrderBy declarations to indicate an ascending sort
static int ORDER_BY_DESC
          The static to be used in OrderBy declarations to indicate an descending sort
static int RELATIONAL_BEGINS_WITH
          The static to be used in criteria declarations to create a construct of the type "like 'Abc%'"
static int RELATIONAL_ENDS_WITH
          The static to be used in criteria declarations to create a construct of the type "like '%Abc'"
static int RELATIONAL_EQUALS
          The static to be used in criteria declarations to indicate an = operator
static int RELATIONAL_GREATER_THAN
          The static to be used in criteria declarations to indicate an > operator
static int RELATIONAL_GREATER_THAN_EQUAL_TO
          The static to be used in criteria declarations to indicate an >= operator
static int RELATIONAL_IS_NOT_NULL
          The static to be used in criteria declarations to indicate an 'is not null' operator
static int RELATIONAL_IS_NULL
          The static to be used in criteria declarations to indicate an 'is null' operator
static int RELATIONAL_LIKE
          The static to be used in criteria declarations to create a construct of the type "like '%Abc%'"
static int RELATIONAL_NOT_EQUALS
          The static to be used in criteria declarations to indicate a !
static int RELATIONAL_SMALLER_THAN
          The static to be used in criteria declarations to indicate an < operator
static int RELATIONAL_SMALLER_THAN_EQUAL_TO
          The static to be used in criteria declarations to indicate an <= operator
 
Constructor Summary
Criteria()
           
 
Method Summary
 void addAggregate(Criteria criteria)
          Add another criteria object to indicate a join.
 void addAtomic(AtomicCriteria atomicCriteria)
          Add an atomic criteria object.
 void addCriteria(String name, int operator)
          Add a criteria entry.
 void addCriteria(String name, int operator, Object value)
          Add a criteria entry.
 void addCriteria(String name, Object value)
          Add a criteria entry.
 void addDualCriteria(String name, int operator, String name2)
          Add a dual criteria entry.
 void addDualCriteria(String name, String name2)
          Add a dual criteria entry.
 void addInnerCriteria(String name, int operator, String name2)
          Add a criteria entry to signify a join condition between 2 persistent classes.
 void addInnerCriteria(String name, String name2)
          Add a criteria entry to signify a join condition between 2 persistent classes.
 void addOrAtomic(AtomicCriteria atomicCriteria)
          Add an OR-ed atomic criteria object.
 void addOrCriteria(String name, int operator)
          Add an OR criteria entry.
 void addOrCriteria(String name, int operator, Object value)
          Add an OR criteria entry.
 void addOrCriteria(String name, Object value)
          Add an OR criteria entry.
 void addOrderBy(String orderByElement, int ordering)
          Add an order by element, specifying the ordering type to be used.
 void clearInnerCriteria()
          Clears the inner criteria entries.
 void clearOrderBy()
          Clear the order by entries.
 Collection getAggregates()
          Returns a collection of Criteria objects, indicating the joins to be performed.
 Collection getCriteriaEntries()
          Returns the criteria entries.
 Collection getInners()
          Returns a collection of criteria entries to signify the join conditions.
 int getLocking()
          Returns the locking strategy for a query.
 Collection getOrderBys()
          Returns a collection of order by elements.
 String getTable()
          Returns the name of the persistent class on which the query is to be performed.
 UOW getUow()
          Returns the UOW against which the query is to be performed.
 void setLocking(int locking)
          Set the locking strategy for a query.
 void setTable(String table)
          Set the persistent class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORDER_BY_ASC

public static final int ORDER_BY_ASC
The static to be used in OrderBy declarations to indicate an ascending sort

See Also:
Constant Field Values

ORDER_BY_DESC

public static final int ORDER_BY_DESC
The static to be used in OrderBy declarations to indicate an descending sort

See Also:
Constant Field Values

RELATIONAL_EQUALS

public static final int RELATIONAL_EQUALS
The static to be used in criteria declarations to indicate an = operator

See Also:
Constant Field Values

RELATIONAL_NOT_EQUALS

public static final int RELATIONAL_NOT_EQUALS
The static to be used in criteria declarations to indicate a != operator

See Also:
Constant Field Values

RELATIONAL_GREATER_THAN

public static final int RELATIONAL_GREATER_THAN
The static to be used in criteria declarations to indicate an > operator

See Also:
Constant Field Values

RELATIONAL_SMALLER_THAN

public static final int RELATIONAL_SMALLER_THAN
The static to be used in criteria declarations to indicate an < operator

See Also:
Constant Field Values

RELATIONAL_GREATER_THAN_EQUAL_TO

public static final int RELATIONAL_GREATER_THAN_EQUAL_TO
The static to be used in criteria declarations to indicate an >= operator

See Also:
Constant Field Values

RELATIONAL_SMALLER_THAN_EQUAL_TO

public static final int RELATIONAL_SMALLER_THAN_EQUAL_TO
The static to be used in criteria declarations to indicate an <= operator

See Also:
Constant Field Values

RELATIONAL_IS_NOT_NULL

public static final int RELATIONAL_IS_NOT_NULL
The static to be used in criteria declarations to indicate an 'is not null' operator

See Also:
Constant Field Values

RELATIONAL_IS_NULL

public static final int RELATIONAL_IS_NULL
The static to be used in criteria declarations to indicate an 'is null' operator

See Also:
Constant Field Values

RELATIONAL_BEGINS_WITH

public static final int RELATIONAL_BEGINS_WITH
The static to be used in criteria declarations to create a construct of the type "like 'Abc%'"

See Also:
Constant Field Values

RELATIONAL_ENDS_WITH

public static final int RELATIONAL_ENDS_WITH
The static to be used in criteria declarations to create a construct of the type "like '%Abc'"

See Also:
Constant Field Values

RELATIONAL_LIKE

public static final int RELATIONAL_LIKE
The static to be used in criteria declarations to create a construct of the type "like '%Abc%'"

See Also:
Constant Field Values

LOCKING_OPTIMISTIC

public static final int LOCKING_OPTIMISTIC
Use this static to indicate optimistic locking on a query. The record in the database will be locked, only when the persistent object is added to the database. This is the default locking strategy.

See Also:
Constant Field Values

LOCKING_PESSIMISTIC

public static final int LOCKING_PESSIMISTIC
Use this static to indicate pessimistic locking on a query. The record in the database will be locked, whenever a field is updated on the object.

See Also:
Constant Field Values

LOCKING_PARANOID

public static final int LOCKING_PARANOID
Use this static to indicate paranoid locking on a query. The record in the database will be locked, at the instant it is read.

See Also:
Constant Field Values

LOCKING_READ_ONLY

public static final int LOCKING_READ_ONLY
Use this static to indicate that the persistent object cannot be modified.

See Also:
Constant Field Values
Constructor Detail

Criteria

public Criteria()
Method Detail

getUow

public UOW getUow()
Returns the UOW against which the query is to be performed.

Returns:
the UOW against which the query is to be performed.

getTable

public String getTable()
Returns the name of the persistent class on which the query is to be performed.

Returns:
the name of the persistent class.

setTable

public void setTable(String table)
Set the persistent class name. This will determine the database-table on which the query is to be performed.

Parameters:
table - The name of the persistent class.

getLocking

public int getLocking()
Returns the locking strategy for a query.

Returns:
the locking strategy for a query.

setLocking

public void setLocking(int locking)
Set the locking strategy for a query.

Parameters:
locking - the locking strategy.

addCriteria

public void addCriteria(String name,
                        Object value)
Add a criteria entry. The operator '=' is used.

Parameters:
name - The name of the field.
value - The value to be assigned to the field.

addCriteria

public void addCriteria(String name,
                        int operator,
                        Object value)
Add a criteria entry.

Parameters:
name - The name of the field.
operator - The operator to be used in the assignment.
value - The value to be assigned to the field.

addCriteria

public void addCriteria(String name,
                        int operator)
Add a criteria entry. This method is to be used for unary operator like 'null' and 'not null'.

Parameters:
name - The name of the field.
operator - The operator to be used in the assignment.

addOrCriteria

public void addOrCriteria(String name,
                          Object value)
Add an OR criteria entry. The operator '=' is used.

Parameters:
name - The name of the field.
value - The value to be assigned to the field.

addOrCriteria

public void addOrCriteria(String name,
                          int operator,
                          Object value)
Add an OR criteria entry.

Parameters:
name - The name of the field.
operator - The operator to be used in the assignment.
value - The value to be assigned to the field.

addOrCriteria

public void addOrCriteria(String name,
                          int operator)
Add an OR criteria entry. This method is to be used for unary operator like 'null' and 'not null'.

Parameters:
name - The name of the field.
operator - The operator to be used in the assignment.

addDualCriteria

public void addDualCriteria(String name,
                            String name2)
Add a dual criteria entry. The operator '=' is used.

Parameters:
name - The name of the first field.
name2 - The name of the second field.

addDualCriteria

public void addDualCriteria(String name,
                            int operator,
                            String name2)
Add a dual criteria entry.

Parameters:
name - The name of the first field.
operator - The operator to be used in the assignment.
name2 - The name of the second field.

addInnerCriteria

public void addInnerCriteria(String name,
                             String name2)
Add a criteria entry to signify a join condition between 2 persistent classes. The operator '=' is used.

Parameters:
name - The field of the persistent class which corresponds to this Criteria object.
name2 - The field of the persistent class, against which the join is to be made.

addInnerCriteria

public void addInnerCriteria(String name,
                             int operator,
                             String name2)
Add a criteria entry to signify a join condition between 2 persistent classes.

Parameters:
name - The field of the persistent class which corresponds to this Criteria object.
operator - The operator to be used in the assignment.
name2 - The field of the persistent class, against which the join is to be made.

clearInnerCriteria

public void clearInnerCriteria()
Clears the inner criteria entries.


addAggregate

public void addAggregate(Criteria criteria)
Add another criteria object to indicate a join.

Parameters:
criteria - The criteria object.

addAtomic

public void addAtomic(AtomicCriteria atomicCriteria)
Add an atomic criteria object. This is used to create combinations of AND/OR clauses.

Parameters:
atomicCriteria - The atomic criteria object

addOrAtomic

public void addOrAtomic(AtomicCriteria atomicCriteria)
Add an OR-ed atomic criteria object. This is used to create combinations of AND/OR clauses.

Parameters:
atomicCriteria - The atomic criteria object

addOrderBy

public void addOrderBy(String orderByElement,
                       int ordering)
Add an order by element, specifying the ordering type to be used.

Parameters:
orderByElement - The name of the field to be used in the order by clause.
ordering - indicates an ascending or a descending sort.

clearOrderBy

public void clearOrderBy()
Clear the order by entries.


getCriteriaEntries

public Collection getCriteriaEntries()
Returns the criteria entries.

Returns:
A collection of Criteria.CriteriaEntry objects.

getAggregates

public Collection getAggregates()
Returns a collection of Criteria objects, indicating the joins to be performed.

Returns:
A collection of Criteria objects.

getInners

public Collection getInners()
Returns a collection of criteria entries to signify the join conditions.

Returns:
A collection of Criteria.CriteriaEntry objects.

getOrderBys

public Collection getOrderBys()
Returns a collection of order by elements.

Returns:
A collection of Criteria.OrderBy objects.


Copyright © 2002-2004 JAFFA Project.