I'll state the issue back to you a slightly different way. As you have it, you actually are not defining a bi-directional association; you are really defining 2 distinct associations.
For mapping a bi-directional many-to-one association you have 2 choices (and in fact this is outlined very well in the SO post you link). But as is, your test does neither. So you can either:
-
Make the ManyToOne side the owner in the Java model. This is the typical case, and is indicated by @ManyToOne + @OneToMany(mappedBy). @OrderColumn does not really fit well in this well because it leads to a situation that does not make a ton of sense from the relational perspective, which leads to...
-
Make the OneToMany side the owner in the Java model. Here you'd use @ManyToOne(insert=false,update=false + @OneToMany (no mappedBy)
For what it is worth, the cases where Hibernate does not support @ManyToOne + @OneToMany(mappedBy) + @OrderColumn are actually quite limited. AFAIK its really just cases where the list is reordered, and even then (again afaik) that can be worked around by specifying @ManyToOne(optional=true which granted is not ideal.
|