日期:2014-05-17 浏览次数:20770 次
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>