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
tapac
06/08/2021, 8:35 AM
Do you want to delete Address when related Person or Company deleted?
e
ESchouten
06/08/2021, 10:41 AM
@tapac Yes!
t
tapac
06/08/2021, 7:52 PM
Afaik it's not possible from SQL side to declare such a relation between tables.
e
ESchouten
06/08/2021, 10:30 PM
Would the best solution be to make address an abstract class and create PersonAddress and CompanyAddress with its references?
t
tapac
06/09/2021, 9:38 AM
It should work if you declare person_id in PersonAddress but that means you have to create Person before address in your code.