0

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.

JEFFRIN JACOB
  • 257
  • 1
  • 6
Srinithi K
  • 81
  • 1
  • 4
  • Check out this https://stackoverflow.com/questions/13927295/how-to-read-a-specific-key-value-pair-from-mongodb-collection – ypdev19 Apr 24 '22 at 22:57
  • I tried out this....In mongo console it works but when I need to implement via sprin-boot mongorepository this query didnt work. – Srinithi K Apr 25 '22 at 09:37

0 Answers0