| In my case I was wrong – in the first code sample, I had placed @JoinTable on both sides of the association. However, according to the API docs:
Specifies the mapping of associations. It is applied to the owning side of an association.
And according to section 11.1.27 of the specification (emphasis mine):
The JoinTable annotation is used in the mapping of entity associations. A JoinTable annotation is specified on the owning side of the association.
That's why Hibernate was behaving in an unexpected way. When I fixed the annotations, everything started working as expected.
Some accepted StackOverflow answers are unfortunately wrong and misleading. |