Tag: java annotations

在Kotlin中使用Room的@ForeignKey作为@Entity参数

我遇到了一个Room 教程 ,它使用了类定义上的@PrimaryKey注释: @Entity(foreignKeys = @ForeignKey(entity = User.class, parentColumns = “id”, childColumns = “userId”, onDelete = CASCADE)) public class Repo { … } 现在,我有以下想要使用主键的数据类: @Parcel(Parcel.Serialization.BEAN) data class Foo @ParcelConstructor constructor(var stringOne: String, var stringTwo: String, var stringThree: String): BaseFoo() { … } 所以,我刚刚在@Entity(tableName = “Foo”, foreignKeys = @ForeignKey(entity = Bar::class, parentColumns = “someCol”, childColumns = […]