--Map is possible with key and value --List can be nested normally
Development PC: Windows 10 STS: 4 mybatis:3.2.5 mybatis-spring:1.2.2 Java: 8
http://www.mybatis.org/mybatis-3/ja/dynamic-sql.html No particular explanation for nesting
--Mapper: xml
SampleMapper.xml
<select id="selectTestMapList" resultMap="BaseResultMap">
SELECT
sample.*
FROM
sample
WHERE
sample.id IN
<foreach item="internalMap" collection="nestedMapList">
<foreach item="value" index="key" collection="internalMap" open="(" separator="," close=")">
#{value}
</foreach>
</foreach>
</select>
--Mapper: java
SampleMapper.java
List<Sample> selectTestMapList(@Param("nestedMapList") List<Map<String, Integer>> nestedMapList);
TestMapperExecutor.java
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:/sample/spring/test-context.xml"})
public class TestMapperExecutor {
@Autowired
private SampleMapper sampleMapper;
@Test
public void test() {
List<Map<String, Integer>> nestedMapList = new CopyOnWriteArrayList<>();
Map<String, Integer> internalMap = new ConcurrentHashMap<>();
internalMap.put("iKey", 1);
nestedMapList.add(internalMap);
List<Sample> result = null;
try {
result = sampleMapper.selectTestMapList(nestedMapList);
}
catch (Throwable t) {
t.printStackTrace();
}
}
}
Thank you for your hard work!