mybatis mapper.xml 配置文件多表级联查询返回值映射问题

<resultMap id="BaseResultMap2" type="LossesAre">

<id column="lossesare_id" property="id" jdbcType="INTEGER" />

<result column="lossesare_roomconfigid" property="roomconfigid" jdbcType="INTEGER" />

<result column="lossesare_shouldpay" property="shouldpay" jdbcType="DOUBLE" />

<result column="lossesare_pay" property="pay" jdbcType="DOUBLE" />

<result column="lossesare_paystatus" property="paystatus" jdbcType="INTEGER" />

<result column="lossesare_createdby" property="createdby" jdbcType="INTEGER" />

<result column="lossesare_createdtime" property="createdtime" jdbcType="TIMESTAMP" />

<result column="lossesare_createdby" property="createdby" jdbcType="INTEGER" />

<association property="supplier"  javaType="Supplier" resultMap="com.mogo.mapper.SupplierMapper.BaseResultMap1"  columnPrefix="supplier_" /> 

               1

<association property="flats"  javaType="Flats">

<id column="flats_id" property="id" jdbcType="INTEGER" />

<result column="flats_flatsnum" property="flatsnum" jdbcType="VARCHAR" />

<result column="flats_floornum" property="floornum" jdbcType="INTEGER" />

<association property="community" javaType="Community" resultMap="com.mogo.mapper.CommunityMapper.BaseResultMap" columnPrefix="community_" />

<association property="building" javaType="Building" resultMap="com.mogo.mapper.BuildingMapper.BaseResultMap" columnPrefix="building_" />

</association>

<association property="room"  javaType="Room" resultMap="com.mogo.mapper.RoomMapper.BaseResultMapRoom"  columnPrefix="room_"/>

<association property="product" javaType="Product" resultMap="com.mogo.mapper.ProductMapper.BaseResultMap1"  columnPrefix="product_"/>

<association property="purchaseAmtShould" javaType="PurchaseAmtShould">

<id column="pash_id" property="id" jdbcType="INTEGER"/>

<association property="purchaseOrder" javaType="PurchaseOrder"  >

<id column="purchaseorder_id" property="id" jdbcType="INTEGER" />

<result column="purchaseorder_ordercode" property="ordercode" jdbcType="VARCHAR" />

<association property="creator" javaType="Employee" resultMap="com.mogo.mapper.EmployeeMapper.BaseResultMapBase" columnPrefix="purchasecreated_" />

</association>

</association>

2

</resultMap> 

针对1,如果没有在<association> 内部自定义元素,则需要注明 resultMap的值,相反的,如果针对2,在<association>内部又自定义了返回值列字段,就无需在注明resultMap,不然的话,Mybatis返回值会对应不上这个对象,特此记录!