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

java.lang.Object
  extended bycom.triactive.jdo.store.sql.expr.AbstractSqlExpression
      extended bycom.triactive.jdo.store.sql.expr.BooleanExpression
All Implemented Interfaces:
SqlExpression, StatementTextGenerator
Direct Known Subclasses:
AlternativesExpression, BooleanLiteral, com.triactive.jdo.store.sql.expr.ComparisonExpression

public class BooleanExpression
extends AbstractSqlExpression


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
BooleanExpression(AbstractSqlExpression.Body body)
           
BooleanExpression(QueryStatement.QueryColumn qsc)
           
 
Method Summary
 BooleanExpression and(SqlExpression expr)
          Returns a new expression representing "this && expr".
 BooleanExpression eor(SqlExpression expr)
          Returns a new expression representing "this ^ expr".
 BooleanExpression eq(SqlExpression expr)
          Returns a new expression representing "this == expr".
 BooleanExpression ior(SqlExpression expr)
          Returns a new expression representing "this || expr".
 BooleanExpression not()
          Returns a new expression representing "!this".
 BooleanExpression noteq(SqlExpression expr)
          Returns a new expression representing "this != expr".
protected  BooleanExpression protectOuterJoins()
          Ensures that all columns referenced within this expression have been "protected" against exposure to OUTER JOIN-injected NULLs.
protected  java.util.Set unprotectedOuterJoins()
          Returns the set of unprotected outer join columns for this expression.
protected  java.util.Set unprotectedOuterJoins(QueryStatement targetQs)
          Returns the set of unprotected outer join columns for this expression.
 
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

BooleanExpression

public BooleanExpression(AbstractSqlExpression.Body body)

BooleanExpression

public BooleanExpression(QueryStatement.QueryColumn qsc)
Method Detail

and

public BooleanExpression and(SqlExpression expr)
Description copied from interface: SqlExpression
Returns a new expression representing "this && expr".

Specified by:
and in interface SqlExpression
Overrides:
and in class AbstractSqlExpression

eor

public BooleanExpression eor(SqlExpression expr)
Description copied from interface: SqlExpression
Returns a new expression representing "this ^ expr".

Specified by:
eor in interface SqlExpression
Overrides:
eor in class AbstractSqlExpression

ior

public BooleanExpression ior(SqlExpression expr)
Description copied from interface: SqlExpression
Returns a new expression representing "this || expr".

Specified by:
ior in interface SqlExpression
Overrides:
ior in class AbstractSqlExpression

not

public BooleanExpression not()
Description copied from interface: SqlExpression
Returns a new expression representing "!this".

Specified by:
not in interface SqlExpression
Overrides:
not in class AbstractSqlExpression

eq

public BooleanExpression eq(SqlExpression expr)
Description copied from interface: SqlExpression
Returns a new expression representing "this == expr".

Specified by:
eq in interface SqlExpression
Overrides:
eq in class AbstractSqlExpression

noteq

public BooleanExpression noteq(SqlExpression expr)
Description copied from interface: SqlExpression
Returns a new expression representing "this != expr".

Specified by:
noteq in interface SqlExpression
Overrides:
noteq in class AbstractSqlExpression

unprotectedOuterJoins

protected final java.util.Set unprotectedOuterJoins()
Returns the set of unprotected outer join columns for this expression. Equivalent to calling:
 unprotectedOuterJoins(qs)
 
and passing this.qs as the query statement.

Returns:
A set of QueryStatement.QueryColumn objects.
See Also:
unprotectedOuterJoins(QueryStatement)

unprotectedOuterJoins

protected java.util.Set unprotectedOuterJoins(QueryStatement targetQs)
Returns the set of unprotected outer join columns for this expression.

"Unprotected" means that the expression has not yet been modified to test that the relevant outer join columns are not NULL.

The set of columns to be protected is defined by first considering all columns referenced within the expression. Of those, any whose table expressions participated in an outer join might include rows with NULL values due to the outer join. We "protect" such references, i.e. ensure they are only exposed to actual stored data and not rows with OUTER JOIN-injected NULLs, by testing that all the columns on which the relevant table expressions were outer joined are NOT NULL.

In other words, given an expression such as:

 MOTHER.FIRST_NAME = ? AND FATHER.FIRST_NAME = ?
 
and assuming that the table expressions for MOTHER and FATHER were outer-joined on PERSON_ID, we say that the columns:
 MOTHER.PERSON_ID
 FATHER.PERSON_ID
 
are unprotected outer join columns for this expression. This example would be protected by modifying it to:
 MOTHER.PERSON_ID IS NOT NULL AND
 FATHER.PERSON_ID IS NOT NULL AND
 MOTHER.FIRST_NAME = ? AND FATHER.FIRST_NAME = ?
 
Strictly speaking this approach protects more column references than it needs to. For example, comparing FIRST_NAME to a string literal yields false anyway if FIRST_NAME is a NULL. But it's a simpler model to implement.

Parameters:
targetQs - Consider only references to columns in this statement.
Returns:
A set of QueryStatement.QueryColumn objects.
See Also:
protectOuterJoins()

protectOuterJoins

protected BooleanExpression protectOuterJoins()
Ensures that all columns referenced within this expression have been "protected" against exposure to OUTER JOIN-injected NULLs. If necessary, we AND this expression with another that tests that each unprotected outer join column IS NOT NULL.

This is called at least:

Returns:
The modified expression, or this if no outer join protection was needed.
See Also:
unprotectedOuterJoins(QueryStatement), AlternativesExpression


Copyright 2001-2007 The TJDO Project All Rights Reserved.