<sqlMap namespace="sc_item">
<resultMap id="scaleItem" class="cn.db.model.ScaleItem" > <result property="id" column="id"/> <result property="scaleId" column="scaleId"/> <result property="content" column="content"/> <result property="status" column="status"/> <result property="dimensionId" column="dimensionId"/> <result property="serial" column="serial"/> </resultMap> <delete id="batchDelete"> <![CDATA[ DELETE FROM sc_item WHERE scaleId = #scaleId# AND ID = #id# ]]> </delete></sqlMap>红色是对应class中类的属性,紫色是参数,调用该语句的时候要注意参数是否对应。如:
private void deleteItems(String scaleId, List<Long> itemIds){
if(itemIds == null || itemIds.size() == 0) return; List<Map<String, Object>> params = new ArrayList<Map<String,Object>>(); for (Long itemId : itemIds) { Map<String, Object> param = new HashMap<String, Object>(); param.put("scaleId", scaleId); param.put("id", itemId); params.add(param); } this.dao.batchDelete("sc_item.batchDelete", params); }