2016-08-26 9 views
0

私は製品の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); 

答えて

1

The SQL statement has not been finished since there are previous operations still waiting for clauses

Hrm。私はこれを再現することはできませんし、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を参照してください。