1、package com.bysj.vo;import java.util.ArrayList;import java.util.List;public class PageBean int totalRows,totalPages,currentPage,pageSize;SuppressWarnings(“rawtypes“)List data=new ArrayList();public int getTotalRows() return totalRows;public void setTotalRows(int totalRows) this.totalRows = totalRows
2、;public int getTotalPages() return totalRows % pageSize = 0 ? totalRows / pageSize : totalRows/ pageSize + 1;/(int) Math.ceil(totalRows/pageSize);/totalPages;public void setTotalPages(int totalPages) this.totalPages = totalPages;public int getCurrentPage() return currentPage;public void setCurrentPa
3、ge(int currentPage) this.currentPage = currentPage;public int getPageSize() return pageSize;public void setPageSize(int pageSize) this.pageSize = pageSize;SuppressWarnings(“rawtypes“)public List getData() return data;SuppressWarnings(“rawtypes“)public void setData(List data) this.data = data;package
4、 com.bysj.dao;import java.io.Serializable;import java.util.List;import com.bysj.vo.PageBean;public interface IGenericDao public void create(T entity);public T findById(ID id);public void delete(T entity);public void update(T entity);public List findAll();public List findByObject(String hql,Object pa
5、rams);public PageBean findByPageBean(final String hql,final Object params,final int currentpage,final int pageSize);public PageBean findByPageBean(final String hql, final int currentpage, final int pageSize);public void bulkUpdate(final String bulk, Object params);public Integer countByObject(final
6、String hql,final Object param);public List find(String hql);package com.bysj.dao.impl;import java.io.Serializable;import java.lang.reflect.ParameterizedType;import java.sql.SQLException;import java.util.List;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Sess
7、ion;import org.springframework.orm.hibernate3.HibernateCallback;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import com.bysj.dao.IGenericDao;import com.bysj.vo.PageBean;public abstract class AGenericHibernateDao extends HibernateDaoSupport implements IGenericDao Class persis
8、tentClass;public Class getPersistentClass() return persistentClass;public void setPersistentClass(Class persistentClass) this.persistentClass = persistentClass;SuppressWarnings(“unchecked“)public AGenericHibernateDao()/动态代理获得相应的实体对象this.persistentClass=(Class)(ParameterizedType) getClass().getGeneri
9、cSuperclass().getActualTypeArguments()0;System.out.println(“ageneric:“+this.getPersistentClass();/* 保存对象到数据库*/public void create(T entity) / TODO Auto-generated method stubthis.getHibernateTemplate().save(entity);/* 通过 id 查询*/public T findById(ID id) / TODO Auto-generated method stubreturn this.getH
10、ibernateTemplate().get(persistentClass, id);/* 通过 id 删除对象*/public void delete(T entity) / TODO Auto-generated method stubthis.getHibernateTemplate().delete(entity);/* 更新操作*/public void update(T entity) / TODO Auto-generated method stubthis.getHibernateTemplate().update(entity);/* return List* 获得全部数据
11、,并存到 List 中*/public List findAll() / TODO Auto-generated method stubreturn this.getHibernateTemplate().loadAll(persistentClass);/* return List* 按条件查询,并存到 List 中*/SuppressWarnings(“unchecked“)public List findByObject(String hql, Object params) / TODO Auto-generated method stubreturn this.getHibernate
12、Template().find(hql, params);/* return PageBean * 按条件查询带分页信息的数据*/public PageBean findByPageBean(final String hql, final Object params,final int currentpage, final int pageSize) / TODO Auto-generated method stubreturn this.getHibernateTemplate().execute(new HibernateCallback() public PageBean doInHib
13、ernate(Session arg0)throws HibernateException, SQLException / TODO Auto-generated method stubPageBean bean=new PageBean();Query qu=arg0.createQuery(hql);for(int i=0;i() public PageBean doInHibernate(Session arg0)throws HibernateException, SQLException / TODO Auto-generated method stubPageBean bean=n
14、ew PageBean();Query qu=arg0.createQuery(hql);qu.setFirstResult(currentpage-1)*pageSize);qu.setMaxResults(pageSize);bean.setData(qu.list();qu=arg0.createQuery(“select count(*) “+hql.substring(hql.toLowerCase().indexOf(“from“);bean.setTotalRows(Integer.parseInt(qu.uniqueResult().toString();bean.setCur
15、rentPage(currentpage);bean.setPageSize(pageSize);return bean;);public void bulkUpdate(String bulk, Object params) / TODO Auto-generated method stubpublic Integer countByObject(String hql, Object param) / TODO Auto-generated method stubreturn null;SuppressWarnings(“unchecked“)public List find(String
16、hql) / TODO Auto-generated method stubreturn this.getHibernateTemplate().find(hql);无标题 文档/加 载 函数window.onload = function()document.getElementById(“fll_mym18“).onmouseover = fll_xldisplay;document.getElementById(“fll_mym18“).onmouseout = fll_xlhadden;document.getElementById(“fll_xiala“).onmouseover =
17、 fll_xldisplay;document.getElementById(“fll_xiala“).onmouseout = fll_xlhadden;document.getElementById(“fll_sousuo“).onfocus = fll_ssfocus;function tij()/alert(“456“);var su=document.getElementById(“form8“);su.submit();function countchange(obj)if(isNaN(parseInt(obj.value) | obj.value曼领小区业主登录员工登录主页业主留言业主投诉物资申请维修申请查看账单查看车位查看房产小区业务推荐物美超市新概念理发亮洁洗车房冥想书屋塞恩体育用品欣欣网吧小天津饭庄家具装修快递二手数交易业主评论记录用户评论内容评论日期ID:$mes.mid $mes.mcoutent $mes.mtime 请选择:第$i $i 页总共:$sessionScope.messagepb.totalRows 条记录