Hello!
I started learning Kotlin and found this page (Kotlin tour).
It’s perfect tour (I guess so)!
But I found a couple mistakes and decide to inform you.
- Page Add database support for Spring Boot project | Kotlin Documentation
This block contains the mistake in parameters sequence:
presented code
fun findMessageById(id: String): List<Message> = db.query("select * from messages where id = ?", id) { response, _ ->
Message(response.getString("id"), response.getString("text"))
}
need replace to
fun findMessageById(id: String) : List<Message> = db.query("select * from messages where id = ?", { response, _ ->
Message(response.getString("id"), response.getString("text"))
}, id)
- Page Use Spring Data CrudRepository for database access | Kotlin Documentation
2.1. after changing approach persisting data to DB from ‘Spring JDBC’ to ‘Spring Data’ and change sql-script by creating table, necessary drop exists table (messages) to create new table from sql-script, otherwise you get corresponding message and service doesn’t start.
Or need to change application.property ‘spring.sql.init.mode=always’ to more suitable (drop/create)
2.2. Need to add @Id annotation to class Message:
data class Message(@Id val id: String?, val text: String)
Please correct it.