@@ -396,25 +396,35 @@ This method creates models or providers depending on which package is used:
396
396
Select statement support enables the creation of methods that execute a query allowing a user to specify a where clause,
397
397
join specifications, order by clauses, group by clauses, pagination clauses, etc.
398
398
399
- The DSL for select statements looks like this:
399
+ The full DSL for select statements looks like this:
400
400
401
401
``` kotlin
402
- val selectStatement = select(id, firstName, lastName, birthDate, employed, occupation, addressId) {
403
- from(person)
404
- where { id isLessThan 5 }
405
- and {
406
- id isLessThan 4
407
- and {
408
- id isLessThan 3
409
- or { id isLessThan 2 }
410
- }
402
+ val selectStatement = select(orderMaster.orderId, orderMaster.orderDate, orderDetail.lineNumber,
403
+ orderDetail.description, orderDetail.quantity
404
+ ) {
405
+ from(orderMaster, " om" )
406
+ join(orderDetail, " od" ) {
407
+ on(orderMaster.orderId) equalTo orderDetail.orderId
408
+ and (orderMaster.orderId) equalTo orderDetail.orderId
411
409
}
412
- orderBy(id)
410
+ where { orderMaster.orderId isEqualTo 1 }
411
+ or {
412
+ orderMaster.orderId isEqualTo 2
413
+ and { orderDetail.quantity isLessThan 6 }
414
+ }
415
+ orderBy(orderMaster.orderId)
413
416
limit(3 )
414
417
}
415
418
```
416
419
420
+ In a select statement you must specify a table in a ` from ` clause. Everything else is optional.
421
+
422
+ Multiple join clauses can be specified if you need to join additional tables. In a join clause, you must
423
+ specify an ` on ` condition, and you may specify additional ` and ` conditions as necessary. Full, left, right, inner,
424
+ and outer joins are supported.
425
+
417
426
Where clauses can be of arbitrary complexity and support all SQL operators including exists operators, subqueries, etc.
427
+ You can nest ` and ` , ` or ` , and ` not ` clauses as necessary in where clauses.
418
428
419
429
There is also a method that will create a "distinct" query (` select distinct ... ` ) as follows:
420
430
0 commit comments