parent
17140c8d4b
commit
14f5032e97
|
@ -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"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
.Kotlin
|
.Kotlin
|
||||||
----
|
----
|
||||||
|
val actorMapper = RowMapper<Actor> { rs: ResultSet, rowNum: Int ->
|
||||||
|
return Actor(rs.getString("first_name"), rs.getString("last_name"))
|
||||||
|
}
|
||||||
|
|
||||||
fun findAllActors(): List<Actor> {
|
fun findAllActors(): List<Actor> {
|
||||||
return jdbcTemplate.query("select first_name, last_name from t_actor", ActorMapper())
|
return jdbcTemplate.query("select first_name, last_name from t_actor", actorMapper)
|
||||||
}
|
|
||||||
|
|
||||||
class ActorMapper : RowMapper<Actor> {
|
|
||||||
|
|
||||||
override fun mapRow(rs: ResultSet, rowNum: Int) = Actor(
|
|
||||||
rs.getString("first_name"),
|
|
||||||
rs.getString("last_name"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue