Hello all,
I was wondering where the best place to create many to many relationships was? Fro example if I have something like
Code:
public class permission()
{
permission()
{
user = new HashSet<User>();
categories = new HashSet<Categories>();
}
}
is that better than doing something in the DAO like (and leaving the many to many relationship out of the permission class)
Code:
List<Permission> getPermissionsForUser(Long id)
{
//get permissions for the user from the many to many table and return that as a list
}
This is more of a which design is better question. If for example there is a permission like canUpdateContractPhone which doesn't apply to the categories then having an empty hashSet doesn't seam as effective as searching for the results and returning it from a DAO pattern. Or am I completely off?