数据库是db2 9.7 hibernate4 点击分页上一页或首页没问题,但点击下一页或最后一页就报错。
Hibernate: select tsuserstb0_.USERID as USERID1_1_, tsuserstb0_.CREASTAF as CREASTAF2_1_, tsuserstb0_.CREATIME as CREATIME3_1_, tsuserstb0_.LOCORGNO as LOCORGNO4_1_, tsuserstb0_.PWDMODIFYTIME as PWDMODIF5_1_, tsuserstb0_.REMARK01 as REMARK6_1_, tsuserstb0_.REMARK02 as REMARK7_1_, tsuserstb0_.STAORGNO as STAORGNO8_1_, tsuserstb0_.UPDASTAF as UPDASTAF9_1_, tsuserstb0_.UPDATIME as UPDATIM10_1_, tsuserstb0_.USERNAME as USERNAM11_1_, tsuserstb0_.USERPWD as USERPWD12_1_, tsuserstb0_.USERSTATE as USERSTA13_1_ from TS_USERSTB tsuserstb0_ fetch first 10 rows only
Hibernate: select count(*) as col_0_0_ from TS_USERSTB tsuserstb0_我测试最新版本是好的,你升级到最新版本druid-1.0.8吧
http://repo1.maven.org/maven2/com/alibaba/druid/1.0.18/
<!--druid--><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.0.18</version></dependency>我已经用1.0.18了@wenshao
这是我的service
@Override
publicDatagriddatagrid(Userstbuserstb){
Datagriddg=newDatagrid();
Stringhql="fromTsUserstbt";
StringtotalHql="selectcount(*)"+hql;
List<TsUserstb>ltu=tsUserstbDao.find(hql,userstb.getPage(),userstb.getRows());
List<Userstb>lu=newArrayList<Userstb>();
if(ltu!=null&<u.size()>0){
for(TsUserstbt:ltu){
Userstbu=newUserstb();
BeanUtils.copyProperties(t,u);
lu.add(u);
}
}
dg.setTotal(tsUserstbDao.count(totalHql));
dg.setRows(lu);
returndg;
}
这是dao
publicList<T>find(Stringhql,intpage,introws){
Queryq=this.getCurrentSession().createQuery(hql);
returnq.setFirstResult((page-1)*rows).setMaxResults(rows).list();
}
over(orderbyorderofinner2_)这个语法比较奇怪。
不过这个应该只是logerror,不影响运行吧。
很奇怪com.alibaba.druid.sql.parser.ParserException:syntaxerror,errorin:'ascfetchfirst20rowsonly',expectFETCH,actualFETCHfetch嗯,运行是不影响的。但这个错误看起来很难过。我把这个语句单独在db2上执行没有报错的。看起来确实很奇怪@wenshao
Hibernate:selecttsuserstb0_.USERIDasUSERID1_1_,tsuserstb0_.CREASTAFasCREASTAF2_1_,tsuserstb0_.CREATIMEasCREATIME3_1_,tsuserstb0_.LOCORGNOasLOCORGNO4_1_,tsuserstb0_.PWDMODIFYTIMEasPWDMODIF5_1_,tsuserstb0_.REMARK01asREMARK6_1_,tsuserstb0_.REMARK02asREMARK7_1_,tsuserstb0_.STAORGNOasSTAORGNO8_1_,tsuserstb0_.UPDASTAFasUPDASTAF9_1_,tsuserstb0_.UPDATIMEasUPDATIM10_1_,tsuserstb0_.USERNAMEasUSERNAM11_1_,tsuserstb0_.USERPWDasUSERPWD12_1_,tsuserstb0_.USERSTATEasUSERSTA13_1_fromTS_USERSTBtsuserstb0_orderbytsuserstb0_.USERIDascfetchfirst20rowsonly
[com.alibaba.druid.filter.stat.StatFilter]mergesqlerror,dbTypedb2,sql:
selecttsuserstb0_.USERIDasUSERID1_1_,tsuserstb0_.CREASTAFasCREASTAF2_1_,tsuserstb0_.CREATIMEasCREATIME3_1_,tsuserstb0_.LOCORGNOasLOCORGNO4_1_,tsuserstb0_.PWDMODIFYTIMEasPWDMODIF5_1_,tsuserstb0_.REMARK01asREMARK6_1_,tsuserstb0_.REMARK02asREMARK7_1_,tsuserstb0_.STAORGNOasSTAORGNO8_1_,tsuserstb0_.UPDASTAFasUPDASTAF9_1_,tsuserstb0_.UPDATIMEasUPDATIM10_1_,tsuserstb0_.USERNAMEasUSERNAM11_1_,tsuserstb0_.USERPWDasUSERPWD12_1_,tsuserstb0_.USERSTATEasUSERSTA13_1_fromTS_USERSTBtsuserstb0_orderbytsuserstb0_.USERIDascfetchfirst20rowsonly
com.alibaba.druid.sql.parser.ParserException:syntaxerror,errorin:'ascfetchfirst20rowsonly',expectFETCH,actualFETCHfetch
atcom.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:232)
atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:407)
atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:145)
atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:140)
atcom.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:53)
atcom.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145)
atcom.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:630)
atcom.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:305)
atcom.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124)
atcom.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448)
atcom.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
atcom.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:331)
atorg.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:159)
atorg.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:183)
atorg.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:157)
atorg.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1881)
atorg.hibernate.loader.Loader.executeQueryStatement(Loader.java:1858)
atorg.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
atorg.hibernate.loader.Loader.doQuery(Loader.java:906)
atorg.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348)
atorg.hibernate.loader.Loader.doList(Loader.java:2550)
atorg.hibernate.loader.Loader.doList(Loader.java:2536)
atorg.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2366)
atorg.hibernate.loader.Loader.list(Loader.java:2361)
atorg.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:495)
atorg.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:357)
atorg.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:198)
atorg.hibernate.internal.SessionImpl.list(SessionImpl.java:1230)
atorg.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
athx.dao.base.Impl.BaseDaoImpl.find(BaseDaoImpl.java:127)
athx.service.sysmanage.Impl.TsUserstbServiceImpl.datagrid(TsUserstbServiceImpl.java:81)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
atjava.lang.reflect.Method.invoke(Method.java:597)
atorg.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
atorg.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
atorg.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
atorg.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
atorg.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
atorg.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
atcom.sun.proxy.$Proxy22.datagrid(UnknownSource)
athx.action.TsUserstbAction.datagrid(TsUserstbAction.java:83)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
atjava.lang.reflect.Method.invoke(Method.java:597)
atognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:891)
atognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1293)
atognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
atcom.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)
atcom.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)
atognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)
atognl.ASTMethod.getValueBody(ASTMethod.java:90)
atognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
atognl.SimpleNode.getValue(SimpleNode.java:258)
atognl.Ognl.getValue(Ognl.java:494)
atognl.Ognl.getValue(Ognl.java:458)
atcom.opensymphony.xwork2.ognl.OgnlUtil$2.execute(OgnlUtil.java:309)
atcom.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:340)
atcom.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:307)
atcom.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:423)
atcom.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:287)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:250)
atorg.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
atorg.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)
atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atcom.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
atorg.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
atorg.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
atorg.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
atorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
atorg.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
atorg.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
atjava.lang.Thread.run(Thread.java:662)
Hibernate:selectcount(*)ascol_0_0_fromTS_USERSTBtsuserstb0_
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。