javatools.db
Class DbTrueExpr
java.lang.Object
|
+--javatools.db.DbExpr
|
+--javatools.db.DbCriterion
|
+--javatools.db.DbTrueExpr
- 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 = ? )
- See Also:
DbAndExpr
Fields inherited from class javatools.db.DbExpr |
db |
Methods inherited from class javatools.db.DbExpr |
and, dateTrunc, equal, getString, greaterThan, greaterThanOrEqual, in, isNotNull, isNull, lessThan, lessThanOrEqual, like, lower, max, min, notEqual, notIn, or, setSqlValue, upper, usesTables |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DbTrueExpr
public DbTrueExpr(DbDatabase db)