构建查询时出错 "previous operations still waiting for clauses"
Error building query which says "previous operations still waiting for clauses"
我正在尝试查询 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
。
我正在尝试查询 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
。