Spring Data MongoDB - Criteria API OrOperator is not working properly

前端 未结 2 1100
南笙
南笙 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)));
    
    0 讨论(0)
  • 2021-02-05 08:49

    As far as I remember in order to use orOperator you should do:

    Query query = new Query(new Criteria().orOperator(criteriaV1,criteriaV2));
    0 讨论(0)
提交回复
热议问题