<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 167,  comments - 30,  trackbacks - 0
     public List<CertInfoListView> getInfoList(CertInfoListView view) throws DAOException {
      List<CertInfoListView>  liinfo = new ArrayList<CertInfoListView>();
      String sql="select b.usercode,b.agentcode,i.sn,i.cert,i.certstate,i.endtime, i.ipasskeyno,b.id,b.addtime  from certbind b inner join certinfo i on b.ipasskeyno=i.ipasskeyno";
      Session session = HibernateTemplate.getInstance().getSession();
      StringBuffer sb = new StringBuffer(sql);
      sb.append(" where 1=1 ");
      if(!CheckEmpty.isEmpty(view.getIpasskeyno())){
       sb.append(" and i.ipasskeyno ='").append(view.getIpasskeyno()).append("'");
      }
      if(!CheckEmpty.isEmpty(view.getAgentcode())){
       sb.append(" and b.agentcode ='").append(view.getAgentcode()).append("'");
      }
      if(!CheckEmpty.isEmpty(view.getSn())){
       sb.append(" and i.sn ='").append(view.getSn()).append("'");
      }
      if(!CheckEmpty.isEmpty(view.getUsercode())){
       sb.append(" and b.usercode ='").append(view.getUsercode()).append("'");
      }
      if(view.getAddtime()!=null){
       sb.append(" and b.addtime=").append(view.getAddtime());
      }
      sb.append(" order by ipasskeyno ,addtime desc");
      Query q = session.createSQLQuery(sb.toString());
      int pageno = view.getPageno();
      int size = view.getPagesize();
      if(pageno!=0&&size!=0){
       q.setFirstResult((pageno-1)*size);
       q.setMaxResults(size);
      }
      List list = q.list();
      Iterator it = list.iterator();
      while(it.hasNext()){
       Object[] obj = (Object[])it.next();
       CertInfoListView c = new CertInfoListView();
       for(int i=0;i<obj.length;i++){
        if(!CheckEmpty.isEmpty((String)obj[0])){
         c.setUsercode((String)obj[0]);
        }
        if(!CheckEmpty.isEmpty((String)obj[1])){
         c.setAgentcode((String)obj[1]);
        }
        if(!CheckEmpty.isEmpty((String)obj[2])){
         c.setSn((String)obj[2]);
        }
        if(obj[3]!=null){
         SerializableClob sc = (SerializableClob)obj[3];
         String cc = null;
         if(sc!=null){
          try {
           cc = sc.getSubString(1, (int)sc.length());
          } catch (SQLException e) {
          }
         }
         if(cc!=null)c.setCert(cc);
        }
        if(obj[4]!=null){
         BigDecimal b = (BigDecimal)obj[4];
         c.setCertstate(b.intValue());
        }
        if((obj[5])!=null){
         c.setEndtime(((Date)obj[5]));
        }
        if(!CheckEmpty.isEmpty((String)obj[6])){
         c.setIpasskeyno((String)obj[6]);
        }
        c.setCertbindid(Integer.parseInt((String)obj[7]));
        c.setAddtime((Date)obj[8]);
       }
       liinfo.add(c);
      }
      if(session!=null&&session.isConnected())session.close();
      return liinfo;
     }


    實現分頁的DAO
    /*
      * (non-Javadoc)
      *
      * @see com.cns.certservice.dao.CertBindTabDao#getCertBindList(com.cns.certservice.vo.CertBindView)
      */
     public List<CertBindView> getCertBindList(CertBindView view)
       throws DAOException {
      List<CertBindView> li = null;
      List<Certbind> lic = null;
      Session session = null;
      try {
       session = HibernateTemplate.getInstance().getSession();
       Criteria cri = session.createCriteria(Certbind.class);
       Certbind c = getCertBind(view);
       if (c.getAddtime() != null) {
        cri.add(Expression.eq("addtime", c.getAddtime()));
       }
       if (!CheckEmpty.isEmpty(c.getAgentcode())) {
        cri.add(Expression.eq("agentcode", c.getAgentcode()));
       }
       if(c.getId()!=0)cri.add(Expression.eq("id", c.getId()));
       if (!CheckEmpty.isEmpty(c.getIpasskeyno())) {
        cri.add(Expression.eq("ipasskeyno", c.getIpasskeyno()));
       }
       if (!CheckEmpty.isEmpty(c.getUsercode())) {
        cri.add(Expression.eq("usercode", c.getUsercode()));
       }
       if (!CheckEmpty.isEmpty(c.getExtend1())) {
        cri.add(Expression.eq("extend1", c.getExtend1()));
       }
       if (!CheckEmpty.isEmpty(c.getExtend2())) {
        cri.add(Expression.eq("extend2", c.getExtend2()));
       }
       if (c.getAgenttype() != 0) {
        cri.add(Expression.eq("agenttype", c.getAgenttype()));
       }
       int pageno = view.getPageno();
       int size = view.getPagesize();
       if(pageno!=0&&size!=0){
        cri.setFirstResult((pageno-1)*size);
        cri.setMaxResults(size);
       }
       lic = cri.list();
       if (lic != null) {
        li = new ArrayList<CertBindView>();
        for (Certbind cer : lic) {
         CertBindView v = getCertBindView(cer);
         li.add(v);
        }
       }
       
      } catch (HibernateException e) {
       log.error(e,e);
       throw new DAOException(e);
      }finally{
       if (session != null && session.isConnected())
        session.close();
      }
      return li;
     }
     public int getInfoListCount(CertBindView view) throws DAOException {
      int count = 0;
      Session session = null;
      try {
       session = HibernateTemplate.getInstance().getSession();
       Criteria cri = session.createCriteria(Certbind.class);
       Certbind c = getCertBind(view);
       if (c.getAddtime() != null) {
        cri.add(Expression.eq("addtime", c.getAddtime()));
       }
       if (!CheckEmpty.isEmpty(c.getAgentcode())) {
        cri.add(Expression.eq("agentcode", c.getAgentcode()));
       }
       if(c.getId()!=0)cri.add(Expression.eq("id", c.getId()));
       if (!CheckEmpty.isEmpty(c.getIpasskeyno())) {
        cri.add(Expression.eq("ipasskeyno", c.getIpasskeyno()));
       }
       if (!CheckEmpty.isEmpty(c.getUsercode())) {
        cri.add(Expression.eq("usercode", c.getUsercode()));
       }
       if (!CheckEmpty.isEmpty(c.getExtend1())) {
        cri.add(Expression.eq("extend1", c.getExtend1()));
       }
       if (!CheckEmpty.isEmpty(c.getExtend2())) {
        cri.add(Expression.eq("extend2", c.getExtend2()));
       }
       if (c.getAgenttype() != 0) {
        cri.add(Expression.eq("agenttype", c.getAgenttype()));
       }
       count = (Integer)cri.setProjection(Projections.rowCount()).uniqueResult();
       cri.setProjection(null);
      } catch (HibernateException e) {
       log.error(e,e);
       throw new DAOException(e);
      }finally{
       if (session != null && session.isConnected())
        session.close();
      }
      return count;
     }

    /*
      * (non-Javadoc)
      *
      * @see com.cns.certservice.dao.CertBindTabDao#updateCertBind(com.cns.certservice.vo.CertBindView)
      */
     public boolean updateCertBind(CertBindView view) throws DAOException {
      boolean res = false;
      if (view.getId()==0) {
       throw new DAOException("getId from CertBindView is null!");
      }
      Session session= null;
      try {
       session = HibernateTemplate.getInstance().getSession();
       Certbind c = (Certbind) session.get(Certbind.class, view.getId());
       if (!CheckEmpty.isEmpty(view.getAgentcode()))
        c.setAgentcode(view.getAgentcode());
       if (!CheckEmpty.isEmpty(view.getExtend1()))
        c.setExtend1(view.getExtend1());
       if (!CheckEmpty.isEmpty(view.getExtend2()))
        c.setExtend2(view.getExtend2());
       if (!CheckEmpty.isEmpty(view.getIpasskeyno()))
        c.setIpasskeyno(view.getIpasskeyno());
       if (!CheckEmpty.isEmpty(view.getUsercode()))
        c.setUsercode(view.getUsercode());
       if (view.getAgenttype() != 0)
        c.setAgenttype(view.getAgenttype());
       res = HibernateTemplate.getInstance().updateObject(c);
      } catch (HibernateException e) {
       log.error(e,e);
       throw new DAOException(e);
      }finally{
       if (session != null && session.isConnected())
        session.close();
      }
      return res;
     }


     private Certbind getCertBind(CertBindView view) {
      Certbind c = new Certbind();
      if (view.getAddtime() != null)
       c.setAddtime(view.getAddtime());
      if (!CheckEmpty.isEmpty(view.getAgentcode()))
       c.setAgentcode(view.getAgentcode());
      if (!CheckEmpty.isEmpty(view.getExtend1()))
       c.setExtend1(view.getExtend1());
      if (!CheckEmpty.isEmpty(view.getExtend2()))
       c.setExtend2(view.getExtend2());
      if (!CheckEmpty.isEmpty(view.getIpasskeyno()))
       c.setIpasskeyno(view.getIpasskeyno());
      if (!CheckEmpty.isEmpty(view.getUsercode()))
       c.setUsercode(view.getUsercode());
      if(view.getId()!=0)c.setId(view.getId());
      if (view.getAgenttype() != 0)
       c.setAgenttype(view.getAgenttype());
      return c;
     }

     private CertBindView getCertBindView(Certbind view) {
      CertBindView c = new CertBindView();
      if (view.getAddtime() != null)
       c.setAddtime(view.getAddtime());
      if (!CheckEmpty.isEmpty(view.getAgentcode()))
       c.setAgentcode(view.getAgentcode());
      if (!CheckEmpty.isEmpty(view.getExtend1()))
       c.setExtend1(view.getExtend1());
      if (!CheckEmpty.isEmpty(view.getExtend2()))
       c.setExtend2(view.getExtend2());
      if (!CheckEmpty.isEmpty(view.getIpasskeyno()))
       c.setIpasskeyno(view.getIpasskeyno());
      if (!CheckEmpty.isEmpty(view.getUsercode()))
       c.setUsercode(view.getUsercode());
      if(view.getId()!=0)c.setId(view.getId());
      if (view.getAgenttype() != 0)
       c.setAgenttype(view.getAgenttype());
      return c;
     }

    posted on 2009-08-20 13:37 David1228 閱讀(852) 評論(0)  編輯  收藏 所屬分類: Hibernate/ibatis

    <2009年8月>
    2627282930311
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    常用鏈接

    留言簿(4)

    隨筆分類

    隨筆檔案

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    Java

    Linux知識相關

    Spring相關

    云計算/Linux/虛擬化技術/

    友情博客

    多線程并發編程

    開源技術

    持久層技術相關

    搜索

    •  

    積分與排名

    • 積分 - 358616
    • 排名 - 154

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲免费日韩无码系列 | 久久WWW免费人成—看片| 免费观看理论片毛片| 色天使亚洲综合在线观看| 国产免费不卡视频| 亚洲国产日韩一区高清在线| 大地资源网高清在线观看免费 | 亚洲第一视频在线观看免费| 亚洲日韩国产成网在线观看| 中文毛片无遮挡高清免费| 亚洲欧洲日产国码无码网站 | 噼里啪啦电影在线观看免费高清| 77777亚洲午夜久久多喷| 真实乱视频国产免费观看| 国内成人精品亚洲日本语音 | 亚洲AV成人精品一区二区三区| 国产美女无遮挡免费视频网站| 免费看黄网站在线看| 国产亚洲精品一品区99热| xxxxwww免费| 亚洲av无码专区在线电影| 国产精品亚洲产品一区二区三区| a级成人毛片免费视频高清| 91亚洲导航深夜福利| 免费精品一区二区三区在线观看| 污视频网站在线免费看| 久久精品亚洲视频| 最近2019中文字幕免费看最新| 黄页视频在线观看免费| 久久综合九九亚洲一区| 毛片免费全部免费观看| 美美女高清毛片视频黄的一免费| 亚洲国产精品一区第二页| 24小时免费直播在线观看| 好猛好深好爽好硬免费视频| 亚洲国产日韩在线成人蜜芽| 亚洲国产av一区二区三区| 永久免费在线观看视频| 污网站免费在线观看| 亚洲伊人久久大香线蕉影院| 亚洲综合色成在线播放|