Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 998 Bytes

File metadata and controls

28 lines (20 loc) · 998 Bytes

Kotlin

This part of the reference documentation explains the specific Kotlin functionality offered by Spring Data R2DBC. See Kotlin for the general functionality provided by Spring Data.

To retrieve a list of SWCharacter objects in Java, you would normally write the following:

Flux<SWCharacter> characters = client.select().from(SWCharacter.class).fetch().all();

With Kotlin and the Spring Data extensions, you can instead write the following:

val characters =  client.select().from<SWCharacter>().fetch().all()
// or (both are equivalent)
val characters : Flux<SWCharacter> = client.select().from().fetch().all()

As in Java, characters in Kotlin is strongly typed, but Kotlin’s clever type inference allows for shorter syntax.

Spring Data R2DBC provides the following extensions:

  • Reified generics support for DatabaseClient and Criteria.

  • kotlin/coroutines.adoc extensions for DatabaseClient.