@@ -196,14 +196,15 @@ Single record insert statements can be constructed and executed in a single step
196196``` kotlin
197197val row = PersonRecord (100 , " Joe" , " Jones" , Date (), true , " Developer" , 1 )
198198
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"
205206 map(occupation).toPropertyWhenPresent(" occupation" , row::occupation)
206- map(addressId). toProperty( " addressId" )
207+ map(addressId) toProperty " addressId"
207208}
208209```
209210
@@ -217,14 +218,15 @@ val keyHolder = GeneratedKeyHolder()
217218val row = PersonRecord (100 , " Joe" , " Jones" , Date (), true , " Developer" , 1 )
218219
219220val 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"
226228 map(occupation).toPropertyWhenPresent(" occupation" , row::occupation)
227- map(addressId). toProperty( " addressId" )
229+ map(addressId) toProperty " addressId"
228230 }
229231}
230232```
@@ -255,13 +257,13 @@ General insert statements can be constructed and executed in a single step with
255257val myOccupation = " Developer"
256258
257259val 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
265267}
266268```
267269
@@ -276,13 +278,13 @@ val myOccupation = "Developer"
276278
277279val rows = template.withKeyHolder(keyHolder) {
278280 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
286288 }
287289}
288290```
@@ -313,14 +315,15 @@ Multi-Row insert statements can be constructed and executed in a single step wit
313315val record1 = PersonRecord (100 , " Joe" , LastName (" Jones" ), Date (), true , " Developer" , 1 )
314316val record2 = PersonRecord (101 , " Sarah" , LastName (" Smith" ), Date (), true , " Architect" , 2 )
315317
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"
324327}
325328```
326329
@@ -332,14 +335,15 @@ val record1 = PersonRecord(100, "Joe", LastName("Jones"), Date(), true, "Develop
332335val record2 = PersonRecord (101 , " Sarah" , LastName (" Smith" ), Date (), true , " Architect" , 2 )
333336
334337val 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"
343347 }
344348}
345349```
@@ -365,14 +369,15 @@ Batch statements can be constructed and executed in a single step with code like
365369val record1 = PersonRecord (100 , " Joe" , LastName (" Jones" ), Date (), true , " Developer" , 1 )
366370val record2 = PersonRecord (101 , " Sarah" , LastName (" Smith" ), Date (), true , " Architect" , 2 )
367371
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"
376381}
377382```
378383
0 commit comments