diff options
Diffstat (limited to 'src/site/usage.mkd')
-rw-r--r-- | src/site/usage.mkd | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/site/usage.mkd b/src/site/usage.mkd index b1f4c48..8b54dce 100644 --- a/src/site/usage.mkd +++ b/src/site/usage.mkd @@ -69,6 +69,44 @@ List<Product> allProducts = db.buildObjects(Product.class, rs); JdbcUtils.closeSilently(rs, true);
---JAVA---
+### Compound Conditions
+
+It is possible to specify type-safe compound where clauses using nested `And` and `Or` statements.
+
+---JAVA---
+final Customer model = new Customer();
+
+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");
+ }});
+
+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");
+ }});
+ }});
+
+---JAVA---
+
+### Finding Matches for a List of Values
+
+You can use SQL's *IN* WHERE clause with the `oneOf` or `noneOf` conditions.
+
+---JAVA---
+final Customer model = new Customer();
+
+List<Customer> regionals = db.from(model).where(model.region).oneOf("CA", "LA");
+List<Customer> others = db.from(model).where(model.region).noneOf("CA", "LA");
+
+---JAVA---
+
### Read-only Views
View model classes can inherit their field definitions from a parent table model class.
@@ -232,4 +270,4 @@ for (int i = 0; i < 5; i++) { ---JAVA---
</td></tr>
-</table>
\ No newline at end of file +</table>
|