在我的 GAE 项目中,我从 JPA 1.0 开始,这段代码运行良好:
Query query = em.createQuery("SELECT FROM MyImage " +
"WHERE m_Email = :email " +
"And m_Password = :password ", MyImage.class);
query.setParameter("email", email);
query.setParameter("password", password);
但是现在我使用 JPA 2.0 我得到了:
FROM clause of query has class util.MyImage but no alias
org.datanucleus.store.query.QueryCompilerSyntaxException: FROM clause of query has class util.MyImage but no alias
at org.datanucleus.query.compiler.JavaQueryCompiler.compileFrom(JavaQueryCompiler.java:233)
at org.datanucleus.query.compiler.JPQLCompiler.compile(JPQLCompiler.java:79)
at org.datanucleus.store.query.AbstractJPQLQuery.compileInternal(AbstractJPQLQuery.java:269)
at org.datanucleus.store.query.Query.setImplicitParameter(Query.java:825)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:458)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:57)
at dataBase.DataBase.getMyImageFromDB(DataBase.java:173)
我设法让它与 CriteriaQuery 一起工作,但代码不可读且有点混乱。
知道如何解决此异常吗?