2012-06-15 50 views
0

我试图执行与别名HQL查询用别名

select **clbs.id as id** 
    from ClaimDO cl, ClaimBillSummaryDO clbs, HospitalDO h 
    where clbs.parentGuidObj.id=cl.id and h.id=cl.hospitalSeq and cl.id= '10721' 

一个HQL查询,我收到以下错误

org.hibernate.QueryException: , expected in SELECT 

但是查询,而不错误运行,如果我删除别名

select **clbs.id** 
    from ClaimDO cl, ClaimBillSummaryDO clbs, HospitalDO h 
where clbs.parentGuidObj.id=cl.id and h.id=cl.hospitalSeq and cl.id= '10721' 

回答

1

为什么你不使用映射来加入你的实体?你不妨使用原生查询来做到这一点。 HQL看起来更像以下内容。我省略了HospitalDO加入,因为它看起来没有意义。

select clbs.id from ClaimDO cl join cl.parentGuidObj clbs where cl.id = :id