• hibernate查询返回一个list ,Date类型追加数据


    public Pagination getLookPage(BeanPatrolScheduling beanPatrolScheduling, int pageNo, int pageSize) {
            SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
              Pagination pagination = new Pagination();
              StringBuffer sql = new  StringBuffer();
              sql.append("      select   "); 
              
              sql.append("      ps.id,ju.username,ps.patrol_times,ps.patrol_month, ps.result,ps.parkid");
               
              sql.append("      from patrol_scheduling ps, ");
             
              sql.append("      company_emp ce, ");
              
              sql.append("      jc_user ju ");
                   
              sql.append("      where ps.emp_id=ce.id ");
              
              sql.append("      and  ce.id=ju.user_id ");
              
              sql.append("      and ps.data_status=0");
              
              if(beanPatrolScheduling.getUserName()!= null && beanPatrolScheduling.getUserName()!= ""){
                  sql.append("   and  ju.username like '%"+beanPatrolScheduling.getUserName()+"%'" ); 
                  
              }
              String sqls =  sql.toString();
              Query query =   sessionFactory.getCurrentSession().createSQLQuery(sqls.toString());
              List list = query.list();
              List<BeanPatrolScheduling> result=new ArrayList<BeanPatrolScheduling>();
                if(list!=null&&list.size()>0){
                    
                     for (Object object : list) {
                            int i = 0;
                            BeanPatrolScheduling modell=new BeanPatrolScheduling();
                            Object[] temp = (Object[]) object;            
                            modell.setId(Integer.parseInt( temp[i++] +""));
                            modell.setUserName(String.valueOf( temp[i++]));
                            modell.setPatrol_times(Integer.parseInt( temp[i++] +""));
                            try {
                                modell.setPatrol_month(dateformat.parse( temp[i++] +""));
                            } catch (ParseException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            modell.setResult(Integer.parseInt( temp[i++] +""));
                            modell.setParkid(String.valueOf(temp[i++]));
                            result.add(modell);
                     }
                 }
                
                pagination.setList(result);    
                pagination.setPageNo(pageNo);
                pagination.setPageSize(pageSize);
              
            return pagination;
        }
  • 相关阅读:
    MRF能量优化
    Django:model中的ForeignKey理解
    Django:常见的orm操作
    Django:在模板中获取当前url信息
    Django:haystack全文检索详细教程
    Django:全文检索功能可参考博客
    看电影学英语
    Markdown中怎么上传图片
    Mosquitto的安装、配置、测试
    Django:评论文章后局部刷新评论区
  • 原文地址:https://www.cnblogs.com/xinxin1994/p/6133539.html
Copyright © 2020-2023  润新知