Update Kotlin example

See gh-gh-24398
This commit is contained in:
Sam Brannen 2020-03-17 19:22:26 +01:00
parent 17140c8d4b
commit 14f5032e97
1 changed files with 4 additions and 8 deletions

View File

@ -2793,16 +2793,12 @@ For example, it may be better to write the preceding code snippet as follows:
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
fun findAllActors(): List<Actor> {
return jdbcTemplate.query("select first_name, last_name from t_actor", ActorMapper())
val actorMapper = RowMapper<Actor> { rs: ResultSet, rowNum: Int ->
return Actor(rs.getString("first_name"), rs.getString("last_name"))
}
class ActorMapper : RowMapper<Actor> {
override fun mapRow(rs: ResultSet, rowNum: Int) = Actor(
rs.getString("first_name"),
rs.getString("last_name"))
}
fun findAllActors(): List<Actor> {
return jdbcTemplate.query("select first_name, last_name from t_actor", actorMapper)
}
----