diff options
author | James Moger <james.moger@gitblit.com> | 2014-10-22 21:55:32 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-10-22 22:29:05 -0400 |
commit | c7b36b245d619206dbac00873c8deb7c0681bbe4 (patch) | |
tree | c17a9dd6a40cee82cd183404f679691948ec99fe /src/site | |
parent | 1e4fc9cc867b925d82410f5ab3d5091987d60c4a (diff) | |
download | iciql-c7b36b245d619206dbac00873c8deb7c0681bbe4.tar.gz iciql-c7b36b245d619206dbac00873c8deb7c0681bbe4.zip |
Revise nested conditions implementation and api
Diffstat (limited to 'src/site')
-rw-r--r-- | src/site/usage.mkd | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/site/usage.mkd b/src/site/usage.mkd index 8b54dce..b09f91b 100644 --- a/src/site/usage.mkd +++ b/src/site/usage.mkd @@ -69,28 +69,36 @@ List<Product> allProducts = db.buildObjects(Product.class, rs); JdbcUtils.closeSilently(rs, true);
---JAVA---
-### Compound Conditions
+### Compound Nested Conditions
-It is possible to specify type-safe compound where clauses using nested `And` and `Or` statements.
+It is possible to specify type-safe compound nested conditions in your WHERE clauses using `And` and `Or` statements.
---JAVA---
final Customer model = new Customer();
+// SELECT * FROM CUSTOMERS
+// WHERE customerId IS NOT NULL
+// AND region IS NOT NULL
+// AND (
+// region = 'LA' OR region = 'CA'
+// )
List<Customer> regionals =
- db.from(model).where(model.customerId).isNotNull()
- .and(model.region).isNotNull()
- .and(new Or<Customer>(db, model) {{
- or(model.region).is("LA");
- or(model.region).is("CA");
- }});
+ db.from(model)
+ .where(model.customerId).isNotNull()
+ .and(model.region).isNotNull()
+ .and(new Or<Customer>(db, model) {{
+ or(model.region).is("LA");
+ or(model.region).is("CA");
+ }});
List<Customer> regionalType1s =
- db.from(model).where(new And<Customer>(db, model) {{
- and(model.type).is(1);
- and(new Or<Customer>(db, model) {{
- or(model.region).is("CA");
- or(model.region).is("LA");
- }});
+ db.from(model)
+ .where(new And<Customer>(db, model) {{
+ and(model.type).is(1);
+ and(new Or<Customer>(db, model) {{
+ or(model.region).is("CA");
+ or(model.region).is("LA");
+ }});
}});
---JAVA---
|