BackReference

class BackReference<ParentID : Any, out Parent : Entity<ParentID>, ChildID : Any, in Child : Entity<ChildID>, REF>(reference: Column<REF>, factory: EntityClass<ParentID, Parent>, references: Map<Column<*>, Column<*>>? = null)

What a one-to-one relationship declared with backReferencedOn gives back: the single child entity that references this one, read by invoking the property.

class Film(id: EntityID<Int>) : IntEntity(id) {
val review by Review backReferencedOn Reviews.film

companion object : IntEntityClass<Film>(Films)
}

val stars = film.review().stars

The property is invoked rather than read directly because the lookup suspends.

Parameters

reference

The reference column defined on the child entity's associated table.

factory

The EntityClass associated with the child entity that references the parent entity.

Constructors

Link copied to clipboard
constructor(reference: Column<REF>, factory: EntityClass<ParentID, Parent>, references: Map<Column<*>, Column<*>>? = null)

Functions

Link copied to clipboard
operator fun getValue(thisRef: Child, property: KProperty<*>): suspend () -> Parent