Answer the question
In order to leave comments, you need to log in
How to correctly implement the many to many relationship in Room?
How to correctly implement the many to many relationship in Room?
such tables
Answer the question
In order to leave comments, you need to log in
In short, in the link table, the keys should be described something like this:
@Entity(tableName = "invoiceDetail",
primaryKeys = { "p_id", "inv_id" },
foreignKeys = {
@ForeignKey(entity = Product.class,
parentColumns = "p_id",
childColumns = "p_id"),
@ForeignKey(entity = Invoice.class,
parentColumns = "inv_id",
childColumns = "inv_id")
})
I tried to get cards with a list of categories in this way, but it does not work. All data is null
public class CardWithCategoryEntity {
@Embedded
public CardEntity cardEntity;
@Ignore
@Relation(parentColumn = "id", entityColumn = "cards_id", entity = CardCategoryEntity.class, projection = {"cards_id, category_id, record_type"})
public List<CategoryEntity> categoryList;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question