Methods Summary |
---|
private boolean | addAnd(com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.Constraint foreignConstraint, int joinOp)Decides, if we need to add an additional "AND" constraint to
the stack after merging the foreign stack.
// Add "AND" constraints for equi-joins only.
// * Don't add an "AND" constraint for outer joins. Outer joins
// don't contribute to the "where"-clause in ANSI-case. In the
// non-ANSI case, outer joins can be appended to the query w/o
// changing the semantic.
// * Don't add an "AND" constaint for non-relationship joins,
// as no additional join constraint is added in this case.
return (joinOp == ActionDesc.OP_EQUIJOIN)
// Never add an "AND" constraint, if the foreign stack is
// empty or contains "ORDER_BY" constraints only, as "ORDER_BY"
// constraints don't contribute to the "where"-clause.
&& !foreignConstraint.isEmptyOrOrderBy();
|
public void | addConstraintFieldSubQuery(java.lang.String field, com.sun.jdo.spi.persistence.support.sqlstore.ActionDesc rd)Adds a subquery constraint on the stack.
stack.add(new ConstraintFieldNameSubQuery(field, rd));
|
public void | addField(java.lang.String name, com.sun.jdo.spi.persistence.support.sqlstore.ActionDesc desc)Adds a field to the constraint stack.
AddField creates a ConstraintField node for the indicated
named field, optionally including an operation descriptor
and adds it to the constraint stack.
stack.add(new ConstraintFieldName(name, desc));
|
public void | addField(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc desc)Adds a field to the constraint stack.
AddField creates a ConstraintFieldDesc node for the indicated
field descriptor and adds it to the constraint stack.
stack.add(new ConstraintFieldDesc(desc));
|
public void | addField(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc desc, com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.QueryPlan plan)Adds a field to the constraint stack.
AddField creates a ConstraintFieldDesc node for the indicated
field descriptor and adds it to the constraint stack.
stack.add(new ConstraintFieldDesc(desc, plan));
|
public void | addField(ConstraintFieldDesc constraintDesc)
stack.add(constraintDesc);
|
public void | addForeignField(java.lang.String name, com.sun.jdo.spi.persistence.support.sqlstore.ActionDesc desc)
stack.add(new ConstraintForeignFieldName(name, desc));
|
public void | addJoinConstraint(ConstraintJoin join)Adds specified join constraint. Equi joins are added to the
constraint stack, outer joins are added to a separate stack, the
outerJoinStack .
if (join.operation == ActionDesc.OP_EQUIJOIN) {
stack.add(join);
} else {
// The current logic is written with the assumption that a join
// that is not an equi join is always a left join
assert join.operation == ActionDesc.OP_LEFTJOIN;
outerJoinStack.add(join);
}
|
public void | addOperation(int operation)Adds an operation to the constraint stack.
AddOperation creates a ConstraintOperation node whose operation is
operation and adds it to the constraint stack.
stack.add(new ConstraintOperation(operation));
|
public void | addParamIndex(int index, int enumType, com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc localField)Adds the index of a parameter to the stack.
stack.add(new ConstraintParamIndex(index,enumType, localField));
|
public void | addValue(java.lang.Object value, com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc localField)Adds a data value to the constraint stack. Creates a ConstraintValue
node whose value is value and adds it to the constraint stack.
stack.add(new ConstraintValue(value, localField));
|
public java.util.List | getConstraints()Gets the where clause constraints for this Constraint
return stack;
|
public java.util.List | getOuterJoinConstraints()Gets the outer join constraints for this Constraint
return outerJoinStack;
|
private boolean | isEmptyOrOrderBy()Checks, if the constraint stack is empty or contains "ORDER_BY"
constraints only. "ORDER_BY" constraints are recognized as an
ORDER_BY operation followed by a field name constraint, and
an optional Value constraint giving the position of the Order
By constraint.
NOTE: The value constraints giving the position for
the order by constraints are currently not generated by the
query compiler. Order by constraints stay in the correct order
because of two reasons
- the way, constraints are processed by the query compiler
- the way constraint stacks are joined in
{@link com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.SelectQueryPlan#processForeignConstraints}.
boolean rc = true;
// Abort the loop at first possible opportunity.
for (int i = stack.size() - 1; i >= 0 && rc; ) {
ConstraintNode node = (ConstraintNode) stack.get(i);
if ((node instanceof ConstraintOperation)
&& ((((ConstraintOperation) node).operation == ActionDesc.OP_ORDERBY) ||
(((ConstraintOperation) node).operation == ActionDesc.OP_ORDERBY_DESC))) {
if ((i > 0) && (
stack.get(i - 1) instanceof ConstraintFieldName ||
stack.get(i - 1) instanceof ConstraintFieldDesc)) {
// Order By constraint.
i--;
if ((i > 0) && (stack.get(i - 1) instanceof ConstraintValue)) {
// Optional Value constraint.
i--;
}
} else {
rc = false;
}
} else {
rc = false;
}
// Check the next constraint if any.
i--;
}
return rc;
|
public boolean | mergeConstraint(com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.Constraint foreignConstraint, int joinOp)Merges the stack with the specified foreign constraint stack.
stack.addAll(foreignConstraint.stack);
outerJoinStack.addAll(foreignConstraint.outerJoinStack);
return addAnd(foreignConstraint, joinOp);
|