0
我寫代碼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(查詢),請參閱下面。
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。
謝謝!!!