您好,欢迎光临本网站![请登录][注册会员]  
文件名称: ssh2_base_prj_基本模板.rar
  所属分类: Java
  开发工具:
  文件大小: 177kb
  下载次数: 1
  上传时间: 2011-09-21
  提 供 者: weny****
 详细说明: 新版本的ssh2框架 package com.base.dao; import java.io.Serializable; import java.lang.reflect.ParameterizedType; import java.util.Collection; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.LockMode; import org.springframework.dao.DataAccessException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @SuppressWarnings("unchecked") public class GenericDao exte nds HibernateDaoSupport implements IGenericDao { private Log logger = LogFactory.getLog(getClass()); protected Class entityClass; public GenericDao() { } protected Class getEntityClass() { if (entityClass == null) { entityClass = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; logger.debug("T class = " + entityClass.getName()); } return entityClass; } public void saveOrUpdate(T t) throws DataAccessException { this.getHibernateTemplate().saveOrUpdate(t); } public T load(ID id) throws DataAccessException { T load = (T) getHibernateTemplate().load(getEntityClass(), id); return load; } public T get(ID id) throws DataAccessException { T load = (T) getHibernateTemplate().get(getEntityClass(), id); return load; } public boolean contains(T t) throws DataAccessException { return getHibernateTemplate().contains(t); } public void delete(T t, LockMode lockMode) throws DataAccessException { getHibernateTemplate().delete(t, lockMode); } public void delete(T t) throws DataAccessException { getHibernateTemplate().delete(t); } public void deleteAll(Collection entities) throws DataAccessException { getHibernateTemplate().deleteAll(entities); } public List find(String queryString, Object value) throws DataAccessException { List find = (List) getHibernateTemplate().find(queryString, value); return find; } public List find(String queryString, Object[] values) throws DataAccessException { List find = (List) getHibernateTemplate().find(queryString, values); return find; } public List find(String queryString) throws DataAccessException { return (List) getHibernateTemplate().find(queryString); } public void refresh(T t, LockMode lockMode) throws DataAccessException { getHibernateTemplate().refresh(t, lockMode); } public void refresh(T t) throws DataAccessException { getHibernateTemplate().refresh(t); } public Serializable save(T t) throws DataAccessException { return getHibernateTemplate().save(t); } public void saveOrUpdateAll(Collection entities) throws DataAccessException { getHibernateTemplate().saveOrUpdateAll(entities); } public void update(T t, LockMode lockMode) throws DataAccessException { getHibernateTemplate().update(t, lockMode); } public void update(T t) throws DataAccessException { getHibernateTemplate().update(t); } public List list() throws DataAccessException { return getHibernateTemplate().loadAll(getEntityClass()); } public List findByNamedQuery(String queryName) throws DataAccessException { return getHibernateTemplate().findByNamedQuery(queryName); } public List findByNamedQuery(String queryName, Object value) throws DataAccessException { return getHibernateTemplate().findByNamedQuery(queryName, value); } public List findByNamedQuery(String queryName, Object[] values) throws DataAccessException { return getHibernateTemplate().findByNamedQuery(queryName, values); } /* public PaginationSupport findPageByCriteria(final DetachedCriteria detachedCriteria, final int pageSize, final int startIndex) { return (PaginationSupport) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Criteria criteria = detachedCriteria.getExecutableCriteria(session); int totalCount = ((Integer) criteria.setProjection(Projections.rowCount()).uniqueResult()).intValue(); criteria.setProjection(null); List items = criteria.setFirstResult(startIndex).setMaxResults(pageSize).list(); PaginationSupport ps = new PaginationSupport(items, totalCount, pageSize, startIndex); return ps; } }, true); } public PaginationSupport findPageByQuery(final String hql, final String countHql, final int pageSize, final int startIndex) { return (PaginationSupport) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { int totalCount = ((Integer) session.createQuery(countHql).iterate().next()).intValue(); Query query = session.createQuery(hql); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List items = query.list(); PaginationSupport ps = new PaginationSupport(items, totalCount, pageSize, startIndex); return ps; } }, true); } */ } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: java
 输入关键字,在本站1000多万海量源码库中尽情搜索: