mybatis跨XML引用

resultMap中association标签的select属性使用嵌套查询的时候需要引用其它xml文件的配置

此时可以用要引用xml的namespace.引用select的ID

<resultMap id="BaseResultMap" type="com.jbt.pojo.SectorStaffInfo" >
<id column="Id" property="id" jdbcType="INTEGER" />
<result column="Position" property="position" jdbcType="VARCHAR" />
<result column="Description" property="description" jdbcType="VARCHAR" />
<result column="CreateDate" property="createdate" jdbcType="VARCHAR" />
<association property="staffinfo" column="StaffInfo" select="com.jbt.dao.StaffInfoMapper.selectByPrimaryKey"/>
<association property="sectorinfo" column="SectorInfo" select="com.jbt.dao.SectorInfoMapper.selectByPrimaryKey"/>
</resultMap>

要引用staffInfo中的selectByPrimaryKey来进行嵌套查询,则select="com.jbt.dao.StaffInfoMapper.selectByPrimaryKey"

原文地址:https://www.cnblogs.com/huhuixin/p/5691934.html