首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

hibernate 查询报错QuerySyntaxException解决方法

2012-06-08 
hibernate 查询报错QuerySyntaxExceptionHQLhql select teb from A teb,B tt where teb.state1 and

hibernate 查询报错QuerySyntaxException
HQL
hql = " select teb from A teb,B tt where teb.state='1' and (teb.startdate>=? || teb.enddate<=?) and teb.templateID=tt.templateId

错误信息 
 org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: ||
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: || near line 1, column 146 [ select teb from A teb,B tt where teb.state='1' and (teb.startdate>=? || teb.enddate<=?) and teb.templateID=tt.templateId ]
Caused by: line 1:146: unexpected token: ||

请问到底怎么回事。。。||不能用?可是在另外一个地方也是写的一样的语句就可以 实在郁闷~这句HQL语句我改成SQL放在PL/SQL里面运行也是不行的.不知道到底哪里有问题~



[解决办法]
|| 换成 or
[解决办法]
hibernate最终还是会换成sql语句去执行的、只不过他帮你写了对应的sql语句、

楼主学java学入迷了啊、
[解决办法]
楼上正解,||是java的语法,or才是数据库语法
[解决办法]
呵呵.楼主要注意了哈.

热点排行