Andriel
Andriel

Reputation: 374

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

How to mapping the relations between three class @ManyToMany unidirectional for a unique table ?

The relations is like that:

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

Upvotes: 1

Views: 178

Answers (1)

Manoj Kathiriya
Manoj Kathiriya

Reputation: 3416

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.

Upvotes: 1

Related Questions