Embedded
複数の同じクラスを使用したい場合。@AttributeOverrides
すべての列に対して行う必要があります。以下のようにしてみてください。
リファレンスJPA AttributeOverrides
@Embeddable
public class Address {
private String state;
@Column(name = "zip_code")
private String zip;
}
@Entity(name = "Employee")
public class Employee implements Serializable {
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "state", column = @Column(name = "province_1")),
@AttributeOverride(name = "zip", column = @Column(name = "postal_code_2"))
})
private Address address_1;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "state", column = @Column(name = "province_2")),
@AttributeOverride(name = "zip", column = @Column(name = "postal_code_2"))
})
private Address address_2;
}
に 1 つ以上のEmbedded
値がある場合、私の提案Entity
です。使ってみてください@CollectionTable
。
@CollectionTable(name = "EMPLOYEE_ADDRESS", joinColumns = @JoinColumn(name = "ADDRESS_ID"))
private List<Address> addressList;
リファレンスJPA CollectionTable