Accessor
class Accessor<ID : Any, Parent : Entity<ID>, REF : Any>(reference: Column<REF>, factory: EntityClass<ID, Parent>, entity: Entity<*>, references: Map<Column<*>, Column<*>>? = null)
What a non-nullable many-to-one reference declared with referencedOn gives back. Declare the property as a val, read the referenced entity by invoking it, and write it with set:
class Film(id: EntityID<Int>) : IntEntity(id) {
val director by Director referencedOn Films.director
companion object : IntEntityClass<Film>(Films)
}
val name = film.director().name // suspends, and queries unless the entity is already cached
film.director.set(otherDirector) // does not suspend: staged like any other column writeContent copied to clipboard
The property hands back this accessor rather than the entity itself because reading it has to suspend and a property getter cannot — the JDBC DAO, where the read blocks, returns the entity directly.