首页 > 代码库 > hibernate查询返回一个list ,Date类型追加数据
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; }
hibernate查询返回一个list ,Date类型追加数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。