@@ -196,14 +196,15 @@ Single record insert statements can be constructed and executed in a single step
196
196
``` kotlin
197
197
val row = PersonRecord (100 , " Joe" , " Jones" , Date (), true , " Developer" , 1 )
198
198
199
- val rows = template.insert(row).into(Person ) {
200
- map(id).toProperty(" id" )
201
- map(firstName).toProperty(" firstName" )
202
- map(lastName).toProperty(" lastName" )
203
- map(birthDate).toProperty(" birthDate" )
204
- map(employed).toProperty(" employedAsString" )
199
+ val rows = template.insert(row) {
200
+ into(Person )
201
+ map(id) toProperty " id"
202
+ map(firstName) toProperty " firstName"
203
+ map(lastName) toProperty " lastName"
204
+ map(birthDate) toProperty " birthDate"
205
+ map(employed) toProperty " employedAsString"
205
206
map(occupation).toPropertyWhenPresent(" occupation" , row::occupation)
206
- map(addressId). toProperty( " addressId" )
207
+ map(addressId) toProperty " addressId"
207
208
}
208
209
```
209
210
@@ -217,14 +218,15 @@ val keyHolder = GeneratedKeyHolder()
217
218
val row = PersonRecord (100 , " Joe" , " Jones" , Date (), true , " Developer" , 1 )
218
219
219
220
val rows = template.withKeyHolder(keyHolder) {
220
- insert(row).into(Person ) {
221
- map(id).toProperty(" id" )
222
- map(firstName).toProperty(" firstName" )
223
- map(lastName).toProperty(" lastName" )
224
- map(birthDate).toProperty(" birthDate" )
225
- map(employed).toProperty(" employedAsString" )
221
+ insert(row) {
222
+ into(Person )
223
+ map(id) toProperty" id"
224
+ map(firstName) toProperty " firstName"
225
+ map(lastName) toProperty " lastName"
226
+ map(birthDate) toProperty " birthDate"
227
+ map(employed) toProperty " employedAsString"
226
228
map(occupation).toPropertyWhenPresent(" occupation" , row::occupation)
227
- map(addressId). toProperty( " addressId" )
229
+ map(addressId) toProperty " addressId"
228
230
}
229
231
}
230
232
```
@@ -255,13 +257,13 @@ General insert statements can be constructed and executed in a single step with
255
257
val myOccupation = " Developer"
256
258
257
259
val rows = template.insertInto(Person ) {
258
- set(id). toValue( 100 )
259
- set(firstName). toValue( " Joe" )
260
- set(lastName). toValue( " Jones" )
261
- set(birthDate). toValue( Date () )
262
- set(employed). toValue( true )
263
- set(occupation). toValueWhenPresent( myOccupation)
264
- set(addressId). toValue( 1 )
260
+ set(id) toValue 100
261
+ set(firstName) toValue " Joe"
262
+ set(lastName) toValue " Jones"
263
+ set(birthDate) toValue Date ()
264
+ set(employed) toValue true
265
+ set(occupation) toValueWhenPresent myOccupation
266
+ set(addressId) toValue 1
265
267
}
266
268
```
267
269
@@ -276,13 +278,13 @@ val myOccupation = "Developer"
276
278
277
279
val rows = template.withKeyHolder(keyHolder) {
278
280
insertInto(Person ) {
279
- set(id). toValue( 100 )
280
- set(firstName). toValue( " Joe" )
281
- set(lastName). toValue( " Jones" )
282
- set(birthDate). toValue( Date () )
283
- set(employed). toValue( true )
284
- set(occupation). toValueWhenPresent( myOccupation)
285
- set(addressId). toValue( 1 )
281
+ set(id) toValue 100
282
+ set(firstName) toValue " Joe"
283
+ set(lastName) toValue " Jones"
284
+ set(birthDate) toValue Date ()
285
+ set(employed) toValue true
286
+ set(occupation) toValueWhenPresent myOccupation
287
+ set(addressId) toValue 1
286
288
}
287
289
}
288
290
```
@@ -313,14 +315,15 @@ Multi-Row insert statements can be constructed and executed in a single step wit
313
315
val record1 = PersonRecord (100 , " Joe" , LastName (" Jones" ), Date (), true , " Developer" , 1 )
314
316
val record2 = PersonRecord (101 , " Sarah" , LastName (" Smith" ), Date (), true , " Architect" , 2 )
315
317
316
- val rows = template.insertMultiple(record1, record2).into(Person ) {
317
- map(id).toProperty(" id" )
318
- map(firstName).toProperty(" firstName" )
319
- map(lastName).toProperty(" lastNameAsString" )
320
- map(birthDate).toProperty(" birthDate" )
321
- map(employed).toProperty(" employedAsString" )
322
- map(occupation).toProperty(" occupation" )
323
- map(addressId).toProperty(" addressId" )
318
+ val rows = template.insertMultiple(record1, record2) {
319
+ into(Person )
320
+ map(id) toProperty " id"
321
+ map(firstName) toProperty " firstName"
322
+ map(lastName) toProperty " lastNameAsString"
323
+ map(birthDate) toProperty " birthDate"
324
+ map(employed) toProperty " employedAsString"
325
+ map(occupation) toProperty " occupation"
326
+ map(addressId) toProperty " addressId"
324
327
}
325
328
```
326
329
@@ -332,14 +335,15 @@ val record1 = PersonRecord(100, "Joe", LastName("Jones"), Date(), true, "Develop
332
335
val record2 = PersonRecord (101 , " Sarah" , LastName (" Smith" ), Date (), true , " Architect" , 2 )
333
336
334
337
val rows = template.withKeyHolder(keyHolder) {
335
- insertMultiple(record1, record2).into(Person ) {
336
- map(id).toProperty(" id" )
337
- map(firstName).toProperty(" firstName" )
338
- map(lastName).toProperty(" lastNameAsString" )
339
- map(birthDate).toProperty(" birthDate" )
340
- map(employed).toProperty(" employedAsString" )
341
- map(occupation).toProperty(" occupation" )
342
- map(addressId).toProperty(" addressId" )
338
+ insertMultiple(record1, record2) {
339
+ into(Person )
340
+ map(id) toProperty " id"
341
+ map(firstName) toProperty " firstName"
342
+ map(lastName) toProperty " lastNameAsString"
343
+ map(birthDate) toProperty " birthDate"
344
+ map(employed) toProperty " employedAsString"
345
+ map(occupation) toProperty " occupation"
346
+ map(addressId) toProperty " addressId"
343
347
}
344
348
}
345
349
```
@@ -365,14 +369,15 @@ Batch statements can be constructed and executed in a single step with code like
365
369
val record1 = PersonRecord (100 , " Joe" , LastName (" Jones" ), Date (), true , " Developer" , 1 )
366
370
val record2 = PersonRecord (101 , " Sarah" , LastName (" Smith" ), Date (), true , " Architect" , 2 )
367
371
368
- val rows = template.insertBatch(record1, record2).into(Person ) {
369
- map(id).toProperty(" id" )
370
- map(firstName).toProperty(" firstName" )
371
- map(lastName).toProperty(" lastNameAsString" )
372
- map(birthDate).toProperty(" birthDate" )
373
- map(employed).toProperty(" employedAsString" )
374
- map(occupation).toProperty(" occupation" )
375
- map(addressId).toProperty(" addressId" )
372
+ val rows = template.insertBatch(record1, record2) {
373
+ into(Person )
374
+ map(id) toProperty " id"
375
+ map(firstName) toProperty " firstName"
376
+ map(lastName) toProperty " lastNameAsString"
377
+ map(birthDate) toProperty " birthDate"
378
+ map(employed) toProperty " employedAsString"
379
+ map(occupation) toProperty " occupation"
380
+ map(addressId) toProperty " addressId"
376
381
}
377
382
```
378
383
0 commit comments