Use @PrimaryKeyJoinColumn
http://www.java2s.com/Tutorials/Java/JPA/0730__JPA_OneToOne_Primary_Key_Join.htm
@Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private long id; private String name; @OneToOne @PrimaryKeyJoinColumn private Department department;
when you want to use Person's id to join with Department's id
If in Person entity have a FK with name "departmentID" then you should use @JoinColumn
Comments
Post a Comment