2012-06-27 171 views
0
<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休眠查询错误

此查询有什么问题

+0

什么是“line 3 col 30”? –

+0

你不需要在participantIds的括号内,尽管如果它导致错误是很奇怪的。它告诉你的错误是与max(。之间是否有空格)和'as'之间的差异? – Woody

回答

1

该查询不是有效的HQL。 The documentation说:

注意,HQL自查询只能出现在select或者where子句 。

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

+0

我可以使用内部连接吗 – user1484857

+0

什么和什么是连接?子查询只能出现在select或where子句中。不在from子句中。 –