OK, I consider this more of a workaround, but it gets the job done.
I have created an event listener method that will remove all the m2m associated objects prior to delete. Doing it this way ensures that this will always get fired.
The remove method clears the association on both sides.
The removeAll method handles the whole collection.
The preRemove method triggers the whole thing.
Code:
public void removeChannel(Channel channel) {
if (channel == null)
return;
getChannels().remove(channel);
channel.getOfferAvailabilities().remove(this);
}
public void removeAllChannels() {
List<Channel> remove = new ArrayList<Channel>();
remove.addAll(getChannels());
for (Channel channel : remove) {
removeChannel(channel);
}
}
@PreRemove
public void preRemove() {
removeAllChannels();
}