Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javatools.db
Class DbTrueExpr  view DbTrueExpr download DbTrueExpr.java

java.lang.Object
  extended byjavatools.db.DbExpr
      extended byjavatools.db.DbCriterion
          extended byjavatools.db.DbTrueExpr
All Implemented Interfaces:
DbTableUser

public class DbTrueExpr
extends DbCriterion

An expression that always evaluates to true. If not optimised away but DbAndExpr, this will probably result in "0 = 0" in the SQL.

The use of true expressions makes it very convenient for dynamically generated queries...

 DbExpr e = db.trueExpr();
 if (name != null) {
  e = e.and(table.getColumn("NAME")).equals(name));
 }
 if (age != null) {
   e = e.and(table.getColumn("AGE")).equals(age));
 }
 
This gets converted to...
 (0 = 0) AND ( NAME = ? ) AND ( AGE = ? )
 
and then DbAndExpr optimises this to...
 ( NAME = ? ) AND ( AGE = ? )
 

Version:
0.7

Field Summary
 
Fields inherited from class javatools.db.DbCriterion
c1, c2, op
 
Fields inherited from class javatools.db.DbExpr
db
 
Constructor Summary
DbTrueExpr(DbDatabase db)
          Creates a new DbTrueExpr expression.
 
Methods inherited from class javatools.db.DbCriterion
getQueryString, setSqlValues, usesTables
 
Methods inherited from class javatools.db.DbExpr
and, containsAllStrings, containsAllStrings, count, dateTrunc, equal, getString, greaterThan, greaterThanOrEqual, in, in, isNotNull, isNull, lessThan, lessThanOrEqual, like, lower, max, min, notEqual, notIn, notIn, or, setSqlValue, upper, usesTables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbTrueExpr

public DbTrueExpr(DbDatabase db)
Creates a new DbTrueExpr expression.