summaryrefslogtreecommitdiffstats
path: root/docs/02_usage.mkd
diff options
context:
space:
mode:
Diffstat (limited to 'docs/02_usage.mkd')
-rw-r--r--docs/02_usage.mkd24
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/02_usage.mkd b/docs/02_usage.mkd
index 2659e86..fe4801b 100644
--- a/docs/02_usage.mkd
+++ b/docs/02_usage.mkd
@@ -65,6 +65,30 @@ List<Product> allProducts = db.buildObjects(Product.class, rs);
JdbcUtils.closeSilently(rs, true);
%ENDCODE%
+### Natural Syntax
+
+**work-in-progress**
+
+The original JaQu source offers partial support for Java expressions in *where* clauses.
+
+This works by decompiling a Java expression, at runtime, to an SQL condition. The expression is written as an anonymous inner class implementation of the `com.iciql.Filter` interface.
+A proof-of-concept decompiler is included, but is incomplete.
+
+The proposed syntax is:
+%BEGINCODE%
+long count = db.from(co).
+ where(new Filter() { public boolean where() {
+ return co.id == x
+ && co.name.equals(name)
+ && co.value == new BigDecimal("1")
+ && co.amount == 1L
+ && co.birthday.before(new java.util.Date())
+ && co.created.before(java.sql.Timestamp.valueOf("2005-05-05 05:05:05"))
+ && co.time.before(java.sql.Time.valueOf("23:23:23"));
+ }
+ }).selectCount();
+%ENDCODE%
+
### JDBC Statements, ResultSets, and Exception Handling
Iciql opens and closes all JDBC objects automatically. SQLExceptions thrown during execution of a statement (except for *close()* calls), will be caught, wrapped, and rethrown as an `IciqlException`, which is a RuntimeException.