人们!
我编写代码 JPA/HQL 并运行,但出现错误消息。说:
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Syntax error parsing the query [Select t.disciplina.nomeDisciplina, n.notaFinal From (Select f.notas as notas, sum(f.f1 + f.f2 + f.f3 +f.f4) as soma from Frequencia f group by f.notas) subquery inner join subquery.notas n inner join n.aluno1 a inner join n.turma1 t inner join a.usuario u where u = ?1], line 1, column 54: unexpected token [(].Internal Exception: org.eclipse.persistence.internal.jpa.parsing.jpql.InvalidIdentifierException
我使用子句子查询创建 HQL(query),见下文。
public List<Object[]> getListNotasFrequencia(Usuario u) {
EntityManager em = getEntityManager();
List<Object[]> lista = new Vector<Object[]>();
String query = "Select t.disciplina.nomeDisciplina, n.notaFinal "
+ " From (Select f.notas as notas, sum(f.f1 + f.f2 + f.f3 +f.f4) as soma from Frequencia f group by f.notas) subquery "
+ " inner join subquery.notas n"
+ " inner join n.aluno1 a"
+ " inner join n.turma1 t"
+ " inner join a.usuario u"
+ " where u = ?1";
try {
lista = em.createQuery(query).setParameter(1, u).getResultList();
} finally {
em.close();
}
return lista;
}
我已经多次错误地处理这段代码,但同样的错误消息。
请!您帮助或提示此代码。我开始学习这个 JPA/JPQL。
谢谢!!!