references
inline fun <C : Any, R : Entity<R>> Column<C>.references(referenceTable: Table<R>, selector: (E) -> R?): Column<C>(source)
Bind the column to a reference table, equivalent to a foreign key in relational databases. Entity sequence APIs would automatically left-join all references (recursively) by default.
Note: Since Column is immutable, this function will create a new Column instance and replace the origin registered one.
Return
the new Column instance.
Parameters
referenceTable
the reference table, will be copied by calling its aliased function with an alias like _refN
.
selector
a lambda in which we should return the property used to hold the referenced entities. For example: val departmentId = int("department_id").references(Departments) { it.department }
.