I have the following tables in a legacy database:
Table1
+ Table1ID PK
+ Table1Code
Table2
+ Table2ID PK
+ Table1Code
The convention is that there is only 1 Table1Code for each Table1ID. Table2 has a one to many relationship with Table1.
I want to reference them both as JPA objects. Is this possible using @OneToMany and specifying the @JoinColumns?
Yes, you just have to use the
referencedColumnNameattribute of theJoinColumnannotation: