刚开始我是自己写的select查询:
<association property="doctor" select="getDoctorById" column="doctor_id">
</association>
<sql id= "getDoctorById”>
select * from doctor where doctor_id = #{doctor_id}
</sql>
然后查询的结果doctor对象总是空。
解决办法:
select引用外键对应的mapper的select
<association property="doctor" select="com.test.mapper.DoctorMapper.selectByPrimaryKey" column="doctor_id">
</association>