Wu's view, the problem is very simple, but when Baidu came out of the results let people disappointed.
Baidu's results are divided into 2 types
1. If only one parameter is passed, a list or array can be used, which is a better understanding
2. If you pass multiple parameters, you can only use a map to contain multiple parameters, that is not to say I was uploaded to the service layer of the Pojo object, but also to transform into a map to use, so it is not smart ...
Baidu a half-day, found all is an article wandering, so two kinds of statements, MyBatis official documents on the issue is not mentioned.
So I wrote a junit test case and tried it with a try attitude.
Mapper File:
<select id= "gettestprojectlist" parametertype= "Com.goldwind.po.ProjectVo" resulttype= " Com.goldwind.po.ProjectExtend "> Select * from v_project where ID in <foreach item=" Item "index=" index "collection=" IDs "open=" ("separator=", "close=") "> #{item} </foreach> < /select>
Mapper.xml and Service.java don't mention it.
Write the use case directly inside JUnit:
@Test Public void testmybatisinquery () { new projectvo (); ListNew arraylist<integer>(); Ids.add (1); Ids.add (2); Projectvo.setids (IDs); List<ProjectExtend> projectlist = projectservice.gettestprojectlist (projectvo); for (projectextend p:projectlist) { System.out.println (p.tostring ()); } }
Try it, it's ready ....
Implementation of Mybatis in query