Is there any way I can set the childs' ReferenceOp...
# exposed
e
Is there any way I can set the childs' ReferenceOption.Cascade from the parent entity? The child table is referenced from multiple tables, and I want to avoid optionally referencing each of the tables at the child level Example:
Copy code
object Person : UUIDTable() {
    val name = varchar("name", 255)
    val address = reference("address", Address)
}

object Company : UUIDTable() {
    val name = varchar("name", 255)
    val address = reference("address", Address)
}

object Address : UUIDTable() {
    val number = varchar("number", 255)
    val street = varchar("street", 255)
    val city = varchar("city", 255)
    val zipcode = varchar("zipcode", 255)
    val country = varchar("country", 255)
}
t
Do you want to delete Address when related Person or Company deleted?
e
@tapac Yes!
t
Afaik it's not possible from SQL side to declare such a relation between tables.
e
Would the best solution be to make address an abstract class and create PersonAddress and CompanyAddress with its references?
t
It should work if you declare person_id in PersonAddress but that means you have to create Person before address in your code.