我正在尝试选择一个包含60-70k元素的实体。我有一对多的关系。我的问题是,当我想选择所有具有语言ID的关键字时,SugarORM会在每个原始查询中选择语言。
//This is my entity
public class Keyword extends SugarRecord {
String key;
Language language;
public Keyword(){
}
}
//This is my query
Iterator<Keyword> keywords = Keyword.findWithQueryAsIterator(Keyword.class,"Select * from Keyword where language = ?", new String[]{String.valueOf(language.getId())});
while(keywords.hasNext()){
String key = keywords.next().getKey();
dictionary.addKeyword(key);
}
return null;
当我执行下面的代码块时,它记录如下内容:
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
07-26 01:54:58.639 8894-8922/com.tll.treeofwords D/SQL Log: SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
07-26 01:54:58.640 8894-8922/com.tll.treeofwords D/SQL Log: SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
07-26 01:54:58.641 8894-8922/com.tll.treeofwords D/SQL Log: SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
07-26 01:54:58.642 8894-8922/com.tll.treeofwords D/SQL Log: SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
07-26 01:54:58.643 8894-8922/com.tll.treeofwords D/SQL Log: SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
SQLiteQuery: SELECT * FROM LANGUAGE WHERE id=? LIMIT 1
我不知道如何一直阻止选择具有ID的语言。我也尝试过findById,Keyword.find方法等,即使我像上面的示例一样编写查询,它们也都无法帮助我解决这个问题。