Hibernate will happily infer a name for a many-valued association with a @JoinTable with no name member, exactly as specified by JPA. But for some reason it apparently refuses to do this for a single-valued association. This seems inconsistent, and arguably even goes against the spec. It’s surely very easy to fix: just infer a name. The Javadoc and spec say:
Defaults to the concatenated names of the two associated primary entity tables, separated by an underscore.
This is a bit ambiguous, being silent on the order of the table names! But I think we can extrapolate from sections 2.10.5.x that the rule is that the “owner” of the association comes first. (A @ManyToOne is always the owner.) |