Skip to content

Commit 4cec2a8

Browse files
committed
Doc Updates
1 parent a772eb4 commit 4cec2a8

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

src/site/markdown/docs/kotlinMyBatis3.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ val rows = mapper.count {
113113
}
114114
```
115115

116-
There is also an extension method that can be used to count all rows in a table:
116+
There is also a method that can be used to count all rows in a table:
117117

118118
```kotlin
119119
val rows = mapper.count { allRows() }
@@ -385,11 +385,12 @@ val rows = mapper.update {
385385
```
386386
## Join Support
387387

388-
There are extension functions that support building a reusable select method based on a join. In this way, you can create the start of the select statement (the column list and join specifications) and allow the user to supply where clauses and other parts of a select statement. For example, you could code a mapper extension method like this:
388+
There are functions that support building a reusable select method based on a join. In this way, you can create the start of the select statement (the column list and join specifications) and allow the user to supply where clauses and other parts of a select statement. For example, you could code a mapper extension method like this:
389389

390390
```kotlin
391391
fun PersonWithAddressMapper.select(completer: SelectCompleter): List<PersonWithAddress> {
392-
val start = select(columnList).from(Person, "p") {
392+
val start = select(columnList) {
393+
from(Person, "p")
393394
join(Address, "a") {
394395
on(Person.addressId, equalTo(Address.id))
395396
}

src/site/markdown/docs/kotlinSpring.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,16 @@ The DSL for count methods looks like this:
7373
}
7474

7575
// count(column)
76-
val countStatement = countColumn(lastName).from(Person) { // countStatement is a SelectStatementProvider
77-
allRows()
76+
val countStatement = count(lastName) { // countStatement is a SelectStatementProvider
77+
from(Person)
7878
}
7979

8080
// count(distinct column)
81-
val countStatement = countDistinctColumn(lastName).from(Person) { // countStatement is a SelectStatementProvider
82-
allRows()
81+
val countStatement = countDistinct(lastName) { // countStatement is a SelectStatementProvider
82+
from(Person)
8383
}
8484
```
8585

86-
Note the somewhat awkward method names `countColumn`, and `countDistinctColumn`. The methods are named this way to avoid a name collision with other methods in the `SqlBuilder`. This awkwardness can be avoided by using the one-step method shown below.
87-
8886
These methods create a `SelectStatementProvider` that can be executed with an extension method for `NamedParameterJdbcTemplate` like this:
8987

9088
```kotlin
@@ -99,16 +97,18 @@ This is the two-step execution process. This can be combined into a single step
9997
where(id, isLessThan(4))
10098
}
10199

102-
val rows = template.count(lastName).from(Person) {
100+
val rows = template.count(lastName) {
101+
from(Person)
103102
where(id, isLessThan(4))
104103
}
105104

106-
val rows = template.countDistinct(lastName).from(Person) {
105+
val rows = template.countDistinct(lastName) {
106+
from(Person)
107107
where(id, isLessThan(4))
108108
}
109109
```
110110

111-
There is also an extension method that can be used to count all rows in a table:
111+
There is also a method that can be used to count all rows in a table:
112112

113113
```kotlin
114114
val rows = template.countFrom(Person) {
@@ -143,7 +143,7 @@ This is the two-step execution process. This can be combined into a single step
143143
}
144144
```
145145

146-
There is also an extension method that can be used to count all rows in a table:
146+
There is also a method that can be used to count all rows in a table:
147147

148148
```kotlin
149149
val rows = template.deleteFrom(Person) {
@@ -404,7 +404,8 @@ The DSL for select methods looks like this:
404404

405405
```kotlin
406406
val selectStatement = select(id, firstName, lastName, birthDate, employed, occupation, // selectStatement is a SelectStatementProvider
407-
addressId).from(Person) {
407+
addressId) {
408+
from(Person)
408409
where(id, isLessThan(5))
409410
and(id, isLessThan(4)) {
410411
and(id, isLessThan(3)) {
@@ -437,8 +438,8 @@ Note that you must provide a row mapper to tell Spring JDBC how to create result
437438
This is the two-step execution process. This can be combined into a single step with code like the following:
438439

439440
```kotlin
440-
val rows = template.select(id, firstName, lastName, birthDate, employed, occupation, addressId)
441-
.from(Person) {
441+
val rows = template.select(id, firstName, lastName, birthDate, employed, occupation, addressId) {
442+
from(Person)
442443
where(id, isLessThan(4)) {
443444
and(occupation, isNotNull())
444445
}
@@ -461,8 +462,8 @@ This is the two-step execution process. This can be combined into a single step
461462
There are similar methods for selecting a single row, or executing a select distinct query. For example, you could implement a "select by primary key" method using code like this:
462463

463464
```kotlin
464-
val record = template.selectOne(id, firstName, lastName, birthDate, employed, occupation, addressId)
465-
.from(Person) {
465+
val record = template.selectOne(id, firstName, lastName, birthDate, employed, occupation, addressId) {
466+
from(Person)
466467
where(id, isEqualTo(key))
467468
}.withRowMapper { rs, _ ->
468469
PersonRecord().apply {
@@ -479,12 +480,12 @@ There are similar methods for selecting a single row, or executing a select dist
479480

480481
In this case, the data type for `record` would be `PersonRecord?` - a nullable value.
481482

482-
There is also an extension method that can be used to select all rows in a table:
483+
There is also an optional method that can be used to select all rows in a table:
483484

484485
```kotlin
485-
val rows = template.select(id, firstName, lastName, birthDate, employed, occupation, addressId)
486-
.from(Person) {
487-
allRows()
486+
val rows = template.select(id, firstName, lastName, birthDate, employed, occupation, addressId) {
487+
from(Person)
488+
allRows() // allRows() is optional - the query works the same with or without it
488489
orderBy(id)
489490
}.withRowMapper { rs, _ ->
490491
PersonRecord().apply {

0 commit comments

Comments
 (0)