<resultMap type="com.mybatis.bean.Customer" id="BaseResultMap">
<id column="cust_id" property="custId"/>
<result column="cust_name" property="custName"/>
<result column="cust_age" property="custAge"/>
<collection property="orderSet" ofType="com.mybatis.bean.Order" column="cust_id"
select="com.mybatis.mapper.OrderMapper.getOrderByCustId">
</collection>
</resultMap>
<select id="getCustomerByCustId" resultMap="BaseResultMap">
select cust_id,cust_name,cust_age
from tbl_cust
where cust_id=#{custId}
</select>
<select id="getCustomerAndOrederByCustId" resultMap="BaseResultMap">
select cust_id,cust_name,cust_age
from tbl_cust
where cust_id=#{custId}
</select>
在执行getCustomerByCustId方法时不需要关联查询,不执行resultMap中的collection,在执行getCustomerAndOrederByCustId方法是需要执行关联查询,我知道在getCustomerByCustId方法的查询语句中不查询cust_id可以解决这个问题,但是现在的需求是我要放回的结果中包含cust_id的,不知道这个该怎么处理?求大神指点迷津。。。