How to mapping the relations between classes (@ManyToMany) for a table

邮差的信 提交于 2019-12-11 07:08:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!