I have two entities
- Fruit Set , which contains a list of fruit
- fruit, which may or may not belong to a Fruit Set
I’m trying to figure out how to get a constraint working which
- If I delete a fruit set it deletes all the nestled fruit
- If I try and delete a fruit entity which belongs to a fruit set it denies it
Having a hell of a time.
Also do not want soft delete functionality in either table.
I can get (1) to work with an on delete listener.
But 2 will not work. Even if I set the on delete policy. It just deletes the fruit and removes it from the fruit set.
Is it because I have an entity listener on the fruit entity? Does that override the @OnDelete(DeletePolicy.DENY) policy on the fruit class?
Is it possible to set something in the fruit listener which denies the transaction if the fruit belongs to a fruit set? I cannot see any methods to override or anything…