被引用xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.mymall.mbg.mapper.UmsRoleMapper">
<resultMap id="BaseResultMap" type="com.demo.mymall.mbg.model.UmsRole">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="admin_count" jdbcType="INTEGER" property="adminCount" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="sort" jdbcType="INTEGER" property="sort" />
</resultMap>
<!--省略其他sql -->
<mapper>
其中<mapper namespace="com.demo.mymall.mbg.mapper.UmsRoleMapper"> 和 resultMap id="BaseResultMap"
在引用文件中我们需要指定被引用文件的namespace+resultMap
引用文件
<!--获得用户角色-->
<select id="getRoleList" resultMap="com.demo.mymall.mbg.mapper.UmsRoleMapper.BaseResultMap">
select r.*
from ums_admin_role_relation ar left join ums_role r on ar.role_id = r.id
where ar.admin_id = #{adminId}
</select>
关键属性resultMap="com.demo.mymall.mbg.mapper.UmsRoleMapper.BaseResultMap"
即被引用文件的namespace+resultMap