一对多查询,关联查询方式
两个表关联查询,然后封装
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxx.biz.sys.dao.KeyRoleSourceMapper">
<resultMap id="poolResult" type="com.xxx.biz.pool.entity.Pool">
<result property="lobNumber" column="lob_number"/>
<collection property="opItems" ofType="com.xxx.biz.po.entity.OPItem">
<result property="itemPlanMember" column="ITEM_PLAN_MEMBER"/>
<result property="planItemAmount" column="PLAN_ITEM_AMOUNT"/>
<result property="pricingModeal" column="PRICING_MODEAL"/>
</collection>
</resultMap>
<select id="queryPoolAllLobNumber" resultMap="poolResult">
select
source.lob_number,
item.ITEM_PLAN_MEMBER,
item.PLAN_ITEM_AMOUNT,
item.PRICING_MODEAL
from
tbl_keyrole_source source
left join tbl_joinitem joinitem on joinitem.lob_number = source.lob_number and joinitem.role_type = '项目经理'
left join op_item item on item.item_no = joinitem.item_no
where
source.keyrole_type = 17
and source.ignoe= 0
and source.month_id = 1
</select>
<update id="updateManagementScale" parameterType="com.xxx.biz.pool.entity.Pool">
update
tbl_keyrole_source
set
TM_MAX_TEAM_SIZE = #{tmMaxTeamSize},
TM_MAX_ITEM_AMOUNT = #{tmMaxItemAmount},
FP_MAX_TEAM_SIZE = #{fpMaxTeamSize},
FP_MAX_ITEM_AMOUNT = #{fpMaxItemAmount}
where
keyrole_type = 17
and ignoe= 0
and month_id = 1
and lob_number = #{lobNumber}
</update>
</mapper>
一对多查询,内嵌查询方式
先查询主表,然后用相关列查询从表
<resul