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

HQL异常

2012-01-31 
HQL错误语句如下:Java codefrom CustomerGroup group where 11and ( group.oper 0or group.oper s

HQL错误
语句如下:

Java code
from CustomerGroup group where 1=1  and ( group.oper = '0'  or group.oper = 'super' ) order by group.createTime DESC


报错:
Java code
org.hibernate.hql.ast.QuerySyntaxException: expecting "by", found '.' near line 1, column 84 [ from com.XXXXXXXXX.hibernate.persistent.CustomerGroup group where 1=1  and ( group.oper = '0'  or group.oper = 'super' )  order by group.createTime DESC]    at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)    at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)    at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)    at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)    at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)


我试着把括号里面的group.去掉,语句改为
Java code
from CustomerGroup group where 1=1  and ( oper = '0'  or oper = 'super' ) order by group.createTime DESC

就没问题了,这是什么原因,hibernate怎么处理括号的

[解决办法]
group 是关键字

热点排行