In my spring-boot 2.3 application, I have a simple data method using DatabaseClient
:
fun getCurrentTime(): Mono<LocalDateTime> =
databaseClient
.execute("SELECT NOW()")
.asType<LocalDateTime>()
.fetch()
.first()
}
With spring-boot 2.4 (and spring 5.3 and spring-data-r2dbc 1.2), org.springframework.data.r2dbc.core.DatabaseClient
from spring-data-r2dbc is deprecated in favor of org.springframework.r2dbc.core.DatabaseClient
of spring-r2dbc - which has a different API.
Adapting that is pretty much straightforward - with the exception of the kotlin extension asType
, which is not a part of the new DatabaseClientExtensions.
fun getCurrentTime(): Mono<LocalDateTime> =
databaseClient
.sql("SELECT NOW()")
.map { row: Row ->
row.get(0, LocalDateTime::class.java)!!
}
.one()
Are those extensions somewhere else or how can I convert using a reified type parameter?