How to read a specific key-value pair from mongorepository

217 Views Asked by At

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.

0

There are 0 best solutions below