【发布时间】:2020-03-19 22:40:36
【问题描述】:
我想在 Android 项目中使用 @Relation 注释。 Here我找到了关于该主题的描述:
@Entity
public class User {
@PrimaryKey
public int id; // User id
}
@Entity
public class Pet {
@PrimaryKey
public int id; // Pet id
public int userId; // User id
public String name;
}
public class UserWithPets {
@Embedded
public User user;
@Relation(parentColumn = "id", entityColumn = "userId", entity = Pet.class)
public List<Pet> pets;
}
我的问题是:
parentColumn 参数是 id 。但它是哪个id?是User 的id 还是Pet 的id?在文档中,它说parentColumn() 是父 POJO 中的参考列。但是哪个是父 POJO 呢?
【问题讨论】:
标签: android android-room pojo