mybatis :一对多关系映射成对象时:
1.<resultMap id="Result" > <result property="value1" column="value1"/> <result property="value2" column="value2"/> <collection property="programs" column="{param1=value1,param2=value2}" select="selectlist"></collection> </resultMap>
2.<select id="selectlist" parameterType="java.util.Map"> select t.* from table t <where> t.param1=#{param1} and t.param2=#{param2} </where> </select>
1为组成结果的Map,2为对应的多个对象的查询。当需要传递多个参数进行查询多对象时
传递用{param1=value1,param2=value2},接收用java.util.Map
其中{}中,param为下面使用的参数名称,是多对象中对应的字段,value为值,就是一对象中匹配的字段