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的類型  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM