我在查询我的Google数据存储区实例时遇到了NucleusUserException
。我正在查询扩展它的类MappedSuperclass
上存在的字段。这是我的抽象类,包含我感兴趣的字段:
@Entity
@MappedSuperclass
@JsonIgnoreProperties({ "password" })
public abstract class AbstractUser implements User {
@Persistent
protected String emailAddress;
public void setEmailAddress(String email) {
this.emailAddress = email;
}
public String getEmailAddress() {
return this.emailAddress;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long key;
//Other stuff.
}
具体实例如下所示:
@Entity
public class Client extends AbstractUser {
//Things that only clients have.
}
我失败的查询如下所示:
List existingUsersWithEmail = manager
.createQuery(
"SELECT c from Client AS c WHERE c.emailaddress = :mail")
.setParameter("mail", request.getEmailAddress())
.getResultList();
例外是:
Cannot access field emailaddress on type org.workouthound.user.Client
org.datanucleus.exceptions.NucleusUserException: Cannot access field emailaddress on type org.workouthound.user.Client
at org.datanucleus.query.compiler.JavaQueryCompiler.getType(JavaQueryCompiler.java:552)
at org.datanucleus.query.compiler.JavaQueryCompiler.getType(JavaQueryCompiler.java:529)
at org.datanucleus.query.symbol.SymbolTable.getType(SymbolTable.java:118)
at org.datanucleus.query.expression.PrimaryExpression.bind(PrimaryExpression.java:118)
at org.datanucleus.query.expression.DyadicExpression.bind(DyadicExpression.java:85)
at org.datanucleus.query.compiler.JavaQueryCompiler.compileFilter(JavaQueryCompiler.java:299)
at org.datanucleus.query.compiler.JPQLCompiler.compile(JPQLCompiler.java:75)
at org.datanucleus.store.query.AbstractJPQLQuery.compileInternal(AbstractJPQLQuery.java:246)
at org.datanucleus.store.query.Query.setImplicitParameter(Query.java:690)
at org.datanucleus.jpa.JPAQuery.setParameter(JPAQuery.java:428)
at org.workouthound.rest.client.UserResources.emailIsRegistered(UserResources.java:55)
at org.workouthound.rest.client.UserResources.createClient(UserResources.java:33)
我是DataNucleus和Google Data Store的新手。我试图按照here概述的教程,但我很可能错过了一些东西。请告诉我,因为有必要提供更多信息。
更新
如果我将字段名称更改为email
以及getter,setter和query,它的工作原理......为什么?