<resultMap type ="Customer" id= "customerMap">
             <id property ="id" column="id" />
             <result property ="name" column="name" />
             <result property ="age" column="age" />
             <result property ="address" column="address" />
            
             <collection property ="orders" ofType="Order" >
                   <id property ="orderId" column="oid" />
                   <result property ="orderPrice" column="price" />
                   <result property ="orderNumber" column="orderNumber" />
             </collection>
       </resultMap>
      
       <select id ="selectCustomerById" parameterType="string" resultMap="customerMap" >
            select c.id,c.name,c.age,c.address,o.id oid,o.price,o.orderNumber,o.cid from customer c,orders o where c.id=o.cid and c.id=#{id}
       </select>
      
       <!-- 批量插入数据 -->
       <insert id ="insertBatch" parameterType="list" >
            insert into customer(id,name,age,address) values
             <foreach collection ="list" item="obj" separator="," >
                  (#{obj.id},#{obj.name},#{obj.age},#{obj.address})
             </foreach>
       </insert>

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-11-21
猜你喜欢
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
相关资源
相似解决方案