I am writing my entities and due to my modeling I have a OneToMany
relationship between two Entities, of course both relationships have a
different meaning. However when I see the data base only one table with
three columns was created representing the relationship. I was expecting
to have two relationship tables each representing a relationship. Is there
a way to model two OneToMany relationships between two Entities creating a
different table for every relationship?
You must use the @JoinTable annotation whenever you have two
OneToMany/ManyToMany relationships to the same class. This is because the
JPA defined defaulting auto-mapping rules require using the
<source>_<target> as the default table name, as normally it is the best
name to use, but of course does not work if you have multiple
Also please log a bug that a warning or error message should be logged if
there are multiple OneToMany/ManyToMany relationships to the same class
(or a different naming strategy should be used in the case of multiple).