2024.6.8

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.drip.mapper.OrderMapper">
    <resultMap id="orderMap" type="Order">
        <id column="order_id" property="orderId"/>
        <result column="order_name" property="orderName"/>
        <result column="customer_id" property="customerId"/>
<!--对象属性赋值
property对象属性名
customer对象类型-->
        <association property="customer" javaType="customer">
<!--            <id column="customer_id" property="customerId"/>-->
<!--            <result column="customer_name" property="customerName"/>-->
        </association>
    </resultMap>
    <select id="queryOrderById" resultMap="orderMap">
        SELECT * from t_order a LEFT JOIN t_customer b on a.customer_id=b.customer_id WHERE a.order_id=#{id}
    </select>

</mapper>

后端mapper层代码

posted @ 2024-06-08 23:34  258333  阅读(5)  评论(0编辑  收藏  举报