问题
How to mapping the relations between three class @ManyToMany unidirectional for a unique table ?
The relations is like that:
- Project have many Task
- Many Task have many specifcs Activitys (to standard) - for each task have many specifcs activitys
- Task and Activitys are standard into the data base.
So, when I'll create a Project, I'll chose somes Tasks and somes Task's Activitys.
I would to create a table (project_task_activity_map) like that:
project_id task_id activity_id
1 2 3
1 2 4
2 1 2
2 1 1
2 2 3
2 3 5
How can I map the class Project ?
Reference link:
See Orders Table
回答1:
I think hierarchy like
Project | Task | Activity
There is no direct relation between Project & Activity.
Better to create many to many table for Task & Activity, keep Project as master only. Total 4 tables - Project - Task - Activity - TaskActivityMapping
Fourth table will be created by Hibernate mapping of Task and Activity via Embadable.
来源:https://stackoverflow.com/questions/16033461/how-to-mapping-the-relations-between-classes-manytomany-for-a-table