为什么使用DBFlow不多介绍, 还有其gradle配置的百度很多资料, 但极少提及如何进行生产的应用,比如写一些or/and一起用的复杂的查询条件, 即使Google也很少查得到, 即使查到的也是低版本的应用,在4.0以上编译有问题.
现在4.0+已经改为用OperatorGroup来描述查询条件了, 如下例子:
OperatorGroup op=OperatorGroup.clause(OperatorGroup.clause()
.and(CombMaster_Table.status.eq(CombMaster.NoteStatus.ns_Submitted))
.and(CombMaster_Table.createBy.eq("user1")))
.or(OperatorGroup.clause().and(CombMaster_Table.status.eq(CombMaster.NoteStatus.ns_Confirmed))
.and(CombMaster_Table.createBy.eq("user2")));
System.out.println(SQLite.select().from(CombMaster.class)
.where(op).getQuery());
出来的Sql为:I/System.out: SELECT * FROM `CombMaster` WHERE ((`status`=1 AND `createBy`='user1') OR (`status`=2 AND `createBy`='user2'))