0

我有以下表架构。

Employee (id int primary key, addressId int);
Address (id int primary key, line1 varchar(99), line2 varchar(99));

和类:

Employee {
int id;
Address address;}

Address {
String line1;
String line2;}

如何使用注释创建从 Employee 到 Address 的 OneToOne 组件映射?

4

1 回答 1

0
@Entity
public class Employee {

    private int id;

    @OneToOne
    private Address address;

}

@Entity
public class Address {
    private String line1;
    private String line2;
}
于 2012-09-22T18:12:04.470 回答