首页 > 代码库 > 嵌套查询--------关联一对多关系----------collection
嵌套查询--------关联一对多关系----------collection
参考来源: 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。