xxxxxxxxxx
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@OneToOne(mappedBy = "person", cascade = CascadeType.ALL)
private Address address;
// Getters and setters (omitted for brevity)
}
@Entity
public class Address {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String city;
@OneToOne
@JoinColumn(name = "person_id")
private Person person;
// Getters and setters (omitted for brevity)
}