zoukankan      html  css  js  c++  java
  • Mybatis多表关联及批量插入

     <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>
    

      

  • 相关阅读:
    前端面试题
    js collection
    javascript变量声明提升(hoisting)
    css3动画
    神奇的meta
    wap站bug小结
    前端collection
    js拾遗
    prototype之初印象
    自定义scrollBottom的值
  • 原文地址:https://www.cnblogs.com/judylucky/p/7082814.html
Copyright © 2011-2022 走看看