daoImpl

 //删除一个
 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);
  }
 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值