我试图用 green dao 编写一个查询,但不知道如何准确地说出我想说的话, 我有 3 个属性,我将查询集中在 CardIconType、Type_of_word 和 Type_of_type (糟糕的命名约定,但请不要关注这个) 我想要返回的是 CardIconType 中显示“ORIGINAL”的所有项目和 CardIconType 中显示“USER”的所有项目,但前提是 Type_of_type 为“PRONOUN”且 Type_of_word 为“QUICKS”
我尝试过的
到目前为止我已经尝试过这个
qb.where(addNewCardDao.Properties.CardIconType.eq("ORIGINAL"),
qb.and(addNewCardDao.Properties.Type_of_type.eq("PRONOUNS"),
addNewCardDao.Properties.Type_of_word.eq("QUICKS")));
leaseList = qb.list();
这解决了我问题的一半,它返回“ORIGINAL”的所有对象,其中 Type_of_type 是“PRONOUNS,Type_of_word 是“QUICKS”,我的第一个想法是为 USER 再次执行此操作并加入列表,但我不认为那是最好的方法,所以我尝试了这个
qb.where(addNewCardDao.Properties.CardIconType.eq("SIMPLE"),
qb.or(addNewCardDao.Properties.CardIconType.gt("USER"),
qb.and(addNewCardDao.Properties.Type_of_type.eq("PRONOUNS"),
addNewCardDao.Properties.Type_of_word.ge("QUICKS"))));
leaseList = qb.list();
但是没有人可以帮助我,请让我快乐
最佳答案
使用 QueryBuilder.in()
方法在一个属性中查找多个值。
String[] strings = {"ORIGINAL", "USER"};
qb.where(addNewCardDao.Properties.CardIconType.in(strings),
然后添加额外的限制:
qb.and(addNewCardDao.Properties.Type_of_type.eq("PRONOUNS"),
addNewCardDao.Properties.Type_of_word.eq("QUICKS")));
然后列出它:
leaseList = qb.list();
关于java - green dao 如何使用一次查询四个属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38085675/