Back to Exposed

optionalBackReferencedOn

docs/api/exposed-dao/org.jetbrains.exposed.v1.dao/-entity-class/optional-back-referenced-on.html

1.2.04.3 KB
Original Source

optionalBackReferencedOn

infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.optionalBackReferencedOn(column: Column<REF>): OptionalBackReference<TargetID, Target, ID, Entity<ID>, REF>

@JvmName(name = "optionalBackReferencedOnOpt")

infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.optionalBackReferencedOn(column: Column<REF?>): OptionalBackReference<TargetID, Target, ID, Entity<ID>, REF>

Registers an optional reference as an immutable field of the parent entity class, which returns a child object of this EntityClass or null if no child references the parent entity.

The reference could have been defined on the child table in 1 of the following ways:

  • By the creation of a column using either optReference() or reference().nullable()

  • By the creation of a non-nullable reference() column where either 0 or 1 row(s) is expected in the relationship

Samples

org.jetbrains.exposed.v1.tests.shared.entities.EntityTests.Studentorg.jetbrains.exposed.v1.tests.shared.entities.EntityTests.StudentBiosorg.jetbrains.exposed.v1.tests.shared.entities.EntityTests.StudentBio


infix fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.optionalBackReferencedOn(table: IdTable<*>): OptionalBackReference<TargetID, Target, ID, Entity<ID>, Any>

Registers an optional reference as an immutable field of the parent entity class, which returns a child object of this EntityClass or null if no child references the parent entity.

The reference should have been defined by the creation of a foreign key constraint on the child table, by using foreignKey().

Samples

org.jetbrains.exposed.v1.tests.shared.entities.CompositeIdTableEntityTest.Publisherorg.jetbrains.exposed.v1.tests.shared.entities.CompositeIdTableEntityTest.Officesorg.jetbrains.exposed.v1.tests.shared.entities.CompositeIdTableEntityTest.Office

Generated by Dokka © 2026 Copyright