org.springframework.data.mongodb.InvalidMongoDbApiUsageException: Due to limitations of the com.mongodb.BasicDBObject, you can't add a second '$or' expression specified as '$or : [ { “field1” : “value1”}, {“field1” : “value2”}]'. Criteria already contains '$or : [ { “field2” : “value3”} , { “field2” : “value4”}]'.

Stack Overflow | Dikshit Luthra | 7 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Failing to add a second '$or' expression

    Stack Overflow | 7 months ago | Dikshit Luthra
    org.springframework.data.mongodb.InvalidMongoDbApiUsageException: Due to limitations of the com.mongodb.BasicDBObject, you can't add a second '$or' expression specified as '$or : [ { “field1” : “value1”}, {“field1” : “value2”}]'. Criteria already contains '$or : [ { “field2” : “value3”} , { “field2” : “value4”}]'.

    Root Cause Analysis

    1. org.springframework.data.mongodb.InvalidMongoDbApiUsageException

      Due to limitations of the com.mongodb.BasicDBObject, you can't add a second '$or' expression specified as '$or : [ { “field1” : “value1”}, {“field1” : “value2”}]'. Criteria already contains '$or : [ { “field2” : “value3”} , { “field2” : “value4”}]'.

      at org.springframework.data.mongodb.core.query.Criteria.setValue()
    2. Spring Data MongoDB - Core
      Criteria.andOperator
      1. org.springframework.data.mongodb.core.query.Criteria.setValue(Criteria.java:640)
      2. org.springframework.data.mongodb.core.query.Criteria.getCriteriaObject(Criteria.java:573)
      3. org.springframework.data.mongodb.core.query.Criteria.createCriteriaList(Criteria.java:630)
      4. org.springframework.data.mongodb.core.query.Criteria.andOperator(Criteria.java:539)
      4 frames