我试图从不同的实体中获取3个表,当我使用eia.carreraHorizontal.kid = eig.carreraHorizontal.kid和eig.carreraHorizontal.kid = hch.carreraHorizontal.kid时,它一直在说我有错误。重复返回很多结果。
这是我的代码:
List<EvaluacionIndividualAnualYGdp> lista;
String jpql = "select DISTINCT new es.valencia.gp.sbch.entity.EvaluacionIndividualAnualYGdp(eia, eig, hch)"
+ " from EvaluacionIndividualAnual eia, EvaluacionIndividualGdp eig, HistoricoCarreraHorizontal hch"
+ " where eia.carreraHorizontal.kid = eig.carreraHorizontal.kid = eig.carreraHorizontal.kid"
+ " ";
//GROUP BY eia ORDER BY eia.carreraHorizontal.empleado.apellido1 ASC, eia
TypedQuery<EvaluacionIndividualAnualYGdp> query = em.createQuery(jpql, EvaluacionIndividualAnualYGdp.class);
lista = query.getResultList();
return lista;
} ```
The error:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: = near line 1, column 302 [select DISTINCT new es.valencia.gp.sbch.entity.EvaluacionIndividualAnualYGdp(eia, eig, hch) from es.valencia.gp.sbch.entity.EvaluacionIndividualAnual eia, es.valencia.gp.sbch.entity.EvaluacionIndividualGdp eig, es.valencia.gp.sbch.entity.HistoricoCarreraHorizontal hch where eia.carreraHorizontal.kid = eig.carreraHorizontal.kid = eig.carreraHorizontal.kid ]
But i'm getting an exception. How i can get those values? Sorry for the question but i'm new.
最佳答案
您应该删除最后一个eig.carreraHorizontal.kid:
eia.carreraHorizontal.kid = eig.carreraHorizontal.kid = eig.carreraHorizontal.kid
应该
eia.carreraHorizontal.kid = eig.carreraHorizontal.kid
比较a = b = b无效。可能应该是a = b和b = c
eia.carreraHorizontal.kid = eig.carreraHorizontal.kid
and eig.carreraHorizontal.kid = hch.carreraHorizontal.kid
而且我不知道在distinct之后的“ new”是否也是错误。