问题:
程序使用hibernate调用sql语句,发现不加as时结果A表的code和B表的code内容一致。
加了as之后现象消失
//代码片段 final int PAGE_NUMBER = 300; int size = itemIds.size(); int j = MyUtils.getSize(size,PAGE_NUMBER); for(int k = 0; k < j ; k++){ int toIdnex = MyUtils.getIndex(k,size,PAGE_NUMBER); List<Object> ret = MyUtils.getList(itemIds, k, toIdnex,PAGE_NUMBER); //bcFristSj-no2 sql = "select v1.item_id as p0,"+ " v1.boxtype1_id as p1,v1.first_package_box_quty as p2,"+//--一级包装 " v1.box_material_id1 as p3,v1.box_material_quantity1 as p4,"+//--包材1 " v1.box_material_id2 as p5,v1.box_material_quantity2 as p6,"+//--包材2 " v1.box_material_id3 as p7,v1.box_material_quantity3 as p8,"+//--包材3 " v1.box_material_id4 as p9,v1.box_material_quantity4 as p10,"+//--包材4 " v1.box_material_id5 as p11,v1.box_material_quantity5 as p12,"+//--包材5 " v1.box_material_id6 as p13,v1.box_material_quantity6 as p14,"+//--包材6 " v1.box_material_id7 as p15,v1.box_material_quantity7 as p16,"+//--包材7 " v1.min_split_quty as p17,"+//--最小拆分量 " v1.boxtype2_id as p18,"+//--二级包装 " v2.code as p19,"+//一级包装code " v3.code as p20"+ " from wms_item_to_customer v1"+ " left join wms_box_type v2 on v2.id = v1.boxtype1_id"+ " left join wms_item v3 on v3.id = v1.item_id"+ " where v1.item_id in("+StringUtils.substringBetween(ret.toString(), "[", "]")+")"+ " and v1.customer_id = ?"+ " and v1.status = 'ENABLED'"; query = session.createSQLQuery(sql); query.setLong(0, customerOrder.getCustomer().getId()); List<Object[]> listItemToCustomer = query.list(); //NO5:对客户物料关系查询结果进行匹配,获取所需一级包装和相应包材量 Map<Long,Double> box2 = new HashMap<Long,Double>(); for(Object[] obj : listItemToCustomer){ Long itemId = Long.parseLong(obj[0].toString()); //..........................
DEGUB模式进入后发现数据如下
[207632, 201966, 120, 200848, 1, null, 0, null, 0, null, 0, null, 0, null, 0, null, 0, 120, 201966, SGMSB111, SGMSB111]
而实际结果应该是
[207632, 201966, 120, 200848, 1, null, 0, null, 0, null, 0, null, 0, null, 0, null, 0, 120, 201966, SGMSB111, 9010511]