Java NucleusUserException:无法访问扩展映射超类的实体上的字段
在查询我的google数据存储实例时,我遇到了一个Java NucleusUserException:无法访问扩展映射超类的实体上的字段,java,jpa,google-cloud-datastore,datanucleus,Java,Jpa,Google Cloud Datastore,Datanucleus,在查询我的google数据存储实例时,我遇到了一个nucleuserexception。我正在查询扩展它的类上的MappedSuperclass上存在的字段。下面是我的抽象类,其中包含我感兴趣的字段: @Entity @MappedSuperclass @JsonIgnoreProperties({ "password" }) public abstract class AbstractUser implements User { @Persistent protected String
nucleuserexception
。我正在查询扩展它的类上的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();
失败的查询如下所示:
@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数据存储的新手。我试图按照概述的教程进行学习,但是我很可能错过了一些东西。请让我知道额外的信息是必要的
更新:如果我将字段名更改为
email
以及getter、setter和query,它会工作……为什么?那里使用的GAE和低级DataNucleus库版本太旧,不受支持。使用GAE JPA插件v2.x作为minimum@DataNucleus谢谢你让我知道。