写点什么

Mybatis-Plus 集成 YashanDB 时分页功能怎么配置?

作者:数据库砖家
  • 2025-05-15
    广东
  • 本文字数:402 字

    阅读完需:约 1 分钟

问题背景

在使用 Mybatis-Plus 开发项目并接入 YashanDB 时,若未正确配置分页插件或数据库方言,可能导致分页功能失效或报错。

推荐配置方式

使用 Oracle 模式配置(推荐):

pagehelper:helperDialect: oracleMybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.ORACLE));
复制代码

或者使用 MySQL 模式:

pagehelper:helperDialect: mysqlMybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
复制代码

注意事项

插件的方言设置和拦截器 DbType 要保持一致;

控制层建议直接传入 Page 对象,避免业务代码中手动拼接分页 SQL;

避免只创建 Page page = new Page<>() 却未赋值分页参数。

示例代码

Page page = new Page<>(1. 10);List userList = userMapper.selectPage(page, null).getRecords();
复制代码


用户头像

还未添加个人签名 2025-04-09 加入

还未添加个人简介

评论

发布
暂无评论
Mybatis-Plus 集成 YashanDB 时分页功能怎么配置?_数据库_数据库砖家_InfoQ写作社区