Skip to content

Commit 14f5032

Browse files
committed
Update Kotlin example
See gh-gh-24398
1 parent 17140c8 commit 14f5032

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/docs/asciidoc/data-access.adoc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,16 +2793,12 @@ For example, it may be better to write the preceding code snippet as follows:
27932793
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
27942794
.Kotlin
27952795
----
2796-
fun findAllActors(): List<Actor> {
2797-
return jdbcTemplate.query("select first_name, last_name from t_actor", ActorMapper())
2796+
val actorMapper = RowMapper<Actor> { rs: ResultSet, rowNum: Int ->
2797+
return Actor(rs.getString("first_name"), rs.getString("last_name"))
27982798
}
27992799
2800-
class ActorMapper : RowMapper<Actor> {
2801-
2802-
override fun mapRow(rs: ResultSet, rowNum: Int) = Actor(
2803-
rs.getString("first_name"),
2804-
rs.getString("last_name"))
2805-
}
2800+
fun findAllActors(): List<Actor> {
2801+
return jdbcTemplate.query("select first_name, last_name from t_actor", actorMapper)
28062802
}
28072803
----
28082804

0 commit comments

Comments
 (0)