Search code examples
javahibernatetable-relationships

Hibernate relation to jointable


I have a problem with Hibernate. I have three tables jobs, actions and mails. For jobs and actions there is a many-to-many relationship. So I created a join-table Action_Jobs which contains the ids of both tables.

Now, how can I build a relationship from the join-table Action_Jobs to my third table mails? Because from the combination of jobs and actions my mails are identified.


Solution

  • Create a new table Action_Jobs which maps Jobs to Action. Use the primary key of Action_Jobs table and map with Mails table. The primary key can be an auto increment column.

    Hope this helps...