Skip to content
Advertisement

Spring MongoDB Criteria: How to check that the List exists and contains object with specific value?

How to check that the List<Object> exists and contains an object of class whose partnerRole field value is equal to "CREATOR" and companyId field value is equals to "123"?

Document class:

JavaScript

My method for generating a List of Criteria. But that won’t work because I’m referring to partners as if it were a PartnerDocument object, but partners is actually a List<PartnerDocument>.

JavaScript

Advertisement

Answer

There is a mistake in your second criteria.

JavaScript

You are checking companyId against partnerRole.

It should be

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement