Spring Data MongoDB - Criteria API OrOperator is not working properly

前端 未结 2 1098
南笙
南笙 2021-02-05 08:21

I\'m facing Spring Data MongoDB Criteria API orOperator problem.

Here\'s query result for irregular verbs: (Terminal output)



        
2条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 08:41

    We need explicitly specify a new criteria with OR condition - try with below example

    Criteria criteria = Criteria.where("field1").is(val1).
                    .andOperator(new Criteria().orOperator(Criteria.where("field2").is(filterVal),
                            Criteria.where("field3").is(filterVal)));
    

提交回复
热议问题