Nikhil Purushe edited this page May 10, 2017 · 16 revisions


The kotlin module provides an alternate query and storage interface that takes advantage of Kotlin specific language features. These include property references, infix functions, operator functions and more.

To use these features use KotlinEntityDataStore instead of EntityDataStore.

val configuration = KotlinConfiguration(dataSource = dataSource, model = Models.DEFAULT)
val data = KotlinEntityDataStore(configuration)


data.invoke {
    val result = select(Person::class) where (Person::name eq "Bob") limit 5
    val first = result().first()


In Kotlin entity definitions can be created from interface classes with properties or from immutable data classes. Example: (note the get prefix on annotations)

interface Person : Persistable {

    var id: Int
    var name: String
    var email: String
    var birthday: Date
    var age: Int

    var address: Address

    val groups: Set<Group>

    var about: String

    @get:Column(unique = true)
    var uuid: UUID
    var homepage: URL

Data class example:

data class Person constructor (

    var id: Int,
    var name: String,
    var email: String,
    var birthday: Date,
    var age: Int,

    var about: String,

    @get:Column(unique = true)
    val uuid: UUID,
    val homepage: URL,
    val picture: String

Note data classes are subject to same restrictions as immutable types


  1. Add the apt gradle plug-in to your build as described here
  2. Add the requery dependencies to your app build.gradle file:
dependencies {
    compile 'io.requery:requery:<latestVersion>'
    compile 'io.requery:requery-kotlin:<latestVersion>'
    compile 'io.requery:requery-android:<latestVersion>' // optional for android support
    apt 'io.requery:requery-processor:<latestVersion>' 


A full android example project is available here

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.