I wanted to use the @Relation annotation in an Android Project. Here I have found a description about that topic:
@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;
}
My question would be:
The parentColumn argument is id . But which id is it ? Is it the id of User or the id of Pet? In the documentation it says that the parentColumn() is a reference column in the parent POJO. But which one is the parent POJO ?