如何设置Id字段并通过JPA在GAE数据存储区中查询它

时间:2012-02-14 13:20:53

标签: google-app-engine jpa google-cloud-datastore

我想设置类型为Long的Id字段。但是,当我查询它时,我得到了这个例外:

Cannot access field id on type

这是我对此查询的注释

@NamedQuery(name = Q.User.FindById, query = "SELECT u FROM User u WHERE u.id = :id") })

堆栈跟踪:

org.datanucleus.exceptions.NucleusUserException: Cannot access field id on type com.j.model.User
    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)

我一直在为此寻找,有些人建议使用Key和getname。 quiote混淆,我该如何解决?

感谢。

0 个答案:

没有答案