代码如下
Query query1=this.getSession().createSQLQuery(" select p.smallClassId as smallClassId,p.id as id,p.name as name,p.thumbNail as thumbNail,p.marketPrice as marketPrice,p.memberPrice as memberPrice from product p where p.name like ? and p.smallClassId= ? and p.valid=true and p.id not in (select sp.productId from special_product sp where sp.specialId =? and sp.valid=true)") .addScalar("id",StandardBasicTypes.LONG) .addScalar("thumbNail") .addScalar("marketPrice") .addScalar("memberPrice") .addScalar("name") .addScalar("smallClassId",StandardBasicTypes.LONG) .setResultTransformer(Transformers.aliasToBean(SpecialVo.class)); query1.setParameter(0, "%"+name+"%"); query1.setParameter(1, smallClassId); query1.setParameter(2, id); List<SpecialVo> specialVos1=query1.list(); for (SpecialVo s:specialVos1){ s.setIsSpecial(false); s.setQuantity(0); } specialVos.addAll(specialVos1);
时间: 2024-11-02 09:41:08