@Entity
public class Item {
@PrimaryKey(autoGenerate = true)
public long id;
public String value;
}
@Entity
public class Image {
@PrimaryKey(autoGenerate = true)
public long id;
public String value;
public long patternId;
public long itemId;
}
@Entity
public class Pattern {
@PrimaryKey(autoGenerate = true)
public long id;
public String value;
}
关系:
public class ItemWithImages {
@Embedded
public Item item;
@Relation(parentColumn = "id", entityColumn = "itemId")
public List<ImageWithPattern> imageWithPattern;
}
public class ImageWithPattern {
@Embedded
public Image image;
@Embedded
public Pattern pattern;
}
Query("SELECT * FROM items LEFT JOIN patterns ON images.patternId = patterns.id")
public abstract Maybe<List<ItemWithImages>> getItems();
以下是我的错误:
查询有问题:[SQLITE_ERROR]SQL错误或丢失
数据库(没有这样的列:images.pattern_id)