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