I kindly ask for help for mapping OneToMany bidirectional with ManyToOne. Consider the following (for the sake of semplicity):
I have two tables, FOO and BAR. Foo has a PK which is named "ID". BAR has a composite PK, which is made of ID_FOO (i.e. it's the FK to FOO) and ID.
For both tables, there're the realitve entites, namely Foo and Bar.
Foo has the field id annotated with @Id and contains a field of type Bar (say 'bar') which has the @OneToMany mapped by "foo" - which is the field of the Bar class. On this field (foo) of the Bar class, I have @ManyToOne and @JoinColumn(name="ID_FOO") annotated. Foo also has the composite primary key field fooPk of type FooPK, with @EmbeddedId annotated. The FooPK refers to the two fields, i.e. the ones mapping ID and ID_FOO.
With this config, I get the error "org.hibernate.MappingException: Repeated column in mapping for entity:" Foo. when deploying.
If I change the configuration, and use only OneToMany JoinColumn on ID_FOO on the Foo entity bean and delete the reference back on the Bar entity, it works - but of course, I can't navigate from Bar to Foo...
So, how do I config the OneToMany bidirectionally, when the "weak" table/class has a composite primary key?