I am facing with a specific problem with Room. I have an object
@Entity(tableName = "classifieds")
data class ClassifiedBean(
@PrimaryKey
@ColumnInfo(name = "id")
@SerializedName("id")
var id: String,
@Embedded
@SerializedName("client")
var clientBean: ClientBean,
@Embedded
@SerializedName("location")
var locationBean: LocationBean
)
Here I have my Object LocationBean and ClientBean.
The problem is inside my ClientBean, I have also a LocationBean with same attribute (address, postalCode, city, country...).
data class ClientBean(
@ColumnInfo(name = "client_id")
@SerializedName("id")
var id: Int,
@ColumnInfo(name = "name")
@SerializedName("name")
var name: String,
@Embedded
@SerializedName("location")
var locationBean: LocationBean
)
here you can find my LocationBean
data class LocationBean (
@ColumnInfo(name = "location_id")
@SerializedName("locationId")
var id: Int,
@ColumnInfo(name = "country")
@SerializedName("country")
var country: String,
@ColumnInfo(name = "city")
@SerializedName("city")
var city: String,
@ColumnInfo(name = "address")
@SerializedName("address")
var address: String,
@ColumnInfo(name = "postal_code")
@SerializedName("postalCode")
var postalCode: String,
)
Here my error :
error: Multiple fields have the same columnName: location_id. Field names: clientBean > locationBean > id, locationBean > id.
One of the solution is to create 2 different object with same attribute but I would like to know if they have another solution ?
Thank you for your help