> Each Membership is associated with a Subscriber. To complicate things, a Subscriber has its own association with Membership: It has the concept of a "default" Membership.
to clarify, a Topic has this:
Code:
Set getMemberships()
A Membership has this:
Code:
Subscriber getSubscriber()
And a Subscriber has this:
Code:
Membership getDefaultMembership()
So in my mapping I have a set of Memberships for a Topic.
I can set cascading deletes up so that when a Topic is deleted, the Memberships are also deleted.
But then if I delete a Topic, I might have Subscribers that point to deleted Memberships.
So currently, my service layer looks up the Topic and asks it to "clear()" itself. This, in turn, asks each membership is to clear() itself, which un-links itself from its subscriber (i.e: if subscriber.getDefaultMembership().equals(this), subscriber.setDefaultMembership(null) ).
Does this sound like a reasonable way to do it? It just feels a little "un-clean" to me.