hibernate中用hql查询时程序报错,将hql语句转为sql,在mysql工具查询不报错,这是什么情况,

MySql 码拜 8年前 (2016-02-13) 1367次浏览
hql查询时报语法错误,本人把hql改为sql之后,在mysql工具上查,可以成功查询到记录。问一下高手本人的hql语法哪儿有错,跪求指点,困扰一天了。
下面是hql

select d.taskId, s2.name, d.triggerTime, d.startTime, d.endTime, d.state, d.cycle, d.expectTime 
from SchTaskDetail d, 
	 SchTask s2 
where d.taskId = s2.id  and  d.id in ( 
	select c1.id 
	from SchTaskDetail c1,
		(select t1.taskId,max(t1.updateTime) updateTime 
		 from SchTaskDetail t1 
		 where 1=1  and t1.startTime >= "2015-01-04 12:23:12"  and t1.endTime <= "2016-01-04 12:23:12" 
		 group by t1.taskId) d1 
	where c1.taskId = d1.taskId and c1.updateTime = d1.updateTime )  
order by d.triggerTime asc

这是sql

select 
    d.task_id,
    s2.name,
    d.trigger_time,
    d.start_time,
    d.end_time,
    d.state,
    d.expect_time
from
    etldb.sch_task_detail d,
    etldb.sch_task s2
where
    d.task_id = s2.id
        and d.id in (select 
            c1.id
        from
            etldb.sch_task_detail c1,
            (select 
                t1.task_id, max(t1.update_time) update_time
            from
                etldb.sch_task_detail t1
            where
                1 = 1 and t1.start_time >= "2015-01-04 12:23:12"
                    and t1.end_time <= "2016-01-04 12:23:12"
            group by t1.task_id) d1
        where
            c1.task_id = d1.task_id
                and c1.update_time = d1.update_time)
order by d.trigger_time asc

hibernate程序中报错 :org.hibernate.hql.ast.QuerySyntaxException: unexpected token:

解决方案

5

你贴出来的hql  是sql的语法 而不是hql的语法

15


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明hibernate中用hql查询时程序报错,将hql语句转为sql,在mysql工具查询不报错,这是什么情况,
喜欢 (0)
[1034331897@qq.com]
分享 (0)