SQL - Hibernate意外令牌

时间:2015-04-02 11:14:51

标签: mysql sql hibernate

我直接在Mysql数据库中运行下面的查询,它按预期工作:

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]

任何人都知道我错过了什么?

1 个答案:

答案 0 :(得分:0)

在没有select语句的情况下尝试

“来自LocationUpdate lu内部联接(选择imsi,MAX(日期)作为maxdate,来自LocationUpdate group by imsi)grouplu on lu.imsi = grouplu.imsi and lu.date = grouplu.maxdate”