mysql嵌套查询

AccountBillModel -->  UserModel  一对一
AccountBillModel -->  AccountBillDetailModel  一对多
    <resultMap id="AccountBillMap" type="com.blm.model.accountBill.AccountBillModel">
        <result column="billId" jdbcType="BIGINT" property="billId"/>
        <result column="billCode" jdbcType="VARCHAR" property="billCode"/>
        <result column="accountedStatus" jdbcType="INTEGER" property="accountedStatus"/>
        <result column="settleValid" jdbcType="INTEGER" property="settleValid"/>
        <result column="user_id" jdbcType="BIGINT" property="userId" />
        <association property="userModel" javaType="com.blm.model.user.UserModel">
            <result column="user_id" jdbcType="BIGINT" property="userId" />
            <result column="user_name" jdbcType="VARCHAR" property="userName" />
        </association>
        <collection javaType="ArrayList" ofType="com.blm.model.accountBill.AccountBillDetailModel"
                    property="accountBillDetailModel">
            <result column="orderId" jdbcType="BIGINT" property="orderId"/>
            <result column="orderCode" jdbcType="VARCHAR" property="orderCode"/>
            <result column="freightAmount" jdbcType="DECIMAL" property="freightAmount"/>
            <result column="incidentalAmount" jdbcType="DECIMAL" property="incidentalAmount"/>
            <result column="publishTime" jdbcType="TIMESTAMP" property="publishTime"/>
        </collection>
    </resultMap>

 property = “ ” 被维护实体在宿主实体中的属性名

javaType = " " 被维护实体的类型

ofType:指定映射到List集合的pojo的类型  

 

posted @ 2018-08-07 11:38  _秋天该很好  阅读(1316)  评论(0编辑  收藏  举报