zoukankan      html  css  js  c++  java
  • Dao层查询

    得到list的几种方式:

    一:继承HibernateDaoSupport类

    1,this.getSession().createQuery(hql.toString()).list();

    @SuppressWarnings("unchecked")
    	public List<BusinessOrderRelation> getBrList(String orderNo,Integer orderSubNo,String type,String fdbs,String seqNo)
    	{
    		StringBuffer hql = new StringBuffer();
    		List<BusinessOrderRelation> list = new ArrayList<BusinessOrderRelation>();
    		hql.append("from BusinessRelation bor  where 1=1 ");
    		hql.append(" and bor.orderNo =:orderNo and bor.orderSubNo = :orderSubNo ")
    		          .append("and bor.type = :type and bor.fdbs = :fdbs and seqNo like '")
                           .append(seqNo)
                              .append("%') ))");
    		list = this.getSession().createQuery(hql.toString())
    						.setString("orderNo", orderNo)
    						.setInteger("orderSubNo", orderSubNo)
    						.setString("type", type)
    						.setString("fdbs", fdbs)
    						.list();
    		return list;
    	}
    

     2,this.getHibernateTemplate().find(hql.toString());

    @SuppressWarnings("unchecked")
    	public List<Pscrkkphz> findDbPsrkkpInfor(String fdbs,String djbs) throws DataAccessFailureException
    	{
    		StringBuffer hql = new StringBuffer();	
    		hql.append("from Pscrkkphz where 1=1 and djbs = '"+ djbs +"' and executeStatus = 'N'");
    		if(!UtilHelper.isEmpty(fdbs))
    		{
    			hql.append(" and fdbs = '")
    			.append(fdbs).append("'");
    		}
    		return this.getHibernateTemplate().find(hql.toString());
    	}
    

    二:继承JdbcDaoSupport类

    1,this.getJdbcTemplate().query(sql.toString(), ParameterizedBeanPropertyRowMapper.newInstance(CaogaomxDto.class), new Object[]{djbh});

    public List<CaogaomxDto> findCaogaomxInfor(String djbh) throws DataAccessFailureException{
    		StringBuffer sql = new StringBuffer();
    		sql.append("select cm.*, dor.draft_order_relation_id, dor.order_no, dor.order_sub_no, dor.original_order_no, "); 
    		sql.append("dor.original_order_sub_no, dor.original_not_arrival_quantity notArrivalQuantity from caogaomx cm ");
    		sql.append(" left join draft_order_relation dor on cm.plh = dor.order_no  and cm.dj_sn = dor.order_sub_no where 1 = 1 ");
    		if(!UtilHelper.isEmpty(djbh)){
    			sql.append(" and cm.plh = ? ");
    		}
    		return this.getJdbcTemplate()
    			.query(sql.toString(), ParameterizedBeanPropertyRowMapper.newInstance(CaogaomxDto.class), new Object[]{djbh});
    	}
    

    2,this.getJdbcTemplate().queryForList(sql.toString(), new Object[]{originalOrderNo, originalOrderSubNo});

    	public List<Map<String, Object>> getConfirmJeAndHsjeByOriginalOrder(
    			String originalOrderNo, Integer originalOrderSubNo)
    			throws DataAccessFailureException {
    		StringBuffer sql = new StringBuffer();
    		sql.append("select cx.je, cx.hsje, cx.shl, cx.hshj from Confirmmx cx where 1 = 1 ");
    		if(!UtilHelper.isEmpty(originalOrderNo)){
    			sql.append("and cx.original_Order_No = ? ");
    		}
    		if(!UtilHelper.isEmpty(originalOrderSubNo)){
    			sql.append("and cx.original_Order_Sub_No = ? ");
    		}
    		sql.append("and cx.EXECUTE_STATUS = '").append(McConstants.CONFIMR_ORDER_PASS).append("'");
    		return this.getJdbcTemplate().queryForList(sql.toString(), new Object[]{originalOrderNo, originalOrderSubNo});
    	}
    
  • 相关阅读:
    [NOIp2016] 天天爱跑步
    状压DP小拼盘
    DP × KMP
    KMP算法 详解+模板
    [NOI2014] 起床困难综合症
    [洛谷P3391] 文艺平衡树 (Splay模板)
    START
    【C】单链表的实现
    【数据结构】动态顺序表
    C语言实现扫雷程序
  • 原文地址:https://www.cnblogs.com/csuwangwei/p/2281692.html
Copyright © 2011-2022 走看看