OptionalBackReference

class OptionalBackReference<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 optionalBackReferencedOn gives back: the single child entity that references this one, or null if there is none.

class Film(id: EntityID<Int>) : IntEntity(id) {
val review by Review optionalBackReferencedOn 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 nullable reference column defined on the child entity's associated table.

factory

The EntityClass associated with the child entity that optionally 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?