I have a Patient entity which extends a base Resource object. Now Resource contains a uuid and a display, which I also want to include to the patients table, so I annotate like so:
public class Resource implements Serializable {
@ColumnInfo
protected String uuid;
@ColumnInfo
protected String display;
// getters and setters
}
And in my Patient entity, there are nested objects and they also extend from Resource (e.g. a PatientIdentifier and a Person object is embedded and has their own uuid and display):
@Entity(tableName = "patients")
public class Patient extends Resource implements Serializable {
@PrimaryKey
private Long id;
// ...
@Embedded
private PatientIdentifier identifier;
@Embedded
private Person person;
// other variables
}
this results in a column name conflict - as there is a "uuid" column for a Patient, the PatientIdentifier and the Person.
I want to rename the nested objects' uuid columns after their name (e.g. "person_uuid"), similar to the @ForeignKey annotation in entity relationships, so may I know how to do that?
You can specify the column name like that :
@ColumnInfo(name = "person_uuid")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With