在roomdb android中@Relation面临的问题

问题描述 投票:0回答:1
 public class StockRelation extends Item {
        @Relation(parentColumn = "mpc", entityColumn = "itempc", entity = Location.class)
        public List<Location> locationList;
    }

    public class RStockRelation extends StockRelation{
       @Relation(parentColumn = "mpc", entityColumn = "location_itemid", entity = Location.class)
       public List<Location> locationList;
    }

这里只有@Relation得到更改,而其他情况相同。我想根据查询本身的位置表中的列对位置列表进行排序。因此,如何在一个对象中而不是两个不同的StockRelation和RStockRelation中拥有最终数据。我还有其他方法可以解决此问题吗?>

public类StockRelation扩展了项目{@Relation(parentColumn =“ mpc”,entityColumn =“ itempc”,entity = Location.class)public List locationList; } public ...

java android android-sqlite android-room
1个回答
0
投票

据我所知,您有两个表(实体),通常,您希望在不同的字段上从第一个表到第二个表应用两个左连接-以便使第一个对象与两个不同的位置列表相关联(但请使用Room-关系注释,而不是左连接)。

© www.soinside.com 2019 - 2024. All rights reserved.