spring data - Extra quotes being added to @Query -


i have following json structure:

{   "communication": {       "office": {         "email": "test@example.com"       },       "private": {         "email": "test2@example.com"       },   } } 

i want query dynamically email based on type e.g. office or private. when use following command:

@query(value = "{ 'communication.?0.email' : ?1 }") object findbyemail(string type, string email); 

the

'communication.?0.email' 

is converted to

'communication."office".email' 

and mongo didn't find entry. how can avoid quotes before , after office?

simple answer spring mongo doesn't supports looking for. why not passing parameter rather below.

@query(value = "{ 'communication.?0.email' : ?1 }") object findbyemail(string type, string email);

where email value should

type= "communication." + type + ".email" 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -