HQL:加入的路径!无法解决财产问题

时间:2016-12-29 03:13:24

标签: java sql hql

我找不到关于如何处理这种情况的任何文件。我一直收到以下错误:

org.hibernate.QueryException: could not resolve property: id_alumno_origen
of: dm.model.tramite.TrasladoInterno
....
antlr.SemanticException: Path expected for join!

我使用以下查询,虽然我找到了一些解决方案,指的是JOIN + ON情况下缺少对字段的引用,但我没有运气:

from pe.edu.innovaschools.dm.model.tramite.TrasladoInterno a
    JOIN  gen_sede b ON b.id = a.id_sede_destino  
    JOIN  aca_grado c ON a.id_grado_destino = c.id   
    WHERE a.tipo = 'INTERPERIODO'   
        AND a.estado IN ('ACEP' , 'PEND')   
        AND a.id_periodo_origen = :PERIODOORIG   
        AND a.id_periodo_destino = :PERIODODEST   
GROUP BY a.id_sede_destino , b.nombre , a.id_grado_destino , c.nombre_ps , a.estado

1 个答案:

答案 0 :(得分:0)

HQL上我更喜欢使用隐式JOIN表示法(更多次显式JOIN会导致错误)。 如果您使用GROUP BY,则必须对SELECT应用投影,请尝试以下操作:

select a.id_sede_destino, b.nombre,
    a.id_grado_destino , c.nombre_ps , a.estado
from pe.edu.innovaschools.dm.model.tramite.TrasladoInterno a,
gen_sede b, 
aca_grado c   
WHERE b.id = a.id_sede_destino 
    AND a.tipo = 'INTERPERIODO'
    AND a.id_grado_destino = c.id
    AND a.estado IN ('ACEP' , 'PEND')   
    AND a.id_periodo_origen = :PERIODOORIG   
    AND a.id_periodo_destino = :PERIODODEST   
GROUP BY a.id_sede_destino, b.nombre,
    a.id_grado_destino , c.nombre_ps , a.estado