mybatis父查询方法参数传递到子查询
父查询中的timeType,在父查询中创建了虚拟列,就返到子查询中了。
·
上代码
父查询
IPage<PollingPlan> selectAllContainRate(IPage<PollingPlan> page, @Param("companyId") Integer companyId, @Param("departmentId") Integer departmentId, @Param("timeType") Integer timeType);
<resultMap id="BaseResultMap" type="com.zjars.unified.device.bean.model.PollingPlan">
<id column="id" property="id"/>
<association property="rate" column="{id=id,timeType=timeType}" select="com.XXX.mapper.PollingTaskMapper.getRateByPlanIdAndTimeType" />
</resultMap>
<select id="selectAllContainRate" resultMap="BaseResultMap">
select pp.id,pp.plan_name,pp.state_check,case when (#{timeType} IS NULL) then NULL else #{timeType} end as timeType from polling_plan as pp where pp.company_id = #{companyId} and deleted = 0
<where>
<if test="departmentId != null">
and pp.department_id = #{departmentId}
</if>
</where>
</select>
子查询
String getRateByPlanIdAndTimeType(@Param("id") Integer id, @Param("timeType") Integer timeType);
父查询中的timeType,在父查询中创建了虚拟列,就返到子查询中了

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)