| How to trigger pre-update computation on parent? [message #869324] |
Thu, 03 May 2012 04:26  |
|
Hi,
Here is the simplified legacy data model: a one-to-many relationship between Invoice and Payment (an invoice can have many payments). Besides, the Invoice entity has a persistent field containing the sum of all associated payments.
This sum is computed in a preWrite API called from @PreCreate and @PreUpdate hooks of the Invoice entity.
The question is: what is the cleanest way to trigger the invoice sum computation when one of its payments created or updated?
I've set a CascadeType.MERGE on both sides of this bidirectional association. But to get the @PreUpdate API called on the Invoice entity I have to manually trigger to sum of its payments.
I wish the only update of a payment automatically triggered the update of its associated invoice.
Thanks,
Chris
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02216 seconds