|
I have some difficulty to find the right solution for the mapping problem I have here.
I have a User class which has two business methods: getCoWorkers() and getDirectCoWorkers(). Direct co-workers are a subset of co-workers. Both methods return a collection of User objects. The relationship between users and co-workers is many-to-many, and it's unidirectional from users to co-workers. Since direct co-workers are co-workers, I don't want to keep two copies of the same user in the object.
The table of the relationship is like:
id (synthetic primary key)
user_id
co_worker_id
co_worker_flag (indicating whether this co-worker is a direct co-worker)
Anyone can help out on this?
Thanks in advance.
|