Hibernate 只进结果集不支持请求的操作 Hql

[size=medium][ERROR] 2013-01-21 13:44:34:990 org.hibernate.util.JDBCExceptionReporter:78 - [只进结果集不支持请求的操作。]
[ERROR] 2013-01-21 13:44:35:124 com.opensymphony.xwork2.util.logging.commons.CommonsLogger:38 - [Hibernate operation: could not execute query; uncategorized SQLException for SQL [select item0_.c_id as c1_0_, item0_.c_address as c2_0_, item0_.c_batchId as c3_0_, item0_.c_bmpeople as c4_0_, item0_.c_createDate as c5_0_, item0_.c_fromAge as c6_0_, item0_.c_limit as c7_0_, item0_.c_name as c8_0_, item0_.c_remark as c9_0_, item0_.c_sktime as c10_0_, item0_.c_status as c11_0_, item0_.c_teacherRemark as c12_0_, item0_.c_toAge as c13_0_ from TRT_ITEM item0_ order by item0_.c_createDate desc]; SQL state [null]; error code [0]; 只进结果集不支持请求的操作。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作。]
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select item0_.c_id as c1_0_, item0_.c_address as c2_0_, item0_.c_batchId as c3_0_, item0_.c_bmpeople as c4_0_, item0_.c_createDate as c5_0_, item0_.c_fromAge as c6_0_, item0_.c_limit as c7_0_, item0_.c_name as c8_0_, item0_.c_remark as c9_0_, item0_.c_sktime as c10_0_, item0_.c_status as c11_0_, item0_.c_teacherRemark as c12_0_, item0_.c_toAge as c13_0_ from TRT_ITEM item0_ order by item0_.c_createDate desc]; SQL state [null]; error code [0]; 只进结果集不支持请求的操作。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作。
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:425)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:410)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
at com.trt.dev.helper.HqlQueryHelper.findForPage(HqlQueryHelper.java:41)
at com.trt.dev.action.ItemAction.searchItemForPage(ItemAction.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)[/size]

[color=red]
[size=large]原因是:数据库中没有数据导致的,分页时要设置一下
解决方法:
修改框架的 方法 :
q.setFirstResult((page.getCurrentPage()-1)*page.getPageSize());
改成
q.setFirstResult((page.getCurrentPage()-1)*page.getPageSize()+1);
要确保开始记录数 不能为0[/size][/color]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值