Hibernate Strongly recommends not mapping one-to-many with a join column?

Here’s what the Hibernate Annotations documentation has to say about mapping a unidirectional one-to-many relationship using a join column on the child table:

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 (as explained in the next section). This kind of association is described through a @JoinColumn

That’s a pretty vague statement! And finding out the details behind that statement isn’t too easy.

I did some splunking into the Unidirectional @OneToMany relationship via @JoinColumn to see if I agreed and found that I did not. I think this type of relationship is exactly what you need sometimes (not always).

But I did find some other interesting observations along the way.

Check out this snip for details Unidirectional one-to-many using a Join Column – Hibernate (link to follow)

Comments?

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply