hibernate 模糊查询及not in子查询
生活随笔
收集整理的這篇文章主要介紹了
hibernate 模糊查询及not in子查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼如下
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);轉載于:https://blog.51cto.com/tianxingzhe/1678159
總結
以上是生活随笔為你收集整理的hibernate 模糊查询及not in子查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: esp8266 rtos sdk在小黄板
- 下一篇: 人工智能的策略,如果国家优先发展”梦想成