I am writing a cloud endpoint api using JDO to fetch a list of users based on the emailid. I am passing email id as a @Named parameter to the email and adding it to the query filter and i get the error message "Unexpected expression type while parsing query. Variables not supported by GAE (email)"
FYI, gae version is 1.8
@Api (name="MyAppname", version="v1")
public class PersonEndpoint {
public Person validate(@Named("email") String email, @Named("role") String role){
.......
PersistenceManager pm=getPersistenceManager();
Query q = pm.newQuery(Person.class);
q.setFilter(" email == emailParam && role == "+role);
q.declareParameters("String emailParam");
try{
person=(Person)q.execute(email);
}finally{
q.closeAll();
pm.close();
}
return person;
}
}
Any suggestions please?
Here is the Person class
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Person {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String emailId;
@Persistent
private String role;
<getters and setters here>
}
The exception i see when i call the validate API
javax.jdo.JDOFatalUserException: Unexpected expression type while parsing query. Variables not supported by GAE (email)
at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:498)
at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:252)