How do I achieve a unidirectional one to one relationship for Person and PersonData?
@Entity
public class Person {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
// @OneToOne...?
// ...?
private PersonData data;
}
@Entity
public class PersonData {
@Id
private long personId;
}
Using the
@OneToOne
annotation with the@JoinColumn
annotation to specify the primary key of the other entity: