oracle中分页问题(带有order by)
软件环境:
struts+hibernate
eclipse
oracle
配置文件:
sql = "FROM TVoyage WHERE STATUE between '2' and '4' ORDER BY ARRIVE_DATE DESC";
q = session.createQuery(sql);
q.setFirstResult((np - 1) * newspagecount);
q.setMaxResults(newspagecount);
it = q.iterate();
错误提示信息:
Hibernate: select * from ( select tvoyage0_.VOYAGEKEY as x0_0_, tvoyage0_.VESSEL
ENG as x1_0_, tvoyage0_.VESSELCHN as x2_0_, tvoyage0_.ARRIVE_DATE as x3_0_, tvoy
age0_.REGION as x4_0_, tvoyage0_.I_VOYAGE as x5_0_, tvoyage0_.E_VOYAGE as x6_0_,
tvoyage0_.TO_PORT_CHN as x7_0_, tvoyage0_.I_E as x8_0_, tvoyage0_.CUSTOM_BH as
x9_0_, tvoyage0_.WZH as x10_0_, tvoyage0_.YARDMAN as x11_0_, tvoyage0_.WQ_NAME a
s x12_0_, tvoyage0_.SHIPCODE as x13_0_ from T_VOYAGE tvoyage0_ where (STATUE bet
ween '2' and '4' ) order by ARRIVE_DATE DESC ) where rownum <= ?
WARN (JDBCExceptionReporter.java:57) - SQL Error: 907, SQLState: 42000
ERROR (JDBCExceptionReporter.java:5 - ORA-00907: 缺少右括号
WARN (JDBCExceptionReporter.java:57) - SQL Error: 907, SQLState: 42000
ERROR (JDBCExceptionReporter.java:5 - ORA-00907: 缺少右括号
你的分析:
如果把order by 去掉的话则就不会出错,在sql server中没有遇到类似的问题。看到hbiernate的show sql: from T_VOYAGE tvoyage0_ where (STATUE between '2' and '4' ) order by ARRIVE_DATE DESC ) where rownum <= ?
hibernate中自动把后面的where放到了order by 后面了。请问你们遇到这样的问题如何解决的阿??????