0
我直接在MySQL數據庫中運行下面的查詢,它按預期工作:SQL - Hibernate的意外標記
select lu.* from LocationUpdate lu inner join (select imsi,MAX(date) as maxdate from LocationUpdate group by imsi) grouplu on lu.imsi = grouplu.imsi and lu.date = grouplu.maxdate
在HQL,我只是改變lu.*
到lu
但我得到這個錯誤:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: (near line 1, column 114 [select lu from com.truphone.simmanager.simcard.service.impl.entities.locationupdate.LocationUpdate lu inner join (select imsi,MAX(date) as maxdate from com.truphone.simmanager.simcard.service.impl.entities.locationupdate.LocationUpdate group by imsi) grouplu on lu.imsi = grouplu.imsi and lu.date = grouplu.maxdate]
任何人都知道我錯過了什麼?
我認爲lu必須替換爲LocationUpdate,因爲HQL會視爲enity。只需將'select lu from'替換爲'select LocationUpdate from'並再試一次 – 2015-04-02 11:42:39
這不是解決方案。它可以完成,但Hibernate可以將LocationUpdate轉換爲lu。我在其他情況下也是這樣。儘管感謝您的幫助。 – bsferreira 2015-04-02 12:12:40