3

I have a database structure like that:

Item
- id
- status_id
- title

Status
- id
- name

Feature
- id
- name

ItemFeature
- item_id
- feature_id
- value

I'd like to load the entire graph in a LiveData<List<Item>> collection... I know I have to make a POJO with @Embedded and @Relation attributes, but no matter how I design those nested POJOs, Room constantly reports that some columns are missing from the query.

My last attempt was something like that:

public class ItemFeatureAndRelated {
  @Embedded
  public ItemFeature itemFeature;

  @Embedded
  public Feature feature;
}

public class ItemAndRelated {
  @Embedded
  public Item item;

  @Embedded
  public Status status;

  @Relation(parentColumn = "id", entityColumn = "item_id")
  public List<ItemFeatureAndRelated> itemFeatures;
}

I need a LiveData<List<Item>> so I can be notified of any database change in the Item table and refresh my interface.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Alessandro
  • 3,666
  • 2
  • 28
  • 41

0 Answers0