Hibernate version: 2.1
Mapping documents: generated by middlegen
Here's a simple association to illustrate my question:
Code:
(user)-1---*-(user_priv)-*---1-(priv)
Assume the join table has some association-specific data in it, so it needs to exist as a navigable class with two 1-many relationships. The pseudocode to manage these relationships might look like this:
Code:
UserPriv addAssociation(User user, Priv priv) {
UserPriv assoc = new UserPriv(priv,user);
user.getUserPrivs().add(assoc);
priv.getUserPrivs().add(assoc);
}
void removeAssociation(UserPriv assoc) {
assoc.getPriv().getUserPrivs().remove(assoc);
assoc.getUser().getUserPrivs().remove(assoc);
session.delete(assoc);
}
That last line is where my question/problem lies. Everything else could be written into the pojos, requiring no session/transaction logic to be embedded in the method. But the act of breaking an association requires object deletion, which (AFAIK) requires a call on the session -- thus making my pojo no longer "po". So how could I do this so that the pojos can remain DB-code-free?