com.triactive.jdo.store.sql.expr
Class AlternativesExpression

java.lang.Object
  extended bycom.triactive.jdo.store.sql.expr.AbstractSqlExpression
      extended bycom.triactive.jdo.store.sql.expr.BooleanExpression
          extended bycom.triactive.jdo.store.sql.expr.AlternativesExpression
All Implemented Interfaces:
SqlExpression, StatementTextGenerator

public class AlternativesExpression
extends BooleanExpression

A series of two or more boolean expressions combined with OR. Used by BooleanExpression to OR together any pairs of subexpressions (except for literals), with the result being that this expression is aware of the entire chain of adjacent OR alternatives. The purpose is to possibly reorder the subexpressions such that those which share the same set of unprotected outer join references will be grouped together and have protectOuterJoins() called just once for each group.

In other words, given a JDOQL filter such as:

 "mother.firstName == n || father.firstName = n || mother.middleName == n || father.middleName == n"
 
assuming "mother." and "father." require outer joins, then we can reorder the alternative subexpressions before adding the "IS NOT NULL AND" to generate more compact SQL:
 MOTHER.PERSON_ID IS NOT NULL AND (MOTHER.FIRST_NAME = ? OR MOTHER.MIDDLE_NAME = ?) OR
 FATHER.PERSON_ID IS NOT NULL AND (FATHER.FIRST_NAME = ? OR FATHER.MIDDLE_NAME = ?)
 

Author:
Mike Martin

Nested Class Summary
 
Nested classes inherited from class com.triactive.jdo.store.sql.expr.AbstractSqlExpression
AbstractSqlExpression.Body, AbstractSqlExpression.CompoundExpression, AbstractSqlExpression.SimpleColumnReference, AbstractSqlExpression.SubqueryExpression
 
Field Summary
 
Fields inherited from class com.triactive.jdo.store.sql.expr.AbstractSqlExpression
body, qs
 
Constructor Summary
AlternativesExpression(BooleanExpression operand1, BooleanExpression operand2)
           
 
Methods inherited from class com.triactive.jdo.store.sql.expr.BooleanExpression
and, eor, eq, ior, not, noteq, protectOuterJoins, unprotectedOuterJoins, unprotectedOuterJoins
 
Methods inherited from class com.triactive.jdo.store.sql.expr.AbstractSqlExpression
accessField, add, callMethod, cast, com, div, getColumnMapping, getJavaType, getMapping, getQueryStatement, getReferencedColumns, gt, gteq, innermostQuery, innermostQuery, lt, lteq, mod, mul, neg, newBody, newBody, newBody, newBody, newBody, newBody, newResultExpression, newSubqueryBody, select, setMapping, sub, toStatementText, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlternativesExpression

public AlternativesExpression(BooleanExpression operand1,
                              BooleanExpression operand2)


Copyright © 2001-2007 The TJDO Project All Rights Reserved.