我正在使用 JDO 编写一个云端点 api,以根据 emailid 获取用户列表。我将电子邮件 ID 作为 @Named 参数传递给电子邮件并将其添加到查询过滤器中,我收到错误消息“解析查询时出现意外的表达式类型。GAE(电子邮件)不支持的变量”
仅供参考,gae版本是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;
}
}
请问有什么建议吗?
这是 Person 类
@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>
}
我调用验证 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)