我尝试查询 3 种类型的产品,但收到此错误:
The SQL statement has not been finished since there are previous operations
still waiting for clauses.
这是代码:
QueryBuilder<Product, UUID> queryBuilder = pDao.queryBuilder();
Where<Transaction, UUID> where = queryBuilder.where();
where.eq("state", Product.State.NEW)
.and()
.eq("type", Product.Type.DIGITAL)
.or() -> I get the error here
.eq("type", Product.Type.PHYSICAL);
最佳答案
The SQL statement has not been finished since there are previous operations still waiting for clauses
嗯。我无法重现这一点,并且 QueryBuilder
内容的测试覆盖率非常好。我添加了 similar test here通过了。
QueryBuilder<Foo, String> qb = dao.queryBuilder();
Where<Foo, String> where = qb.where();
where.eq(Foo.VAL_COLUMN_NAME, foo1.val)
.and()
.eq(Foo.STRING_COLUMN_NAME, foo1.stringField)
.or()
.eq(Foo.STRING_COLUMN_NAME, foo2.stringField);
我认为还有其他事情正在发生。也许正在进行额外的 Where
调用,但这些调用未在您的测试中体现?如果没有,请确保您运行的是 4.48 或 5.0 版本。
您还可以尝试使用带参数的 and(...)
和 or(...)
生成查询:
where.and(where.eq("state", Product.State.NEW),
where.or(where.eq("type", Product.Type.DIGITAL),
where.eq("type", Product.Type.PHYSICAL)));
请参阅docs on QueryBuilder
了解更多。
关于java - 构建查询时出错,显示 "previous operations still waiting for clauses",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39167116/