2012-06-27 185 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子句中。 –