根据实体关系模型之间的关系,tbl_post并且tbl_category可以使用指定房间持久性库如下:
@Entity(foreignKeys = @ForeignKey(
entity = TblPost.class,
parentColumns = "id",
childColumns = "tbl_post_id")
)
class TblPostCategory {
@PrimaryKey
public String id;
@ColumnInfo(name = "user_id")
public String postId;
}
Run Code Online (Sandbox Code Playgroud)
但是TblPostCategory取决于两个外键:post_id和category_id来自TblPost和TbCategory.
如何使用房间注释描述关系?