Consider the following domain model:
Issue
- id
- List<Comment>
Entry
- id
- List<Comment>
Comment
-id
-comment
In my design, I was attempting to create two join tables to manage the associations; issue_comments, and entry_comments. I assumed @OneToMany on Issue & Entry, but how do you map the multiple join tables? Using hibernate annotations, how can this be mapped?
If you can change your domain model, take a look at answer given by cletus. You’ll only have one table to update so it’ll provide better performance.
If you cannot change your domain model, you can map your
commentcollections via join tables:Your comments would still be in the same table for both issues and entries; only join tables will be different. Note that this is a uni-directional relationship. Details are here