Srinithi K
Srinithi K

Reputation: 101

How to read a specific key-value pair from mongorepository

I am storing as an nested objects inside mongodb. My data looks like below:

"test":{
    "serviceNAme01": {
              "name-01": "value",
              "name-02": "value2"
            },
    "serviceName02": {
              "name-01": "value",
              "name-02": "value2"
            },
       }

Using query like Query("{}, {'test.serviceNAme01': ''}") gives nested exception - org.springframework.dao.IncorrectResultSizeDataAccessException: Query { "$java" : Query: {}, Fields: {}, Sort: {} } returned non unique result.] with root cause.

Note - this query returns the expected result in mongo console.

Even using @Query(" {'test.serviceNAme01': ''}") gives empty {}.

How to write query to get specified results inside nested object.

Thanks in advance.

Upvotes: 0

Views: 229

Answers (0)

Related Questions