Reputation: 1242
I have the following code structure:
interface Watchable {
fun show: Show
}
@Entity
@Parcelize
data class TopRatedShow(
@Embedded
val show: Show,
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "topRatedShowId") val id: Int = show.id
) : Parcelable, Watchable {
override fun show(): Show {
return show
}
}
But my code wont compile and throw:
error: Ambiguous getter for Field(element=show, name=show, type=com.zk.***.Show,
affinity=null, collate=null, columnName=show, defaultValue=null, parent=null,
indexed=false, nonNull=true).
All of the following match: show, getShow.
You can @Ignore the ones that you don't want to match.
private final com.zk.***.Show show = null;
It seems that combining @Embedded with implementing the interface is causing the issue but I don't fully understand what seems to be the problem
Upvotes: 0
Views: 594
Reputation: 1129
Since all your class, function signature, as well as val name is show, room is having problem on which one to choose.
interface Watchable {
fun show: Show
}
@Entity
@Parcelize
data class TopRatedShow(
@Embedded
val myshow: Show,
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "topRatedShowId") val id: Int = myshow.id
) : Parcelable, Watchable {
override fun show(): Show {
return myshow
}
}
Either you can change the val name or you can tell room which one to ignore using @Ignore
Upvotes: 1