代码之家  ›  专栏  ›  技术社区  ›  waldemar

房间中的嵌套关系

  •  0
  • waldemar  · 技术社区  · 6 年前

    @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)

    0 回复  |  直到 6 年前