I am developing human task engine based on WS- Human Task spec. When handling people assignments in task, there are several roles specific to task. For a task we have stakeholders, potential owners, business administrators and notification recipients. So when reflecting this in my domain objects, I designed it using several Sets like following(This is task domain object).
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<OrganizationalEntity> stakeHolders;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<OrganizationalEntity> potentialOwners;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<OrganizationalEntity> businessAdministrators;
And in the OrganizationalEntity I keep list of tasks. Is this the right way to do it.
What if I do it in following manner. I keep one field for people assignments in Task.
private Set peopleAssignments;
And I am adding humanRole field to OrganizationEntity to tell that this entity is in this role. I think I must allow to store list of human roles, because one entity can be in several roles(Spec doesn't have clear explanation about this).
I think if I follow the later approach I will have to write complex queries in data access object for Organizationalentity.
What do you think about this?