嗨,我想使用带有继承的 Sugar ORM。
我的课程:
public class Building extends SugarRecord<Building> {
protected String name;
}
和:
public class Kitchen extends Building{
int value =1;
}
当我保存一些厨房并列出它们时,我只能查询厨房 AS Kitchens,但不能查询 AS Buildings。
我可以以某种方式解决这个问题还是 Sugar ORM 没有这个功能?
记录:
List<Building> buildingsList = Building.listAll(Building.class);
for (Building buidling : buildingsList) {
Log.i("Buildings: ", buidling.toString());
}
List<Kitchen> kitchenList = Kitchen.listAll(Kitchen.class);
for (Kitchen kitchen : kitchenList) {
Log.i("Kitchens: ", kitchen.toString());
}
输出:
//Adding Kitchens,
10-04 13:10:53.212: I/Sugar(12104): Kitchen saved : 1
10-04 13:10:58.058: I/Sugar(12104): Kitchen saved : 2
10-04 13:10:58.455: I/Sugar(12104): Kitchen saved : 3
//Listing Buildings, nothing
10-04 13:11:16.993: D/SQL Log(12104): SQLiteQuery: SELECT * FROM BUILDING
*NONE*
//Listing as Kitchens, here they are:
10-04 13:11:16.993: D/SQL Log(12104): SQLiteQuery: SELECT * FROM KITCHEN
10-04 13:11:16.994: I/Kitchens:(12104): com.adamvarhegyi.clanwars.application.model.Kitchen@103ff5bd
10-04 13:11:16.994: I/Kitchens:(12104): com.adamvarhegyi.clanwars.application.model.Kitchen@354967b2
10-04 13:11:16.994: I/Kitchens:(12104): com.adamvarhegyi.clanwars.application.model.Kitchen@33859303