9
Person
類JPA:如何重寫@Embedded的列名屬性
@Embeddable
public class Person {
@Column
public int code;
//...
}
嵌入內Event
作爲兩個不同的兩倍屬性:manager
和operator
@Entity
public class Event {
@Embedded
@Column(name = "manager_code")
public Person manager;
@Embedded
@Column(name = "operator_code")
public Person operator;
//...
}
這應該給兩個各自在列用Persistence生成數據庫模式。而是拋出一個異常:
org.hibernate.MappingException:在映射重複列實體:事件列:代碼
如何爲每個屬性覆蓋默認列名code
?
使用'@ AssociationOverrides'(用於實體間關係)或'@ AttributeOverrides'(用於簡單的屬性) – Thomas