We use @onDelete annotation when we want to control deletion of an entity preventing data redundancy. this works very well and I’m using this as and where needed.
Now my requirement is a bit different. Let me explain with an example. Say I have 3 Entity. Account, CostCentre and Transaction. Account and CostCentre are related Many to Many. Each record in Transaction Entity has both Account and CostCentre entities. I want to deny deletion of specific relationship between Account and CostCentre if this pair of Account-CostCentre is used in any record in Transaction Entity. Is there any way to achieve this through annotations or other good solutions?