[英]Android Room one-to-one Entities Relation
In Room if you want a relation between two entities you can achieve it with a third POJO
that defines their relation as: 在房间中如果你想要两个实体之间的关系,你可以用第三个
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>
}
Is there a nice approach to make the POJO expose a single field instead of a List
? 有没有一个很好的方法让POJO暴露单个字段而不是
List
? Are there any workarounds? 有没有解决方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.