日期:2014-05-20  浏览次数:20984 次

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 是关键字