|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.Query
public abstract class Query
Describes a simple query to retrieve objects from a
database.
This class provides a small subset of the functionality of SQL that is
required to gain access to objects based on certain selection criteria.
All queries return references to instances of Record.
| Field Summary | |
|---|---|
static boolean |
ASCENDING
|
static boolean |
DESCENDING
|
| Method Summary | |
|---|---|
void |
addArguments(java.lang.Object[] arguments)
Adds the arguments for a SELECT expression. |
void |
addConj(Condition pred)
Adds the Condition to the list of boolean expressions, that are
AND'ed together to form the WHERE part of the
statement. |
int |
addJoin(int baseColumn,
Column refColumn,
boolean pullInFields)
Add an equi-join on the table referenced by the reference in refColumn. |
void |
addOrderBy(int baseColumn,
Column designator)
|
void |
addOrderBy(int baseColumn,
Column[] designator,
boolean ascending)
|
void |
addOrderBy(int baseColumn,
Column designator,
boolean ascending)
|
void |
addOrderBy(Member designator,
boolean ascending)
|
void |
addTableExpr(java.lang.Class<? extends Record> tableClass,
boolean pullInFields)
Adds a new table expression to the query. |
void |
addTableExpr(TableExpr te,
boolean pullInFields)
Adds a new table expression to the query. |
abstract int |
count()
Returns the number of rows which will be returned by the query. |
abstract EvalContext |
evaluate(boolean forCount)
Evaluates this query. |
Record[][] |
execute()
Executes this query and returns the result. |
abstract PObjResultSet |
executeResultSet()
Executes this query and returns the result set for row-by-row processing. |
Container |
getContainer()
|
int |
getNumTableExprs()
|
TableExpr |
getTableExpr(int n)
Returns the table expression at index n of this query. |
boolean |
isDistinct()
Returns whether this query will filter out duplicates. |
boolean |
isOrdered()
|
void |
pullInReference(Member designator)
As part of the query, retrieve the complete data of all objects referenced by designator. |
void |
setDistinct(boolean distinct)
Sets whether this query should filter out duplicates. |
void |
setLimit(int aOffset,
int aLimit)
Limits the result of this query. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean ASCENDING
public static final boolean DESCENDING
| Method Detail |
|---|
public final Container getContainer()
public final void addTableExpr(TableExpr te,
boolean pullInFields)
te - the table expression to add.pullInFields - if true all fields of the table will be
read, else just the IdField to make a transient
object. This parameter will be ignored for
SELECT expressions.addTableExprFct(TableExpr,boolean)
public final void addTableExpr(java.lang.Class<? extends Record> tableClass,
boolean pullInFields)
tableClass - the class of the table expression to add.pullInFields - if true all fields of the table will be
read, else just the IdField to make a transient
object. This parameter will be ignored for
SELECT expressions.addTableExprFct(TableExpr,boolean)public final TableExpr getTableExpr(int n)
n of this query.
java.lang.ArrayIndexOutOfBoundsException - if no such table expression existspublic final int getNumTableExprs()
public final boolean isDistinct()
There are some limitations with this feature, which are described under
setDistinct(boolean).
public void setDistinct(boolean distinct)
Even if the query is marked as distinct can it still return duplicates,
due to the nature of created query and how DISTINCT works in
SQL. To get a real distinct result the following things
have to be met:
pullInFields of the
addTableExpr methods must be false for every
table. Note that for SelectExpr and ViewDecl this
parameter is always true, so that the distinctness
depends on the distinctness of these expressions.
pullInReference(Member) has not to be used.
addTableExpr(Class, boolean),
addTableExpr(TableExpr, boolean),
pullInReference(Member)public final void addArguments(java.lang.Object[] arguments)
SELECT expression.
public final void setLimit(int aOffset,
int aLimit)
public void addConj(Condition pred)
Condition to the list of boolean expressions, that are
AND'ed together to form the WHERE part of the
statement.
java.lang.IllegalArgumentException - if pred is null.EvalContext.addWhereConj(de.mguennewig.pobjects.Term)
public final void addOrderBy(int baseColumn,
Column designator)
public final void addOrderBy(int baseColumn,
Column designator,
boolean ascending)
public final void addOrderBy(int baseColumn,
Column[] designator,
boolean ascending)
public void addOrderBy(Member designator,
boolean ascending)
java.lang.IllegalArgumentException - if no designator is given, or the
designator refers to an unknown table expression.ASCENDING,
DESCENDINGpublic final boolean isOrdered()
public void pullInReference(Member designator)
designator.
This makes sure that the data of the referenced objects is internalized during the request, preventing individual database lookups for them later on.
Pre-condition:The attribute identified by
designator is of type ReferenceToClass.
designator must have a selector. The referring field must
be pulled in.
java.lang.IllegalArgumentException - if the designator does not met a
pre-conditions.
java.lang.IllegalStateException - if the reference to pull is from a table
whose fields are not pulled in.addTableExpr(Class,boolean),
addTableExpr(TableExpr,boolean)
public int addJoin(int baseColumn,
Column refColumn,
boolean pullInFields)
refColumn.
Result is the column index of the new entry in the query's list of result columns.
Pre-condition: The type of refColumn is
ReferenceToClass.
public abstract EvalContext evaluate(boolean forCount)
public Record[][] execute()
result = new Record[][] {
new Table_1[] { table_1[row_0], table_1[row_1], ... },
new Table_2[] { table_2[row_0], table_2[row_1], ... },
...
};
PObjReadError - if any database error occurs.executeResultSet()public abstract PObjResultSet executeResultSet()
PObjReadError - if any database error occurs.execute()public abstract int count()
PObjReadError
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||