2014년 12월 29일 월요일

spring data mongodb query matching elements in an array

user:(Collection)                                   usernamea userB    

skills:                                             C          Erlang
neededSkills:                                   Erlang, ChicagoBoss C, Erlang, Lisp


I am trying to find a match in this example of user's skills and neededSkills 

having issues using spring data mongodb trying to find a match.

I would like to find all users

where 

#1. a user's skills are needed by users (in collection)

#2. the needed skills of the user match the skills of users (in collection)

Having extreme trouble with this.

Any ideas?

Thanks 

query.addCriteria(Criteria.where("user.skills").in(user.neededSkills));

Criteria subCriteria = Criteria.where("user.neededSkills").in(user.getBasicInfo().getCountry());

query.addCriteria(subCriteria);


댓글 없음:

댓글 쓰기