javaType
是用来指定pojo
中属性的类型,而ofType
指的是映射到集合属性中pojo
的类型;
@Data
public class xxxVo implements Serializable {
// 其他属性
// 类型
private List<Integer> types;
}
查询关联表类型,一对多【伪代码】
<resultMap id="xxxVoMap" type="com.xxx.xxxVo" extends="BaseResultMap">
<!-- 一对多关联属性映射 -->
<collection property="types" column="type" ofType="java.lang.Integer" javaType="java.util.ArrayList"></collection>
</resultMap>
<select id="selectList" resultMap="xxxVoMap">
select
t1.id,ti.name,t2.type
from
table1 t1,table2 t2
left join t1.id = t2.table_id
</select>
参考:https://blog.csdn.net/u013216156/article/details/78642920/