| OneToMany two times [message #454260] |
Sat, 01 August 2009 13:26  |
Omar Diego Vera Ustariz Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Hi all,
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?
Thanks in advance,
-Omar Diego
|
|
|
| Re: OneToMany two times [message #480783 is a reply to message #454260] |
Tue, 18 August 2009 09:21  |
James Sutherland Messages: 1834 Registered: July 2009 |
Senior Member |
|
|
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
relationships.
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).
---
James
James : Wiki : Book : Blog
|
|
|
Powered by
FUDForum. Page generated in 0.07446 seconds