【发布时间】:2018-08-29 03:02:41
【问题描述】:
我有一个 Patient 实体,它扩展了一个基础 Resource 对象。现在Resource 包含一个uuid 和一个display,我也想将它们包含到患者表中,所以我这样注释:
public class Resource implements Serializable {
@ColumnInfo
protected String uuid;
@ColumnInfo
protected String display;
// getters and setters
}
在我的Patient 实体中,有嵌套对象,它们也从Resource 扩展(例如PatientIdentifier 和Person 对象被嵌入并具有自己的uuid 和显示):
@Entity(tableName = "patients")
public class Patient extends Resource implements Serializable {
@PrimaryKey
private Long id;
// ...
@Embedded
private PatientIdentifier identifier;
@Embedded
private Person person;
// other variables
}
这会导致列名冲突 - 因为患者、PatientIdentifier 和 Person 有一个“uuid”列。
我想以嵌套对象的名称(例如“person_uuid”)重命名嵌套对象的 uuid 列,类似于实体关系中的 @ForeignKey 注释,请问我该怎么做?
【问题讨论】:
标签: database entity android-room