SSM framework is used, the database is MySQL, make inquiries when incoming List collection, use SQL statements to query data in the way
there are two main problems: My List collection is the use of another statement out of the query, passing parameters is of type int, the return value is of type int List collection:
public List<Integer> select(Integer id); <select id="select" resultType="java.util.List" parameterType="java.lang.Integer"> select id from section where status='A' and unitId=#{id,jdbcType=INTEGER} </select>
This is the first time when I return to use value types (java.util.List), in which case I will perform error : java.lang.UnsupportedOperationException
In fact, we are here if you want to return a collection of the specified type directly write java.lang.Integer (int type) java.lang.String (string), etc. can, of course, you can also customize a resultMap
<select id="select" resultType="java.lang.Integer" parameterType="java.lang.Integer"> select id from section where status='A' and unitId=#{id,jdbcType=INTEGER} </select>
The above is by id check out a List collection, the following is found in the List collection into the query criteria:
public List<JUMember> selectById(List<Integer> id);
<select id="selectById" parameterType="java.util.List" resultMap="BaseResultMap">
select * from jumember where status = 'A' and id in
<foreach collection="list" index="index" item="item" open="("separator="," close=")">
#{item}
</foreach>
</select>
Data collection using foreach loop statement, item is recycled to the data, if you are a sophisticated type of data do, then you can use bulk insert item. Way to obtain the corresponding value of the property name