Hibernate version: 3.1 + Annotations 3.1 beta 7
Mapping documents: @OneToMany @JoinTable vs. @JoinColumn
Code between sessionFactory.openSession() and session.close(): Using JBoss AS 4.0.3SP1 + EJB3RC3 Session Beans w/ entity manager
Name and version of the database you are using: PostgreSQL 8.1
Please forgive my data modeling ignorance. I need help understanding the reasoning of and strategies related to the unidirectional OneToMany best practices. In section 2.2.5.3.2.2 of the Hibernate Annotations 3.1 beta 7 Reference Guide(
http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#d0e1146), the following is stated:
Quote:
A unidirectional one to many using a foreign key column in the owned entity is not that common and not really recommended. We strongly advise you to use a join table for this kind of association.
Can someone explain or point me to documentation that explains the reasoning behind this, the modeling and querying strategies related to this, and maybe give some scenarios that exemplify why the @JoinTable approach is strongly recommend and a scenario that demonstrates a good place to choose to use the @JoinColumn instead?
I've wondered about this and I ask for my own edification. In addition, a colleague who works against the same data as I do, but does not share the same middleware code, recently asked why I'm forcing him to do joins in situations where a select would suffice. He wasn't impressed with "because the Hibernate documentation recommends it" so I figure now's a pretty good time to fill in this hole in my own knowledge.
Thanks for the help!
Jonn