Ibatis


                                       Use if for each loop for iteration in MyBatis



public List<CaseDetail> getCasesFromSalesChecks(List<String> lstSalesCheck,String dcNo) throws CustDirectException {

Map<String, Object> mapSalesCheck= new HashMap<String, Object>();
mapSalesCheck.put("lstSalesCheck", lstSalesCheck);
mapSalesCheck.put("dcNo", dcNo);
List<CaseDetail> lstCases =caseDetailMapper.getCasesFromSalesChecks(mapSalesCheck);
if((null!=lstCases)&&(lstCases.size()!=0)){
logger.info("successfully found "+lstCases.size() +" cases for DC NO "+dcNo+ "  salescheck   " +lstSalesCheck.toString());
return lstCases;
}
logger.info("Fetching salescheck failed for " + lstSalesCheck);
throw new CustDirectException("error.dccust.reprinting.caseList.notFound");
}


public List<CaseDetail> getCasesFromSalesChecks(Map<String, Object> mapSalesCheck);

<select id="getCasesFromSalesChecks" resultType="com.sears.dc.custdirect.vo.CaseDetail" parameterType="map">
SELECT
H.CASE_NO as caseNo,
H.SALES_CHECK as salesCheck,
D.SKU as sku,
D.QTY as qty,
O.SHIP_TO_NAME as itemDesc
FROM CASE_HEADER H, CASE_DETAIL D, ORDERS O
WHERE H.CASE_NO = D.CASE_NO
AND O.SALES_CHECK = H.SALES_CHECK
AND O.DC_NO = H.DC_NO
AND H.DC_NO = #{dcNo}
AND O.SALES_CHECK IN
<foreach item="salescheck" index="index" collection="lstSalesCheck"
      open="(" separator="," close=")">
        #{salescheck}
  </foreach>
</select>

Comments

Popular posts from this blog

Conversion from Clob To String in java and Vice versa

Portable Java 8/ JDK8 setup without admin rights

Multi Threading , Producer consumer problem in Java