Reputation: 1246
I have ParentTable
and ChildTable
as table entites. When a record is inserted into ParentTable i want it to automatically create a record in ChildTable. The child table has two columns, colA is the row id of the parent table and colB is some default value.
Is there any way to automatically do this in Kotlin Exposed using DAO and cascade function onUpdate
?
Upvotes: 1
Views: 341
Reputation: 81
It would be good if you provide more information. But you can use DAO lifecycle hooks in your parent entity class. something like below:
EntityHook.subscribe {
if (it.changeType == EntityChangeType.Created) {
// insert in child table
}
}
Upvotes: 1