RowBounds分页类

版权声明:@渔闻520 https://blog.csdn.net/weixin_41060905/article/details/86622607

只要给接口增加一个RowBounds传输就可以了。

//下面测试MyBatis自带的分页类RowBounds功能
    public  List<Role> findByRowBounds(@Param("roleName")String rolename, @Param("note") String note, RowBounds rowBounds);

而映射文件不需要任何的RowBounds内容的配置:

<!--测试RowBounds的分页功能-->
    <select id="findByRowBounds" resultType="role" >
        select id ,role_name as roleName,note from t_role where role_name like concat('%',#{roleName},'%')
        and note like concat('%',#{note},'%')
    </select>

使用的时候:

 //下面是测试MyBatis自带的RowBounds的分页类
                        RowBounds rowBounds = new RowBounds(0, 1);
                        List<Role> roleList = roleMapper.findByRowBounds("江", "学", rowBounds);
                        log.info(String.valueOf(roleList.size()));

注意,如果对于大量的数据查询,这样的效率并不高,这个时候可以使用分页插件来处理分页功能。

猜你喜欢

转载自blog.csdn.net/weixin_41060905/article/details/86622607