[jboss-user] [EJB 3.0] - Re: Which methods should an Entity contain?

Wolfgang Knauf do-not-reply at jboss.com
Fri Dec 12 06:16:11 EST 2008


Hi Nicki,

My 2 cent: I would suggest to place "addRole" and "removeRole" in the session bean. The reason is that for relationships,  both sides of the relation must be modified:

For example this snippet will add a new user-to-role-connection:
myUser.getRoles().add (myRole);
  | myRole.getUsers().add (myUser);

Placing this in an entity breaks data encapsulation principles, because the entity manipulates other entitities ;-). But technically, it would work in the entity, too. It is just "dirty".

Best regards

Wolfgang

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4196199#4196199

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4196199



More information about the jboss-user mailing list