Hibernate查询错误

时间:2012-06-27 07:36:46

标签: java hibernate

<query name="getStudyTasksByParticipantId">
            from StudyTask st 
            join (select max(lastUpdatedDate)as lastUpdatedDate, study, clinicalStudyRegistration from
                     StudyTask where clinicalStudyRegistration.participant.id in (:participantIds) 
                     group by study, clinicalStudyRegistration ) lst 
            where st.lastUpdatedDate = lst.lastUpdatedDate 
            order by st.lastUpdatedDate desc

        </query>

当我运行此查询时,它会出现unexpected token: ( at line 3 col 30之类的错误。

此查询有什么问题

1 个答案:

答案 0 :(得分:1)

查询无效HQL。 The documentation说:

  

请注意,HQL子查询只能在select或where中出现   条款。

只能通过两个实体之间的关联来完成连接。