i think ther second order by in hibernate sql is no need.
but why hibernate can gernate it?
Hibernate version:2.1.8
Mapping documents:
Code between sessionFactory.openSession() and session.close():
StringBuffer hqlSB = new StringBuffer("from SysRole sr where 1 = 1 ");
hqlSB.append(" order by sr.roleid ");
Full stack trace of any exception that occurs:
WARN : 2005-04-10 00:10:48,022: JDBCExceptionReporter[line:57}:
ERROR: 2005-04-10 00:10:48,022: JDBCExceptionReporter[line:58}: [ISQL Error: -104, SQLState: 42601BM][CLI Driver][DB2/NT] SQL0104N An unexpected token "order" was found following "srole0_ where (1=1 )". Expected tokens may include: "GROUP". SQLSTATE=42601
WARN : 2005-04-10 00:10:48,032: JDBCExceptionReporter[line:57}: SQL Error: -104, SQLState: 42601
ERROR: 2005-04-10 00:10:48,032: JDBCExceptionReporter[line:58}: [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "order" was found following "srole0_ where (1=1 )". Expected tokens may include: "GROUP". SQLSTATE=42601
opmanager:net.sf.hibernate.exception.SQLGrammarException: Could not execute query
Name and version of the database you are using:db2 7.2
The generated SQL (show_sql=true):
select * from ( select rownumber() over(order by sysrole0_.ROLEID) as rownumber_, sysrole0_.ROLEID as ROLEID, sysrole0_.ROLEDESC as ROLEDESC, sysrole0_.PARENT as PARENT from SYSROLE sysrole0_ where (1=1 ) order by sysrole0_.ROLEID ) as temp_ where rownumber_ <= ?
Debug level Hibernate log excerpt:
查询出错!: : [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "order" was found following "srole0_ where (1=1 )". Expected tokens may include: "GROUP". SQLSTATE=42601
wraps: [COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "order" was found following "srole0_ where (1=1 )". Expected tokens may include: "GROUP". SQLSTATE=42601
]
|