Referrers

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

What a one-to-many relationship declared with referrersOn gives back: every child entity whose reference column points at this one.

class Director(id: EntityID<Int>) : IntEntity(id) {
val films by Film referrersOn Films.director

companion object : IntEntityClass<Director>(Directors)
}

val titles = director.films.toList().map { it.title }
val count = director.films.count()

The property is read-only — a child joins the relation by having its own reference set. Nothing is queried until the returned SizedIterable, which is a Flow, is collected or counted.

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.

cache

Whether loaded reference entities should be stored in the EntityCache.

Constructors

Link copied to clipboard
constructor(reference: Column<REF>, factory: EntityClass<ChildID, Child>, cache: Boolean, references: Map<Column<*>, Column<*>>? = null)

Properties

Link copied to clipboard

Full child→parent column mapping for the relationship. Single-column references derive this from reference.referee lazily; composite-FK references pass the full map explicitly. Mirrors JDBC's Referrers.allReferences.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

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

Modifies this reference to sort entities according to the specified order.

Modifies this reference to sort entities based on multiple columns as specified in order.

infix fun orderBy(expression: Expression<*>): Referrers<ParentID, Parent, ChildID, Child, REF>

Modifies this reference to sort entities by a column specified in expression using ascending order.