[英]Android Room one-to-one Entities Relation
在房間中如果你想要兩個實體之間的關系,你可以用第三個POJO
來實現它,它定義了它們的關系:
@Entity
class Foo {
//fields here including _id,...
}
@Entity // forigne keys restriction here ...
class Baz {
long foo_id
}
//The linking POJO
class BazWithFoo extends Baz { //may replaced with @Embeded Baz field
@Relation(entity = Foo.class,entityColumn = "_id",parentColumn = "foo_id")
List<Foo> foo; // <-- want this to be Foo not List<Foo>
}
有沒有一個很好的方法讓POJO暴露單個字段而不是List
? 有沒有解決方法?
你應該看到這個 。 可以在POJO中管理兩個@Embedded
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.