关于Mybatis 分页
电脑版发表于:2021/10/25 16:56
方法调用
持久层接口
List<mattersJionDto> queryBuildJoin(@Param("str_rows") String str_rows,@Param("rows") Integer rows,
@Param("pages") Integer pages, @Param("build_Name")String build_Name);mapper的xml
<!-- 在mapper的写法 -->
<select id="queryBuildJoin" resultType="mattersJionDto">
select <if test="rows!=null">top ${str_rows} </if> b.build_Name,m.matter_Name,m.matter_Number,m.end_time
from Builds b join Matters m on b.Id=m.build_id
<where>
<if test="build_Name!=null">and b.build_Name=#{build_Name}</if>
<if test="pages!=null">and b.Id not
in( select top (#{rows}*(#{pages}-1)) Id from Builds order by Id)
</if>
</where>
</select>
