@PreUpdate on One of OneToMany?

647 Views Asked by At

When updating the underlying list of a OneToMany relationship is there a way to get a @PreUpdate trigger on the One side?

one.getManyList().add(many);

triggers @PreUpdate on many's class, but nothing on one's. This probably makes sense from a db point of view as only many's table is affected, but I really need the trigger to fire on one's class.

Any way to make this happen? Using EclipseLink FWIW.

TIA.


So far the best I've come-up with is a @PreUpdate in Many which sets a many specific timestamp in one which in turn triggers @PostUpdate in One.

Not exactly optimal but it does give me a single event in One regardless of the number of manys that are updated.

1

There are 1 best solutions below

0
On BEST ANSWER

A Many specific timestamp in the One updated from @PreUpdate in the Many is the most efficient solution.

Multiple Many-side @PreUpdates can fire and only one One-side @PostUpdate is triggered.