I’m kinda stuck defining a Hibernate Entity:
Assuming I have the following two tables in a database:
(A)
- fromCompany
- toCompany
- viaCompany
(B)
- companyID (PK)
- description
where the elements of (A) point to the primary key of (B); so there are 3 one-to-one relationships between the FKs and the PK.
I assume 3 OneToOne statements with different mappedBy conditions are not the way to go, mh? Has been a long day – I probably just don’t get it 😉
Thanks for your help!
If I understood correctly, you want your database to look like this:
If so, you can certainly have this. You just need to override the default column name for the relationship, so that each association have it’s own column name instead of falling back to the default name, which would render the three associations with the same name, causing problems.
I don’t really agree with OneToOne, but I assume this was a conscious decision.
See this:
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html#entity-mapping-association