码迷,mamicode.com
首页 > 其他好文 > 详细

嵌套查询--------关联一对多关系----------collection

时间:2017-06-05 12:33:47      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:app   nbsp   sel   ever   ase   lov   http   arch   forever   

参考来源:   http://www.cnblogs.com/LvLoveYuForever/p/6689577.html

 

 <resultMap id="BaseResultMap" type="com.icss.ys.pojo.Customer" >
    <id column="customer_id" property="customerId" jdbcType="INTEGER" />
    <result column="customer_name" property="customerName" jdbcType="VARCHAR" />
    <result column="customer_card" property="customerCard" jdbcType="VARCHAR" /> 
    	
  	<!-- 关联一对多关系      column="customer_id" 此处customer_id作为参数传给select嵌套查询    -->
  	<collection property="tickets" ofType="com.icss.ys.pojo.Ticket" 
  	select="selectTicket" column="customer_id" ></collection>
  </resultMap>
  
  <select id="selectTicket" resultMap="com.icss.ys.dao.TicketMapper.BaseResultMap">
    	select *
    	from ticket
    	where customer_id = #{customer_id}
  </select>
  <select id="selectCustomerByName" resultMap="BaseResultMap" >
    	select *
    	from customer  where customer_name=#{customer_name} 	
  </select>

  

嵌套查询--------关联一对多关系----------collection

标签:app   nbsp   sel   ever   ase   lov   http   arch   forever   

原文地址:http://www.cnblogs.com/1020182600HENG/p/6944125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!