SSH 中 Hibernate 分页翻页多次出问题!求解
SSH 分页 我频繁的翻页几次 之后 不知道为什么 就查不出数据了,设断点查看 在代码:
this.getSession().createQuery("select count(ff) from FdPmaterial ff").uniqueResult()
执行的时候断点就直接跳掉了,控制台也没抛错,郁闷,为什么开始翻页的时候没问题,而后来却
查不错数据了! 这是为什么 那位大侠 来帮我解决下
package com.trade.common;import java.util.ArrayList;import java.util.List;public class FdPage { private int totalProperty;// 一共多少条 private int start;// 开始条数 private int limit;// 显示个数 private boolean success = false;// 执行是否成功 private boolean page = true; private List rootList = new ArrayList();// 数据所在 //get set 方法略}
public FdPage GetFdPmaterialPage(FdPage root) { root.setPage(true); int count = Integer.parseInt(this.getSession().createQuery( "select count(ff) from FdPmaterial ff").uniqueResult() .toString()); root.setTotalProperty(count); int first = root.getStart(); int max = root.getLimit(); Query query = this.getSession().createQuery("from FdPmaterial"); query.setFirstResult(first); query.setMaxResults(max); List list = query.list(); if (list != null) { root.setSuccess(true); } root.setRootList(list); return root; }
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"> </property> <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=Trade"> </property> <property name="username" value="sa"></property> <property name="password" value="sa"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>com/trade/entity/datainit/FdProduct.hbm.xml</value> <value>com/trade/entity/datainit/FdProductType.hbm.xml</value> <value>com/trade/entity/datainit/FdProductMaterial.hbm.xml</value> <value>com/trade/entity/datainit/FdPackInfo.hbm.xml</value> <value>com/trade/entity/datainit/FdPmaterial.hbm.xml</value> <value>com/trade/entity/datainit/FdPmasterialColor.hbm.xml</value> </list> </property> </bean>