Package com.db4o.query
Interface Query
-
- All Known Implementing Classes:
QQuery
public interface QueryHandle to a node in a S.O.D.A. query graph. NOTE: Soda queries silently ignore invalid specified fields, constraints etc.
A node in the query graph can represent a class or an attribute of a class.
The graph is automatically extended with attributes of added constraints (seeconstrain(Object)) and upon calls todescend(java.lang.String)that request nodes that do not yet exist.
References to joined nodes in the query graph can be obtained by "walking" along the nodes of the graph with the methoddescend(String).
execute()evaluates the entire graph against all persistent objects.
execute()can be called from anyQuerynode of the graph. It will return anObjectSetfilled with objects of the class/classes that the node, it was called from, represents.
Note:
ObjectContainer.query(Predicate)Native queries} are the recommended main query interface of db4o.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Constraintconstrain(java.lang.Object constraint)Adds a constraint to this node.Constraintsconstraints()Returns aConstraintsobject that holds an array of all constraints on this node.Querydescend(java.lang.String fieldName)Returns a reference to a descendant node in the query graph.<T> ObjectSet<T>execute()Executes theQuery.QueryorderAscending()Adds an ascending ordering criteria to this node of the query graph.QueryorderDescending()Adds a descending order criteria to this node of the query graph.QuerysortBy(QueryComparator<?> comparator)Sort the resulting ObjectSet by the given comparator.QuerysortBy(java.util.Comparator comparator)Sort the resulting ObjectSet by the given comparator.
-
-
-
Method Detail
-
constrain
Constraint constrain(java.lang.Object constraint)
Adds a constraint to this node.
If the constraint contains attributes that are not yet present in the query graph, the query graph is extended accordingly.
Special behaviour for:- class
Class: confine the result to objects of one class or to objects implementing an interface. -
Evaluation-instance: run evaluation callbacks against all candidates.
- Parameters:
constraint- the constraint to be added to this Query.- Returns:
- a new
Constraintfor this query node or null for objects implementing theEvaluationinterface.
- class
-
constraints
Constraints constraints()
Returns aConstraintsobject that holds an array of all constraints on this node.- Returns:
Constraintson this query node.
-
descend
Query descend(java.lang.String fieldName)
Returns a reference to a descendant node in the query graph.
If the node does not exist, it will be created.
All classes represented in the query node are tested, whether they contain a field with the specified field name. The descendant Query node will be created from all possible candidate classes.- Parameters:
fieldName- path to the descendant.- Returns:
- descendant
Querynode
-
orderAscending
Query orderAscending()
Adds an ascending ordering criteria to this node of the query graph.If multiple ordering criteria are applied, the chronological order of method calls is relevant: criteria created by 'earlier' calls are considered more significant, i.e. 'later' criteria only have an effect for elements that are considered equal by all 'earlier' criteria.
Ordering by non primitive fields works only for classes that implement the
Activatableinterface andTransparentActivationSupportis enabled.As an example, consider a type with two int fields, and an instance set {(a:1,b:3),(a:2,b:2),(a:1,b:2),(a:2,b:3)}. The call sequence [orderAscending(a), orderDescending(b)] will result in [(a:1,b:3),(a:1,b:2),(a:2,b:3),(a:2,b:2)].
- Returns:
- this
Queryobject to allow the chaining of method calls.
-
orderDescending
Query orderDescending()
Adds a descending order criteria to this node of the query graph.
For semantics of multiple calls setting ordering criteria, seeorderAscending().- Returns:
- this
Queryobject to allow the chaining of method calls.
-
sortBy
Query sortBy(QueryComparator<?> comparator)
Sort the resulting ObjectSet by the given comparator.- Parameters:
comparator- The comparator to apply.- Returns:
- this
Queryobject to allow the chaining of method calls.
-
-