mihalcea_vlad wrote:
So both link1 and link2 reference the table_a identifier.
Because the link2 has a unique constraint, it means that you might have multiple table_b rows with a link1 value that point to one row in table_a, but those table_b rows would need to still have unique link2 values.
You could map two @ManyToOne associations using link1 and link2 in TableB entity and have the mappedBy sides (with @OneToMany and @OneToOne) in the TableA entity.
But as soon as I do @ManyToOne in TableB Entity with @JoinColumn("link_2") and @OneToOne in TableA Entity with mappedBy="link2", Eclipse throws an error saying "In attribute EntityA, the mapped by attribute link2 has an invalid mapping type for this relation".
It seems, it's not possible to have ManyToOne on one entity and OneToOne on another entity of the relations.