<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/虛擬化技術/

    友情博客

    多線程并發編程

    開源技術

    持久層技術相關

    搜索

    •  

    積分與排名

    • 積分 - 358627
    • 排名 - 154

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 国产精品亚洲专区无码不卡| 美国毛片亚洲社区在线观看| 大地资源在线资源免费观看| 一级毛片直播亚洲| 免费一级做a爰片久久毛片潮| 四虎永久免费观看| 色屁屁www影院免费观看视频| 亚洲av无码国产精品色在线看不卡 | 中文字幕亚洲乱码熟女一区二区| 免费大片av手机看片高清| 免费大黄网站在线观| 无码人妻一区二区三区免费视频 | 成人特级毛片69免费观看| 亚洲午夜精品久久久久久浪潮 | 又大又硬又粗又黄的视频免费看| 亚洲国产a级视频| a在线视频免费观看| 亚洲成人动漫在线| 国产成在线观看免费视频| 亚洲中文无码永久免| 男人的天堂亚洲一区二区三区 | 亚洲成A人片在线观看WWW| a毛片在线免费观看| 亚洲手机中文字幕| 国产网站免费观看| 中文成人久久久久影院免费观看| 亚洲AV日韩AV永久无码久久 | 国产成人免费a在线视频色戒| 成人在线免费视频| 亚洲日韩区在线电影| 成人免费淫片在线费观看| 色多多A级毛片免费看| 久久久久亚洲精品日久生情| 好吊妞998视频免费观看在线| 免费人成网上在线观看| 亚洲av日韩av无码| 国产精品免费视频网站| 久久国产乱子精品免费女| 亚洲日韩中文字幕一区| 亚洲精品国精品久久99热一| 99久久这里只精品国产免费|