Mybatis 的foreach 可以嵌套吗?

Mybatis 的foreach 可以嵌套吗?_第1张图片


  1. http://code.google.com/p/mybatis/source/browse/trunk/src/test/java/org/apache/ibatis/submitted/nested/?r=3467  
  2.   
  3. Junit Test  
  4. NestedForEachTest.java  
  5. NestedForEach.xml  


照着这个效果,我在自己的paohe项目xml中这样写


java代码:

QualityClientServiceImpl.java:

QualityClient qualityClient = new QualityClient();
qualityClient.setQualitySampleinfoList(sampleInfoListTmp);
List qualityCostList = qualityCostMapper.queryQualityCost(qualityClient); //获取最新的检测项费用


其中QualityClient.java   vo类有 private List qualitySampleinfoList; //样品列表,

QualitySampleinfo.java vo类有 private List qualityVariety;


最终sql效果是

 SELECT QUALITY_COST_ID, QUALITY_DESC_ID, QUALITY_CHECK_ID, INSPECT_ORGANIZATION
_ID, TESTING_COST, CHECK_TYPE, IS_STANDARD_SAMPLE, REMARK, ALIVE_FLAG FROM spot_quality_cost WHERE QUALITY_COS
T_ID IN ( ? , ? , ? , ? , ? , ? ) 


mybatis多个foreach嵌套查询成功!

你可能感兴趣的:(Mybatis)