现在想通过父查询把参数start,end传到子查询中
父查询
@Select("select * from tb_enterprise_watch where id = #{enterpriseWatchId}")
@Results({
@Result(id=true,property = "id",column = "id"),
@Result(id=true,property = "watchId",column = "watch_id"),
@Result(property="positions",column="watch_id=watch_id,start=#{start},end=#{end}",many = @Many(select="com.uwhere.dal.mapper.TbWatchPositionMapper.findPathByWatchId"))
})
TbEnterpriseWatch getPathByWatchId(@Param("enterpriseWatchId") Long enterpriseWatchId, @Param("start")Date start,@Param("end")Date end);
子查询
@Select("SELECT * FROM tb_watch_position " +
"WHERE gmt_create >= #{start} " +
"AND gmt_create <= #{end} " +
"AND watch_id=#{watchId} " +
"ORDER BY gmt_create")
public List<TbWatchPosition> findPathsByWatchId(@Param("watchId") Long watchId,
@Param("start") Date dateStart, @Param("end") Date dateEnd);
1、getPathByWatchId()方法返回的是TbEnterpriseWatch实体类,findPathsByWatchId()方法的形参为什么不用TbEnterpriseWatch实体类呢?
2、没看出来有你说的父查询和子查询的关系;
3、如果只是参数传递的问题,一个查询的结果作为另一个查询的参数,这种情况很常见,你在Service层处理问题不大。