hibernate 集合查询

hibernate 集合查询:

 1 public Long getPurchaseRecordByBlueIdCount(List<Long> blueIdList) {
 2         StringBuilder sql = new StringBuilder();
 3         //--投保人姓名(只显示姓名字脱敏处理)、产品名称、保费、购买数量、成交时间
 4         sql.append("SELECT count(1)");
 5         sql.append("FROM ISP_POLICY pol, ISP_APP_CUSTOMER AC, ISP_BLUEPRINT BP,isp_apply ap ");
 6         sql.append("WHERE 1 = 1 ");
 7         sql.append("AND AC.APPLY_ID = AP.APPLY_ID ");
 8         sql.append("AND AC.CUST_TYPE = 1 ");
 9         sql.append("AND AP.BLUE_ID = BP.BLUE_ID ");
10         sql.append("AND ap.policy_no = pol.policy_no ");
11         sql.append("AND bp.blue_fee_type = 1 ");
12         sql.append("AND bp.blue_id in (:blueIdList) ");
13         
14         LogTool.debug(this.getClass(), sql.toString(),true);
15         LogTool.debug(this.getClass(), "blueIdList: "+blueIdList.toString(),true);
16         Query query = super.getSession().createSQLQuery(sql.toString());
17         query.setParameterList("blueIdList", blueIdList);
18         BigDecimal count = (BigDecimal)query.uniqueResult();
19         
20         LogTool.debug(this.getClass(), "size: "+count);
21         return count.longValue();
22     }

 

posted @ 2019-01-21 10:07  xiluhua  阅读(546)  评论(0编辑  收藏  举报