我从三个表中都有一个对象,我尝试这样做:
@Parcelize
@Entity(tableName = "table_one")
data class OneItem(
@PrimaryKey
@ColumnInfo(name = "id")
val id: Long,
val name: String? = null,
):Parcelable
@Parcelize
@Entity(tableName = "table_two")
data class TableTwo(
@PrimaryKey
@ColumnInfo(name = "label")
val label: Long,
val value: String? = null
):Parcelable
@Parcelize
@Entity(tableName = "table_three", primaryKeys = ["id_table_one", "type"])
data class Three(
@ColumnInfo(name = "id_table_one") val id_table_one: Long,
@ColumnInfo(name = "type") val type: Int,
@ColumnInfo(name = "card_id") var cardId: String? = null,
):Parcelable
我尝试从表1中获取一行对象,从表2中获取对象,并从表3中获取对象,我尝试这样做:
class BigClass(
@Embedded val oneItem: OneItem,
@Embedded val tableTwo: TableTwo,
@Relation(
parentColumn = "id",
entityColumn = "id_table_one",
entity = Three::class
)
val three: List<Three>
)
当我尝试构建应用程序时出现错误;
Eror:用@Relation注释的字段不能是构造函数参数。这些值是在构造对象之后获取的