`

daoImpl

DAO 
阅读更多

 //删除一个
 public void deleteByInfoId(final String infoId) {
  try {
   this.getHibernateTemplate().execute(new HibernateCallback(){
    public Object doInHibernate(Session session)
    throws HibernateException, SQLException {
     String hql = "delete "+getClazz().getName()+" where infoId = :infoId";
     Query query = session.createQuery(hql);
     query.setParameter("infoId", infoId);
     return query.executeUpdate();
    }
   });
  } catch (org.springframework.dao.DataAccessException e) {
   // TODO Auto-generated catch block
   throw new DataAccessException(e.getMessage(),e);
  }
 }
 ==============================================
 批量删除
 public void deleteExhibitionShowList(final List<String> list) {
  // TODO Auto-generated method stub
  try {
   this.getHibernateTemplate().execute(new HibernateCallback(){
    public Object doInHibernate(Session session)
    throws HibernateException, SQLException {
     String hql = "delete "+getClazz().getName()+" where showId in(:ids)";
     Query query = session.createQuery(hql);
     query.setParameterList("ids", list);
     return query.executeUpdate();
    }
   });
  } catch (org.springframework.dao.DataAccessException e) {
   // TODO Auto-generated catch block
   throw new DataAccessException(e.getMessage(),e);
  }
 }
 //批量更新 日期
 public void update(final List<String> list, final String state) {
  // TODO Auto-generated method stub
  try {
   this.getHibernateTemplate().execute(new HibernateCallback(){
    public Object doInHibernate(Session session)
    throws HibernateException, SQLException {
     String hql = "update "+getClazz().getName()+" set approveStateId = :state where showApplyId in(:ids)";
     Query query = session.createQuery(hql);
     query.setParameter("state", state);
     query.setParameterList("ids", list);
     return query.executeUpdate();
    }
   });
  } catch (org.springframework.dao.DataAccessException e) {
   // TODO Auto-generated catch block
   throw new DataAccessException(e.getMessage(),e);
  }
 }
 //分页查找
 public WebPage getExhibitionShowList(Map map) {
  // TODO Auto-generated method stub
  StringBuffer count = new StringBuffer("select count(*) from "+this.getClazz().getName());
  StringBuffer hql = new StringBuffer("from "+this.getClazz().getName());
  StringBuffer where = new StringBuffer(" where 1=1 ");
  List  params = null;
  int start = -1;
  int limit = 0;
  if(map != null){
   params = new ArrayList();
   if(map.get("exhibitionId") != null && !"".equals(map.get("exhibitionId"))){
    where.append(" and exhibitionId = ? ");
    params.add(map.get("exhibitionId"));
   }
   if(map.get("showName") != null && !"".equals(map.get("showName"))){
    where.append(" and showName like ? ");
    params.add("%"+map.get("showName")+"%");
   }
   if(dateStart!=null && !"".equals(dateStart)) {
    hql.append(" and np.createDate >= ? ");
    Date dateStartd=null;
    try {
     dateStartd=new SimpleDateFormat("yyyy-MM-dd").parse(dateStart);
    } catch (Exception e) {
     // TODO: handle exception
    }
    params.add(dateStartd);
   }
   if(dateEnd!=null && !"".equals(dateEnd)) {
    hql.append(" and np.createDate < ? ");
    Date dateEndd=null;
    try {
     dateEndd=new SimpleDateFormat("yyyy-MM-dd").parse(dateEnd);
    } catch (Exception e) {
     // TODO: handle exception
    }
    Calendar calendar=Calendar.getInstance();
    calendar.clear();
    calendar.setTime(dateEndd);
    calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)+1);//让日期加1
    params.add(calendar.getTime());
   }
   if(map.get("start") != null){
    start = (Integer) map.get("start");
   }
   if(map.get("limit") != null){
    limit = (Integer) map.get("limit");
   }
   
   count.append(where);
   hql.append(where);
   if(this.getOrderMap() == null){
    hql.append(" order by entryDate desc");
   }
   else{
    Map orderMap = this.getOrderMap();
    hql.append(" order by "+orderMap.get("sort")+" "+orderMap.get("dir"));
   }
   
   
  }
  if(params != null){
   return this.findByPage(count.toString(), hql.toString(), params.toArray(), start, limit);
  }
  else{
   return this.findByPage(count.toString(), hql.toString(), null, start, limit);
  }
 }

分享到:
评论

相关推荐

    DAOimpl(删除,查询)代码.pdf

    DAOimpl(删除,查询)代码.pdf

    自动生成sqlmap,do,dao,daoimpl

    NULL 博文链接:https://skywhsq1987.iteye.com/blog/1513734

    mybatis反向生成代码工具(包含service,serviceImpl,dao,entity,daoImpl)

    因为这是本人亲自试用过的工具,自己感觉好牛逼啊,绝对的货真价实,mybatis反向生成工具,不会用的话本人可以教授使用,所以资源分偏高

    mybatis的逆向工程代码

    mybatis的逆向工程代码 mybatis的逆向工程代码 mybatis的逆向工程代码

    Spring struts文档上传代码

    实体类entity:文档对象实体 action: 是struts中action层 主要处理表现层的东西 facade:只是一个门面模式(不起多大的作用)主要是... (**DAO是一个接口 每个这样的dao都有个它的实现类与它对应 -也就是**DAOImpl)

    简单的jsp+servlet+javaBean访问mysql数据库

    jsp+servlet+javaBean访问数据库的简单例子,但是类设置非常巧妙,大家注意。

    IBatisNet的Codesmith模板

    DaoImpl, the C# DAO implementation class that implements the interface referred by DaoIntf. SqlMap, the IBatis.NET SQL mapping file that contains SQL statements used in the DaoImpl above.

    基于WIKI的课程交流系统

    其中我负责总体设计及协作交流管理模块的设计开发 技术要求:1、采用MVC+DAO模式设计开发,其中的VO包主要处理表字段,DAO包主要包括数据操作方法的声明,这些方法在DAOImpl包中实现。在DAO工厂模式的基础上,引入...

    Spring+MyBatis/Hibernate+Ehcache+Maven的Demo Web项目(稳定版)

    见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache.xml及web.xml的pageEhCacheFilter 4.MyBatis+Maven代码生成工具。见bin目录 5.作为项目或者技术研究的基础架构。必要的jar包依赖都已配置好,...

    JAVA代码生成,支持模板自定义,完美运行

    2.ssm模板实现:pojo,dao,daoimpl,service,serviceimpl,controller,各mapper.xml 代码自动生成, 3.配置文件自动生(含:spring,springMVC,mybatis,web.xml); 代码完美运行. 使用: 1.配置generator.xml(key):...

    Java代码生成

    2.ssm模板实现:pojo,dao,daoimpl,service,serviceimpl,controller,各mapper.xml 代码自动生成, 3.配置文件自动生(含:spring,springMVC,mybatis,web.xml); 代码完美运行. 使用: 1.配置generator.xml(key):basepackage...

    Spring+MyBatis/Hibernate+Ehcache+Maven的Demo Web项目

    见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache.xml及web.xml的pageEhCacheFilter 4.MyBatis+Maven代码生成工具。见bin目录 5.作为项目或者技术研究的基础架构。必要的jar包依赖都已配置好,...

    java-web_学生管理系统(完成实现三成架构)

    6,从前台页面开始向后进行调用,jsp--&gt;sertlet--&gt;service--&gt;daoimpl 。 7,依次实现各层方法。 主要用的三层架构实现: (1)表示层(USL,即User Show Layer):视图层     a. 前台:对应于MVC中的View,用于...

    spring考试通过必备材料.docx

    *DAOImpl,DAO实现类 20 在struts.xml中配置页面跳转关系, 21 在applicationContext.xml中配置类之间的调用关系, 22 通知 23 通知文件MyAdvice,schema方法的通知 23 在applicationContext.xml中配置通知--通知文件...

    SSH代码生成工具 SSH代码生成器

    DAOImpl --&gt; DAO接口Implements实现类 程序配置 --&gt; web.xml 验证框架--&gt; bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --&gt; ...

    虚拟数据层 Struts2、Hibernate、Spring整合的泛型DAO Version 2010.9.27

    泛型daoimpl :GenericDaoImpl, ID extends Serializable&gt; implements GenericDao, ID&gt; 必须提供的构造方法,以便创建实例的时候就知道具体实体的类型。 daoimpl :PersonDAOImpl extends GenericDaoImpl, ...

    泛型dao 泛型dao 泛型dao

    泛型daoimpl :GenericDaoImpl, ID extends Serializable&gt; implements GenericDao, ID&gt; 必须提供的构造方法,以便创建实例的时候就知道具体实体的类型。 daoimpl :PersonDAOImpl extends GenericDaoImpl, ...

    AutoCode代码生成器【SSH版】

    DAOImpl --&gt; DAO接口Implements实现类 程序配置 --&gt; web.xml 验证框架--&gt; bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验 证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --&gt; ...

    AutoCode代码生成器(SSH版)

    DAOImpl --&gt; DAO接口Implements实现类 程序配置 --&gt; web.xml 验证框架--&gt; bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --&gt; ...

    ssh代码生成器轻松、快捷

    DAOImpl --&gt; DAO接口Implements实现类 程序配置 --&gt; web.xml 验证框架--&gt; bean-validation.xml (实体验证)、SaveAction-validation.xml (保存验证)、UpdateAction-validation.xml (修改验证) 日志管理配置 --&gt; log4j...

Global site tag (gtag.js) - Google Analytics