diff --git a/changes.md b/changes.md
index 849cf14f..83c788dc 100644
--- a/changes.md
+++ b/changes.md
@@ -17,7 +17,7 @@
- 优化:修改 getPropertySimpleType 方法实现, 防止出现找不到类的问题,感谢 @dcrpp
- 优化:重构将 assertAreNotNull 从 FlexExceptions 移动到 FlexAssert 中,感谢 @Suomm
- 优化:重构 ActiveRecord 的一些方法,避免被 JSON 框架解析,感谢 @Suomm
-- 优化:BaseMapper.updateNumberAddByQuery() 为删除,在未来 v1.6.0 将会从项目里删除
+- 优化:标记 BaseMapper.updateNumberAddByQuery() 为删除,在未来 v1.6.0 将会从项目里删除
- 优化:Maven 的 "artifact xxx has been relocated" 警告的问题,感谢 [@sppan24](https://github.com/sppan24)
- 优化:优化主键逻辑删除处理器逻辑,感谢 @Suomm
- 修复:代码生成器多次调用是出错的问题,感谢 @Suomm
@@ -36,9 +36,6 @@
-
-
-
## v1.5.3 20230725:
- 新增:添加 UpdateChain 方便用于对数据进行更新
- 新增:添加对 ActiveRecord 设计模式的支持,感谢 @Suomm
diff --git a/docs/zh/awesome-things.md b/docs/zh/awesome-things.md
index 7f70816c..e2be073c 100644
--- a/docs/zh/awesome-things.md
+++ b/docs/zh/awesome-things.md
@@ -10,9 +10,9 @@
## 开发插件
-**Mybatis-Flex IDEA**
+**Mybatis-Flex-Helper**
-这是一款高度自定义的 Mybatis-Flex IDEA 代码生成插件:
+这是一款高度自定义的 Mybatis-Flex IDEA 插件(idea 开发工具可以直接搜索安装):
- 开源地址:https://gitee.com/djxchi/mybatis-flex-code-gen.git
- 视频简介:https://www.bilibili.com/video/BV1yV411g7Yd
@@ -20,7 +20,7 @@
## 视频教程
**课程1:《MyBatis-Flex 视频教程》** -- 全网首发(免费)。
-> 课程简介:该课程由 [王帅](https://gitee.com/Suomm) 老师录制主讲, [王帅](https://gitee.com/Suomm) 老师 也是除了作者以外,对 MyBatis-Flex 代码贡献最大的 committer。
+> 课程简介:该课程由 [王帅](https://gitee.com/Suomm) 老师录制主讲, [王帅](https://gitee.com/Suomm) 老师也是除了作者以外,对 MyBatis-Flex 代码贡献最大的 committer。
> 其无论对 MyBatis 还是 MyBatis-Flex,都有非常深入的理解。
课程目录:
@@ -49,3 +49,6 @@
- [MyBatis-Flex 视频教程 - 22 @Id 的简单使用](https://www.bilibili.com/video/BV1Hp4y1571K)
- [MyBatis-Flex 视频教程 - 23 自定义主键生成器](https://www.bilibili.com/video/BV1eM4y1p72z)
- [MyBatis-Flex 视频教程 - 24 @Column 注解的简单使用](https://www.bilibili.com/video/BV14c411w7Fr)
+- [MyBatis-Flex 视频教程 - 25 isLogicDelete 逻辑删除的简单使用](https://www.bilibili.com/video/BV1K94y1e7X7)
+- [MyBatis-Flex 视频教程 - 26 自定义逻辑删除处理器](https://www.bilibili.com/video/BV1oP411z7uu)
+- [MyBatis-Flex 视频教程 - 27 version 乐观锁的简单使用](https://www.bilibili.com/video/BV1Rc411F7wp)
diff --git a/docs/zh/base/chain.md b/docs/zh/base/chain.md
index 1b6db4ba..0206b97a 100644
--- a/docs/zh/base/chain.md
+++ b/docs/zh/base/chain.md
@@ -187,7 +187,7 @@ public class ArticleVo {
ArticleVo articleVo = articleService.queryChain()
.select(
ARTICLE.ALL_COLUMNS,
- max(ARTICLE.comments).as(ArticleVo::maxCommments)
+ max(ARTICLE.comments).as(ArticleVo::maxComments)
).from(ARTICLE)
.where(ARTICLE.ID.ge(100))
.limit(1)
diff --git a/docs/zh/base/mybatis-flex-customizer.md b/docs/zh/base/mybatis-flex-customizer.md
index b1b8d658..cceebf6e 100644
--- a/docs/zh/base/mybatis-flex-customizer.md
+++ b/docs/zh/base/mybatis-flex-customizer.md
@@ -2,7 +2,7 @@
`MyBatisFlexCustomizer` 是 MyBatis-Flex 为了方便 `SpringBoot` 用户对 MyBatis-Flex 进行初始化而产生的接口。
-通过在 `@Configuration` 去实现 `MyBatisFlexCustomizer` 接口,我们可以对 MyBatis-Flex 进行一些列的初始化配置。这些配置可能包含如下的内容:
+通过在 `@Configuration` 去实现 `MyBatisFlexCustomizer` 接口,我们可以对 MyBatis-Flex 进行一系列的初始化配置。这些配置可能包含如下的内容:
- 1、FlexGlobalConfig 的全局配置
- 2、自定义主键生成器
diff --git a/docs/zh/base/parts/base-mapper-update-methods.md b/docs/zh/base/parts/base-mapper-update-methods.md
index 1d7f3217..31a52e85 100644
--- a/docs/zh/base/parts/base-mapper-update-methods.md
+++ b/docs/zh/base/parts/base-mapper-update-methods.md
@@ -6,8 +6,8 @@
- **`updateByCondition(entity, ignoreNulls, whereConditions)`**:根据查询条件来更新数据。
- **`updateByQuery(entity, queryWrapper)`**:根据查询条件来更新数据。
- **`updateByQuery(entity, ignoreNulls, queryWrapper)`**:根据查询条件来更新数据。
-- ~**`updateNumberAddByQuery(fieldName, value, queryWrapper)`**:执行类似 `update table set field = field + 1 where ... `
- 的场景。~
-- ~**`updateNumberAddByQuery(column, value, queryWrapper)`**:执行类似 `update table set field = field + 1 where ... `
- 的场景。~
-- ~**`updateNumberAddByQuery(fn, value, queryWrapper)`**:执行类似 `update table set field = field + 1 where ... ` 的场景。~
+- ~~**`updateNumberAddByQuery(fieldName, value, queryWrapper)`**~~:执行类似 `update table set field = field + 1 where ... `
+ 的场景。
+- ~~**`updateNumberAddByQuery(column, value, queryWrapper)`**~~:执行类似 `update table set field = field + 1 where ... `
+ 的场景。
+- ~~**`updateNumberAddByQuery(fn, value, queryWrapper)`**~~:执行类似 `update table set field = field + 1 where ... ` 的场景。
diff --git a/docs/zh/changes.md b/docs/zh/changes.md
index 849cf14f..83c788dc 100644
--- a/docs/zh/changes.md
+++ b/docs/zh/changes.md
@@ -17,7 +17,7 @@
- 优化:修改 getPropertySimpleType 方法实现, 防止出现找不到类的问题,感谢 @dcrpp
- 优化:重构将 assertAreNotNull 从 FlexExceptions 移动到 FlexAssert 中,感谢 @Suomm
- 优化:重构 ActiveRecord 的一些方法,避免被 JSON 框架解析,感谢 @Suomm
-- 优化:BaseMapper.updateNumberAddByQuery() 为删除,在未来 v1.6.0 将会从项目里删除
+- 优化:标记 BaseMapper.updateNumberAddByQuery() 为删除,在未来 v1.6.0 将会从项目里删除
- 优化:Maven 的 "artifact xxx has been relocated" 警告的问题,感谢 [@sppan24](https://github.com/sppan24)
- 优化:优化主键逻辑删除处理器逻辑,感谢 @Suomm
- 修复:代码生成器多次调用是出错的问题,感谢 @Suomm
@@ -36,9 +36,6 @@
-
-
-
## v1.5.3 20230725:
- 新增:添加 UpdateChain 方便用于对数据进行更新
- 新增:添加对 ActiveRecord 设计模式的支持,感谢 @Suomm
diff --git a/docs/zh/core/audit.md b/docs/zh/core/audit.md
index 59d46870..90985962 100644
--- a/docs/zh/core/audit.md
+++ b/docs/zh/core/audit.md
@@ -6,7 +6,7 @@ SQL 审计是一项非常重要的工作,是企业数据安全体系的重要
## 开启审计功能
-Mybaits-Flex 的 SQL 审计功能,默认是关闭的,若开启审计功能,许添加如下配置。
+Mybaits-Flex 的 SQL 审计功能,默认是关闭的,若开启审计功能,需添加如下配置。
```java
AuditManager.setAuditEnable(true)
diff --git a/docs/zh/core/dynamic-table.md b/docs/zh/core/dynamic-table.md
index e617877d..955b16d6 100644
--- a/docs/zh/core/dynamic-table.md
+++ b/docs/zh/core/dynamic-table.md
@@ -26,7 +26,15 @@ TableManager.setDynamicTableProcessor(new DynamicTableProcessor() {
在某些情况下,我们临时修改映射关系,而非通过 `DynamicTableProcessor.process` 方法获取,可以通过如下配置:
```java
-TableManager.setHintTableMapping("tb_account", "tb_account_01")
+try{
+ TableManager.setHintTableMapping("tb_account", "tb_account_01")
+
+ //这里写您的业务逻辑
+
+}finally{
+ TableManager.clear()
+}
+
```
那么此时,当前线程不再通过 `DynamicTableProcessor` 去获取。
@@ -57,13 +65,13 @@ public class MyConfiguration {
DynamicTableProcessor processor = new ....;
return processor;
}
-
-
+
+
@Bean
public DynamicSchemaProcessor dynamicSchemaProcessor(){
DynamicSchemaProcessor processor = new ....;
return processor;
}
-
+
}
-```
\ No newline at end of file
+```
diff --git a/docs/zh/core/logic-delete.md b/docs/zh/core/logic-delete.md
index 6994d313..9b243248 100644
--- a/docs/zh/core/logic-delete.md
+++ b/docs/zh/core/logic-delete.md
@@ -70,12 +70,12 @@ QueryWrapper query1 = QueryWrapper.create()
```sql
SELECT *
FROM `tb_account`
- LEFT JOIN `tb_article` AS `a` ON `tb_account`.`id` = `a`.`account_id`
+ LEFT JOIN `tb_article` AS `a`
+ ON `a`.`is_delete` = 0 and `tb_account`.`id` = `a`.`account_id`
WHERE `tb_account`.`age` >= 10
AND `tb_account`.`is_delete` = 0
- AND `a`.`is_delete` = 0
```
-自动添加上 `tb_account.is_delete = 0 AND a.is_delete = 0` 条件。
+在 `left join on` 条件自动添加:`a.is_delete = 0`,并在 where 条件添加上 `tb_account.is_delete = 0`。
示例 2:
diff --git a/docs/zh/core/sql-print.md b/docs/zh/core/sql-print.md
index 3c47b169..a8b410b9 100644
--- a/docs/zh/core/sql-print.md
+++ b/docs/zh/core/sql-print.md
@@ -33,7 +33,9 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class MyBatisFlexConfiguration {
- private static final Logger logger = LoggerFactory.getLogger("mybatis-flex-sql");
+ private static final Logger logger = LoggerFactory
+ .getLogger("mybatis-flex-sql");
+
public MyBatisFlexConfiguration() {
//开启审计功能
@@ -41,17 +43,42 @@ public class MyBatisFlexConfiguration {
//设置 SQL 审计收集器
AuditManager.setMessageCollector(auditMessage ->
- logger.info("{},{}ms", auditMessage.getFullSql(), auditMessage.getElapsedTime())
+ logger.info("{},{}ms", auditMessage.getFullSql()
+ , auditMessage.getElapsedTime())
);
}
}
```
-## 注意
-在执行以下语句之后执行的 SQL 才会被打印。如果你发现你有些 SQL 没有打印,则需要自行检查 SQL 执行与以下语句执行的先后顺序。
+## MyBatis 自带方案
+
+### 非 Spring 项目
+
+通过 `bootstrap.setLogImpl()` 方法来指定 MyBatis 输出日志:
+
+```java 5
+DataSource dataSource = ...;
+
+MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance()
+ .setDataSource(dataSource)
+ .setLogImpl(StdOutImpl.class)
+ .addMapper(AccountMapper.class)
+ .start();
```
-AuditManager.setAuditEnable(true);
-AuditManager.setMessageCollector(collector);
+
+### SpringBoot 项目
+
+通过自定义 `ConfigurationCustomizer` 来为 `configuration` 配置 `LogImpl`:
+
+```java
+@Configuration
+public class MyConfigurationCustomizer implements ConfigurationCustomizer {
+
+ @Override
+ public void customize(FlexConfiguration configuration) {
+ configuration.setLogImpl(StdOutImpl.class);
+ }
+}
```
## p6spy 方案
@@ -59,4 +86,4 @@ AuditManager.setMessageCollector(collector);
我们可以把数据源配置为 p6spy 数据源,使用 p6spy 的 SQL 输出功能进行 SQL 打印。更多文档参考 p6spy 官方文档:
[https://p6spy.readthedocs.io/en/latest/index.html](https://p6spy.readthedocs.io/en/latest/index.html)
-使用 SpringBoot 的情况下,参考文档 [https://github.com/gavlyukovskiy/spring-boot-data-source-decorator](https://github.com/gavlyukovskiy/spring-boot-data-source-decorator)
\ No newline at end of file
+使用 SpringBoot 的情况下,参考文档 [https://github.com/gavlyukovskiy/spring-boot-data-source-decorator](https://github.com/gavlyukovskiy/spring-boot-data-source-decorator)
diff --git a/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/RelationOneToMany.java b/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/RelationOneToMany.java
index 9fefdf44..eeafeb08 100644
--- a/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/RelationOneToMany.java
+++ b/mybatis-flex-annotation/src/main/java/com/mybatisflex/annotation/RelationOneToMany.java
@@ -116,7 +116,7 @@ public @interface RelationOneToMany {
*
* @return 数据量
*/
- int limit() default 0;
+ long limit() default 0;
/**
* 默认使用哪个数据源,若系统找不到该指定的数据源时,默认使用第一个数据源。
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java
index 0d7dba30..4413d60a 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java
@@ -240,7 +240,7 @@ public interface BaseMapper {
* @return 受影响的行数
*/
default int deleteByMap(Map whereConditions) {
- FlexAssert.notEmpty(whereConditions, "deleteByMap is not allow empty map.");
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
return deleteByQuery(QueryWrapper.create().where(whereConditions));
}
@@ -251,7 +251,7 @@ public interface BaseMapper {
* @return 受影响的行数
*/
default int deleteByCondition(QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ FlexAssert.notNull(whereConditions, "whereConditions");
return deleteByQuery(QueryWrapper.create().where(whereConditions));
}
@@ -296,7 +296,7 @@ public interface BaseMapper {
* @return 受影响的行数
*/
default int updateByMap(T entity, Map whereConditions) {
- FlexAssert.notEmpty(whereConditions, "updateByMap is not allow empty map.");
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
return updateByQuery(entity, QueryWrapper.create().where(whereConditions));
}
@@ -309,7 +309,7 @@ public interface BaseMapper {
* @return 受影响的行数
*/
default int updateByMap(T entity, boolean ignoreNulls, Map whereConditions) {
- FlexAssert.notEmpty(whereConditions, "updateByMap is not allow empty map.");
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
return updateByQuery(entity, ignoreNulls, QueryWrapper.create().where(whereConditions));
}
@@ -321,7 +321,7 @@ public interface BaseMapper {
* @return 受影响的行数
*/
default int updateByCondition(T entity, QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ FlexAssert.notNull(whereConditions, "whereConditions");
return updateByQuery(entity, QueryWrapper.create().where(whereConditions));
}
@@ -334,7 +334,7 @@ public interface BaseMapper {
* @return 受影响的行数
*/
default int updateByCondition(T entity, boolean ignoreNulls, QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ FlexAssert.notNull(whereConditions, "whereConditions");
return updateByQuery(entity, ignoreNulls, QueryWrapper.create().where(whereConditions));
}
@@ -385,7 +385,7 @@ public interface BaseMapper {
*/
@Deprecated
default int updateNumberAddByQuery(QueryColumn column, Number value, QueryWrapper queryWrapper) {
- FlexAssert.notNull(value, "add value can not be null.");
+ FlexAssert.notNull(value, "value");
return updateNumberAddByQuery(column.getName(), value, queryWrapper);
}
@@ -400,7 +400,7 @@ public interface BaseMapper {
*/
@Deprecated
default int updateNumberAddByQuery(LambdaGetter fn, Number value, QueryWrapper queryWrapper) {
- FlexAssert.notNull(value, "add value can not be null.");
+ FlexAssert.notNull(value, "value");
TableInfo tableInfo = TableInfoFactory.ofMapperClass(ClassUtil.getUsefulClass(getClass()));
String column = tableInfo.getColumnByProperty(LambdaUtil.getFieldName(fn));
return updateNumberAddByQuery(column, value, queryWrapper);
@@ -425,8 +425,8 @@ public interface BaseMapper {
* @return 实体类数据
*/
default T selectOneByMap(Map whereConditions) {
- FlexAssert.notEmpty(whereConditions, "whereConditions map can not be null or empty.");
- return selectOneByQuery(QueryWrapper.create().where(whereConditions).limit(1));
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
+ return selectOneByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
}
/**
@@ -436,8 +436,8 @@ public interface BaseMapper {
* @return 实体类数据
*/
default T selectOneByCondition(QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
- return selectOneByQuery(QueryWrapper.create().where(whereConditions).limit(1));
+ FlexAssert.notNull(whereConditions, "whereConditions");
+ return selectOneByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
}
/**
@@ -468,8 +468,8 @@ public interface BaseMapper {
* @return 实体类数据
*/
default T selectOneWithRelationsByMap(Map whereConditions) {
- FlexAssert.notEmpty(whereConditions, "whereConditions map can not be null or empty.");
- return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1));
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
+ return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
}
/**
@@ -479,8 +479,8 @@ public interface BaseMapper {
* @return 实体类数据
*/
default T selectOneWithRelationsByCondition(QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
- return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1));
+ FlexAssert.notNull(whereConditions, "whereConditions");
+ return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
}
/**
@@ -545,7 +545,7 @@ public interface BaseMapper {
* @return 数据列表
*/
default List selectListByMap(Map whereConditions) {
- FlexAssert.notEmpty(whereConditions, "whereConditions map can not be null or empty.");
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
return selectListByQuery(QueryWrapper.create().where(whereConditions));
}
@@ -556,8 +556,8 @@ public interface BaseMapper {
* @param count 数据量
* @return 数据列表
*/
- default List selectListByMap(Map whereConditions, int count) {
- FlexAssert.notEmpty(whereConditions, "whereConditions map can not be null or empty.");
+ default List selectListByMap(Map whereConditions, Long count) {
+ FlexAssert.notEmpty(whereConditions, "whereConditions");
return selectListByQuery(QueryWrapper.create().where(whereConditions).limit(count));
}
@@ -568,7 +568,7 @@ public interface BaseMapper {
* @return 数据列表
*/
default List selectListByCondition(QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ FlexAssert.notNull(whereConditions, "whereConditions");
return selectListByQuery(QueryWrapper.create().where(whereConditions));
}
@@ -579,8 +579,8 @@ public interface BaseMapper {
* @param count 数据量
* @return 数据列表
*/
- default List selectListByCondition(QueryCondition whereConditions, int count) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ default List selectListByCondition(QueryCondition whereConditions, Long count) {
+ FlexAssert.notNull(whereConditions, "whereConditions");
return selectListByQuery(QueryWrapper.create().where(whereConditions).limit(count));
}
@@ -849,7 +849,7 @@ public interface BaseMapper {
* @return 数据量
*/
default long selectCountByCondition(QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ FlexAssert.notNull(whereConditions, "whereConditions");
return selectCountByQuery(QueryWrapper.create().where(whereConditions));
}
@@ -861,7 +861,7 @@ public interface BaseMapper {
* @param queryWrapper 条件
* @return 分页数据
*/
- default Page paginate(int pageNumber, int pageSize, QueryWrapper queryWrapper) {
+ default Page paginate(Number pageNumber, Number pageSize, QueryWrapper queryWrapper) {
Page page = new Page<>(pageNumber, pageSize);
return paginate(page, queryWrapper);
}
@@ -874,7 +874,7 @@ public interface BaseMapper {
* @param queryWrapper 条件
* @return 分页数据
*/
- default Page paginateWithRelations(int pageNumber, int pageSize, QueryWrapper queryWrapper) {
+ default Page paginateWithRelations(Number pageNumber, Number pageSize, QueryWrapper queryWrapper) {
Page page = new Page<>(pageNumber, pageSize);
return paginateWithRelations(page, queryWrapper);
}
@@ -887,7 +887,7 @@ public interface BaseMapper {
* @param whereConditions 条件
* @return 分页数据
*/
- default Page paginate(int pageNumber, int pageSize, QueryCondition whereConditions) {
+ default Page paginate(Number pageNumber, Number pageSize, QueryCondition whereConditions) {
Page page = new Page<>(pageNumber, pageSize);
return paginate(page, new QueryWrapper().where(whereConditions));
}
@@ -900,7 +900,7 @@ public interface BaseMapper {
* @param whereConditions 条件
* @return 分页数据
*/
- default Page paginateWithRelations(int pageNumber, int pageSize, QueryCondition whereConditions) {
+ default Page paginateWithRelations(Number pageNumber, Number pageSize, QueryCondition whereConditions) {
Page page = new Page<>(pageNumber, pageSize);
return paginateWithRelations(page, new QueryWrapper().where(whereConditions));
}
@@ -914,7 +914,7 @@ public interface BaseMapper {
* @param queryWrapper 条件
* @return 分页数据
*/
- default Page paginate(int pageNumber, int pageSize, int totalRow, QueryWrapper queryWrapper) {
+ default Page paginate(Number pageNumber, Number pageSize, Number totalRow, QueryWrapper queryWrapper) {
Page page = new Page<>(pageNumber, pageSize, totalRow);
return paginate(page, queryWrapper);
}
@@ -928,7 +928,7 @@ public interface BaseMapper {
* @param queryWrapper 条件
* @return 分页数据
*/
- default Page paginateWithRelations(int pageNumber, int pageSize, int totalRow, QueryWrapper queryWrapper) {
+ default Page paginateWithRelations(Number pageNumber, Number pageSize, Number totalRow, QueryWrapper queryWrapper) {
Page page = new Page<>(pageNumber, pageSize, totalRow);
return paginateWithRelations(page, queryWrapper);
}
@@ -942,8 +942,8 @@ public interface BaseMapper {
* @param whereConditions 条件
* @return 分页数据
*/
- default Page paginate(int pageNumber, int pageSize, int totalRow, QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ default Page paginate(Number pageNumber, Number pageSize, Number totalRow, QueryCondition whereConditions) {
+ FlexAssert.notNull(whereConditions, "whereConditions");
Page page = new Page<>(pageNumber, pageSize, totalRow);
return paginate(page, new QueryWrapper().where(whereConditions));
}
@@ -957,8 +957,8 @@ public interface BaseMapper {
* @param whereConditions 条件
* @return 分页数据
*/
- default Page paginateWithRelations(int pageNumber, int pageSize, int totalRow, QueryCondition whereConditions) {
- FlexAssert.notNull(whereConditions, "whereConditions can not be null.");
+ default Page paginateWithRelations(Number pageNumber, Number pageSize, Number totalRow, QueryCondition whereConditions) {
+ FlexAssert.notNull(whereConditions, "whereConditions");
Page page = new Page<>(pageNumber, pageSize, totalRow);
return paginateWithRelations(page, new QueryWrapper().where(whereConditions));
}
@@ -1018,7 +1018,7 @@ public interface BaseMapper {
* @param asType 接收数据类型
* @return 分页数据
*/
- default Page paginateAs(int pageNumber, int pageSize, QueryWrapper queryWrapper, Class asType) {
+ default Page paginateAs(Number pageNumber, Number pageSize, QueryWrapper queryWrapper, Class asType) {
Page page = new Page<>(pageNumber, pageSize);
return MapperUtil.doPaginate(this, page, queryWrapper, asType, false);
}
@@ -1033,7 +1033,7 @@ public interface BaseMapper {
* @param asType 接收数据类型
* @return 分页数据
*/
- default Page paginateAs(int pageNumber, int pageSize, int totalRow, QueryWrapper queryWrapper, Class asType) {
+ default Page paginateAs(Number pageNumber, Number pageSize, Number totalRow, QueryWrapper queryWrapper, Class asType) {
Page page = new Page<>(pageNumber, pageSize, totalRow);
return MapperUtil.doPaginate(this, page, queryWrapper, asType, false);
}
@@ -1072,7 +1072,7 @@ public interface BaseMapper {
* @param asType 接收数据类型
* @return 分页数据
*/
- default Page paginateWithRelationsAs(int pageNumber, int pageSize, QueryWrapper queryWrapper, Class asType) {
+ default Page paginateWithRelationsAs(Number pageNumber, Number pageSize, QueryWrapper queryWrapper, Class asType) {
Page page = new Page<>(pageNumber, pageSize);
return MapperUtil.doPaginate(this, page, queryWrapper, asType, true);
}
@@ -1087,7 +1087,7 @@ public interface BaseMapper {
* @param asType 接收数据类型
* @return 分页数据
*/
- default Page paginateWithRelationsAs(int pageNumber, int pageSize, int totalRow, QueryWrapper queryWrapper, Class asType) {
+ default Page paginateWithRelationsAs(Number pageNumber, Number pageSize, Number totalRow, QueryWrapper queryWrapper, Class asType) {
Page page = new Page<>(pageNumber, pageSize, totalRow);
return MapperUtil.doPaginate(this, page, queryWrapper, asType, true);
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java
index 16aeebcd..0e4f5901 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java
@@ -21,6 +21,7 @@ import com.mybatisflex.annotation.SetListener;
import com.mybatisflex.annotation.UpdateListener;
import com.mybatisflex.core.datasource.FlexDataSource;
import com.mybatisflex.core.dialect.DbType;
+import com.mybatisflex.core.exception.FlexAssert;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
@@ -307,9 +308,7 @@ public class FlexGlobalConfig {
}
public void setNormalValueOfLogicDelete(Object normalValueOfLogicDelete) {
- if (normalValueOfLogicDelete == null) {
- throw new NullPointerException("normalValueOfLogicDelete can not be null.");
- }
+ FlexAssert.notNull(normalValueOfLogicDelete,"normalValueOfLogicDelete");
this.normalValueOfLogicDelete = normalValueOfLogicDelete;
}
@@ -318,9 +317,7 @@ public class FlexGlobalConfig {
}
public void setDeletedValueOfLogicDelete(Object deletedValueOfLogicDelete) {
- if (deletedValueOfLogicDelete == null) {
- throw new NullPointerException("deletedValueOfLogicDelete can not be null.");
- }
+ FlexAssert.notNull(deletedValueOfLogicDelete,"deletedValueOfLogicDelete");
this.deletedValueOfLogicDelete = deletedValueOfLogicDelete;
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/MybatisFlexBootstrap.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/MybatisFlexBootstrap.java
index 87c80fd0..5817a037 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/MybatisFlexBootstrap.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/MybatisFlexBootstrap.java
@@ -16,6 +16,7 @@
package com.mybatisflex.core;
import com.mybatisflex.core.datasource.FlexDataSource;
+import com.mybatisflex.core.exception.FlexAssert;
import com.mybatisflex.core.mybatis.FlexConfiguration;
import com.mybatisflex.core.mybatis.FlexSqlSessionFactoryBuilder;
import com.mybatisflex.core.mybatis.Mappers;
@@ -92,9 +93,8 @@ public class MybatisFlexBootstrap {
public MybatisFlexBootstrap start() {
if (started.compareAndSet(false, true)) {
- if (dataSource == null) {
- throw new IllegalStateException("dataSource can not be null.");
- }
+
+ FlexAssert.notNull(dataSource,"dataSource");
//init configuration
if (configuration == null) {
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java
index cfa2ac2a..ceb382f6 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java
@@ -356,17 +356,17 @@ public abstract class QueryModel> {
return new OrderByBuilder<>((T) this, column);
}
- public T limit(Integer rows) {
+ public T limit(Number rows) {
queryWrapper().limit(rows);
return (T) this;
}
- public T offset(Integer offset) {
+ public T offset(Number offset) {
queryWrapper().offset(offset);
return (T) this;
}
- public T limit(Integer offset, Integer rows) {
+ public T limit(Number offset, Number rows) {
queryWrapper().limit(offset, rows);
return (T) this;
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/IDialect.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/IDialect.java
index d122038f..1403c4ee 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/IDialect.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/IDialect.java
@@ -22,6 +22,9 @@ import com.mybatisflex.core.table.TableManager;
import java.util.List;
+/**
+ * @author michael
+ */
public interface IDialect {
String wrap(String keyword);
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java
index 34d3b081..21f79b45 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java
@@ -39,7 +39,7 @@ public interface LimitOffsetProcessor {
* @param limitRows 用户传入的 limit 参数 可能为 null
* @param limitOffset 用户传入的 offset 参数,可能为 null
*/
- StringBuilder process(IDialect dialect, StringBuilder sql, QueryWrapper queryWrapper, Integer limitRows, Integer limitOffset);
+ StringBuilder process(IDialect dialect, StringBuilder sql, QueryWrapper queryWrapper, Long limitRows, Long limitOffset);
/**
@@ -110,7 +110,7 @@ public interface LimitOffsetProcessor {
LimitOffsetProcessor SQLSERVER_2005 = (dialect, sql, queryWrapper, limitRows, limitOffset) -> {
if (limitRows != null) {
if (limitOffset == null) {
- limitOffset = 0;
+ limitOffset = 0L;
}
List queryTables = CPI.getQueryTables(queryWrapper);
@@ -196,7 +196,7 @@ public interface LimitOffsetProcessor {
LimitOffsetProcessor ORACLE = (dialect, sql, queryWrapper, limitRows, limitOffset) -> {
if (limitRows != null) {
if (limitOffset == null) {
- limitOffset = 0;
+ limitOffset = 0L;
}
StringBuilder newSql = new StringBuilder("SELECT * FROM (SELECT TEMP_DATAS.*, ROWNUM RN FROM (");
newSql.append(sql);
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/impl/CommonsDialectImpl.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/impl/CommonsDialectImpl.java
index 15604172..5067e4ea 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/impl/CommonsDialectImpl.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/impl/CommonsDialectImpl.java
@@ -382,8 +382,8 @@ public class CommonsDialectImpl implements IDialect {
}
}
- Integer limitRows = CPI.getLimitRows(queryWrapper);
- Integer limitOffset = CPI.getLimitOffset(queryWrapper);
+ Long limitRows = CPI.getLimitRows(queryWrapper);
+ Long limitOffset = CPI.getLimitOffset(queryWrapper);
if (limitRows != null || limitOffset != null) {
sqlBuilder = buildLimitOffsetSql(sqlBuilder, queryWrapper, limitRows, limitOffset);
}
@@ -418,8 +418,8 @@ public class CommonsDialectImpl implements IDialect {
}
}
- Integer limitRows = CPI.getLimitRows(queryWrapper);
- Integer limitOffset = CPI.getLimitOffset(queryWrapper);
+ Long limitRows = CPI.getLimitRows(queryWrapper);
+ Long limitOffset = CPI.getLimitOffset(queryWrapper);
if (limitRows != null || limitOffset != null) {
sqlBuilder = buildLimitOffsetSql(sqlBuilder, queryWrapper, limitRows, limitOffset);
}
@@ -782,8 +782,8 @@ public class CommonsDialectImpl implements IDialect {
Set updateColumns = tableInfo.obtainUpdateColumns(entity, ignoreNulls, true);
Map rawValueMap = tableInfo.obtainUpdateRawValueMap(entity);
- sql.append(UPDATE).append(forHint(CPI.getHint(queryWrapper)))
- .append(tableInfo.getWrapSchemaAndTableName(this)).append(SET);
+ sql.append(UPDATE).append(forHint(CPI.getHint(queryWrapper)));
+ sql.append(tableInfo.getWrapSchemaAndTableName(this)).append(SET);
StringJoiner stringJoiner = new StringJoiner(DELIMITER);
@@ -814,7 +814,7 @@ public class CommonsDialectImpl implements IDialect {
//不允许全量更新
if (StringUtil.isBlank(whereConditionSql)) {
- throw new IllegalArgumentException("Not allowed UPDATE a table without where condition.");
+ throw FlexExceptions.wrap(LocalizedFormats.UPDATE_OR_DELETE_NOT_ALLOW);
}
sql.append(WHERE).append(whereConditionSql);
@@ -844,7 +844,7 @@ public class CommonsDialectImpl implements IDialect {
//不允许全量更新
if (StringUtil.isBlank(whereConditionSql)) {
- throw new IllegalArgumentException("Not allowed UPDATE a table without where condition.");
+ throw FlexExceptions.wrap(LocalizedFormats.UPDATE_OR_DELETE_NOT_ALLOW);
}
sql.append(WHERE).append(whereConditionSql);
@@ -993,12 +993,12 @@ public class CommonsDialectImpl implements IDialect {
if (StringUtil.isNotBlank(whereSql)) {
sqlBuilder.append(WHERE).append(whereSql);
} else if (!allowNoCondition) {
- throw new IllegalArgumentException("Not allowed DELETE or UPDATE a table without where condition.");
+ throw FlexExceptions.wrap(LocalizedFormats.UPDATE_OR_DELETE_NOT_ALLOW);
}
} else {
// whereQueryCondition == null
if (!allowNoCondition) {
- throw new IllegalArgumentException("Not allowed DELETE or UPDATE a table without where condition.");
+ throw FlexExceptions.wrap(LocalizedFormats.UPDATE_OR_DELETE_NOT_ALLOW);
}
}
}
@@ -1051,7 +1051,7 @@ public class CommonsDialectImpl implements IDialect {
/**
* 构建 limit 和 offset 的参数
*/
- protected StringBuilder buildLimitOffsetSql(StringBuilder sqlBuilder, QueryWrapper queryWrapper, Integer limitRows, Integer limitOffset) {
+ protected StringBuilder buildLimitOffsetSql(StringBuilder sqlBuilder, QueryWrapper queryWrapper, Long limitRows, Long limitOffset) {
return limitOffsetProcessor.process(this, sqlBuilder, queryWrapper, limitRows, limitOffset);
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/FlexAssert.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/FlexAssert.java
index a329919a..59bd3a34 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/FlexAssert.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/FlexAssert.java
@@ -16,6 +16,8 @@
package com.mybatisflex.core.exception;
+import com.mybatisflex.core.exception.locale.LocalizedFormats;
+
import java.util.Collection;
import java.util.Map;
@@ -23,6 +25,8 @@ import java.util.Map;
* 断言。
*
* @author 王帅
+ * @author michael
+ *
* @since 2023-07-08
*/
public final class FlexAssert {
@@ -33,26 +37,27 @@ public final class FlexAssert {
/**
* 断言对象不为空,如果为空抛出异常,并指明哪个对象为空。
*
- * @param obj 对象
- * @param message 错误消息
+ * @param obj 对象
+ * @param param 错误消息参数
* @throws MybatisFlexException 如果对象为空,抛出此异常。
*/
- public static void notNull(Object obj, String message) {
+ public static void notNull(Object obj, String param) {
if (obj == null) {
- throw FlexExceptions.wrap(message);
+ throw FlexExceptions.wrap(LocalizedFormats.OBJECT_NULL, param);
}
}
+
/**
* 断言 Map 集合不为 {@code null} 或者空集合,如果为空则抛出异常,并指明为什么不允许为空集合。
*
- * @param map Map 集合
- * @param message 错误消息
+ * @param map Map 集合
+ * @param param 错误消息参数
* @throws MybatisFlexException 如果集合为空,抛出此异常。
*/
- public static void notEmpty(Map, ?> map, String message) {
+ public static void notEmpty(Map, ?> map, String param) {
if (map == null || map.isEmpty()) {
- throw FlexExceptions.wrap(message);
+ throw FlexExceptions.wrap(LocalizedFormats.MAP_NULL_OR_EMPTY, param);
}
}
@@ -60,25 +65,25 @@ public final class FlexAssert {
* 断言集合不为 {@code null} 或者空集合,如果为空则抛出异常,并指明为什么不允许为空集合。
*
* @param collection 集合
- * @param message 错误消息
+ * @param param 错误消息参数
* @throws MybatisFlexException 如果集合为空,抛出此异常。
*/
- public static void notEmpty(Collection> collection, String message) {
+ public static void notEmpty(Collection> collection, String param) {
if (collection == null || collection.isEmpty()) {
- throw FlexExceptions.wrap(message);
+ throw FlexExceptions.wrap(LocalizedFormats.MAP_NULL_OR_EMPTY, param);
}
}
/**
* 断言数组不为 {@code null} 或者空数组,如果为空则抛出异常,并指明为什么不允许为空数组。
*
- * @param array 数组
- * @param message 错误消息
+ * @param array 数组
+ * @param param 错误消息参数
* @throws MybatisFlexException 如果数组为空,抛出此异常。
*/
- public static void notEmpty(T[] array, String message) {
+ public static void notEmpty(T[] array, String param) {
if (array == null || array.length == 0) {
- throw FlexExceptions.wrap(message);
+ throw FlexExceptions.wrap(param);
}
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/locale/LocalizedFormats.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/locale/LocalizedFormats.java
index f8e1d059..e3848311 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/locale/LocalizedFormats.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/exception/locale/LocalizedFormats.java
@@ -34,17 +34,22 @@ public enum LocalizedFormats implements Localizable {
* object can not be null
*/
OBJECT_NULL("{0} can not be null."),
+ OBJECT_NULL_OR_BLANK("{0} can not be null or blank."),
+ MAP_NULL_OR_EMPTY("{0} can not be null or empty."),
+ ARRAY_NULL_OR_EMPTY("{0} array can not be null or empty."),
DATASOURCE_TYPE_BLANK("The dataSource type can not be null or blank."),
DATASOURCE_TYPE_NOT_FIND("Can not find the dataSource type: {0}"),
- DATASOURCE_CAN_NOT_INSTANCE("Can not new instance dataSource object by class: {0}"),
+ DATASOURCE_CAN_NOT_INSTANCE("Can not new instance dataSource object by class: {0}"),
DATASOURCE_JDBC_URL("Can not get the dataSource jdbcUrl."),
UPDATE_ONLY_SUPPORT_1_TABLE("\"UpdateByQuery\" only support 1 table."),
+ UPDATE_OR_DELETE_NOT_ALLOW("Not allowed \"UPDATE\" or \"DELETE\" a table without where condition."),
- ENTITY_VERSION_NULL("The version value of entity[{0}] must not be null."),
+
+ ENTITY_VERSION_NULL("The version value of entity \"{0}\" must not be null."),
;
private final String sourceFormat;
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/logicdelete/impl/PrimaryKeyLogicDeleteProcessor.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/logicdelete/impl/PrimaryKeyLogicDeleteProcessor.java
index d9a8739a..d4943f4c 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/logicdelete/impl/PrimaryKeyLogicDeleteProcessor.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/logicdelete/impl/PrimaryKeyLogicDeleteProcessor.java
@@ -37,9 +37,9 @@ public class PrimaryKeyLogicDeleteProcessor extends NullableColumnLogicDeletePro
@Override
public String buildLogicDeletedSet(String logicColumn, TableInfo tableInfo, IDialect dialect) {
- List primaryKeyList = tableInfo.getPrimaryKeyList();
- FlexAssert.notEmpty(primaryKeyList, "Entity must have one primary key.");
- String column = primaryKeyList.get(0).getColumn();
+ List primaryKeys = tableInfo.getPrimaryKeyList();
+ FlexAssert.notEmpty(primaryKeys, "primaryKeys");
+ String column = primaryKeys.get(0).getColumn();
return dialect.wrap(logicColumn) + EQUALS + dialect.wrap(column);
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java
index c364091d..8727d865 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/FlexConfiguration.java
@@ -53,7 +53,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class FlexConfiguration extends Configuration {
- private static Map dynamicMappedStatementCache = new ConcurrentHashMap<>();
+ private static final Map dynamicMappedStatementCache = new ConcurrentHashMap<>();
public FlexConfiguration(Environment environment) {
super(environment);
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/Mappers.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/Mappers.java
index dda16903..1efb8a73 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/Mappers.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/mybatis/Mappers.java
@@ -23,14 +23,10 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.util.MapUtil;
-import java.lang.invoke.MethodHandles;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -51,6 +47,7 @@ public class Mappers {
/**
* 通过 entity Class 获取 Mapper 对象
+ *
* @param entityClass
* @param
* @return mapper 对象
@@ -58,7 +55,7 @@ public class Mappers {
public static BaseMapper ofEntityClass(Class entityClass) {
Class> mapperClass = ENTITY_MAPPER_MAP.get(entityClass);
if (mapperClass == null) {
- throw FlexExceptions.wrap("Can not find MapperClass by entity: " + entityClass);
+ throw FlexExceptions.wrap("Can not find MapperClass by entity: " + entityClass.getName());
}
return (BaseMapper) ofMapperClass(mapperClass);
}
@@ -79,10 +76,8 @@ public class Mappers {
}
-
static class MapperHandler implements InvocationHandler {
- private static final Set ignoreMethods = new HashSet<>(Arrays.asList("queryChain","updateChain"));
- private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
+
private Class> mapperClass;
private final SqlSessionFactory sqlSessionFactory = FlexGlobalConfig.getDefaultConfig().getSqlSessionFactory();
private final ExecutorType executorType = FlexGlobalConfig.getDefaultConfig().getConfiguration().getDefaultExecutorType();
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java
index d14b50bc..8592e53e 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java
@@ -44,12 +44,12 @@ public class Page implements Serializable {
/**
* 当前页码。
*/
- private int pageNumber = 1;
+ private long pageNumber = 1;
/**
* 每页数据数量。
*/
- private int pageSize = FlexGlobalConfig.getDefaultConfig().getDefaultPageSize();
+ private long pageSize = FlexGlobalConfig.getDefaultConfig().getDefaultPageSize();
/**
* 总页数。
@@ -74,7 +74,7 @@ public class Page implements Serializable {
* @param 数据类型
* @return 分页对象
*/
- public static Page of(int pageNumber, int pageSize) {
+ public static Page of(Number pageNumber, Number pageSize) {
return new Page<>(pageNumber, pageSize);
}
@@ -87,7 +87,7 @@ public class Page implements Serializable {
* @param 数据类型
* @return 分页对象
*/
- public static Page of(int pageNumber, int pageSize, long totalRow) {
+ public static Page of(Number pageNumber, Number pageSize, Number totalRow) {
return new Page<>(pageNumber, pageSize, totalRow);
}
@@ -103,7 +103,7 @@ public class Page implements Serializable {
* @param pageNumber 当前页码
* @param pageSize 每页数据数量
*/
- public Page(int pageNumber, int pageSize) {
+ public Page(Number pageNumber, Number pageSize) {
this.setPageNumber(pageNumber);
this.setPageSize(pageSize);
}
@@ -115,7 +115,7 @@ public class Page implements Serializable {
* @param pageSize 每页数据数量
* @param totalRow 总数居数量
*/
- public Page(int pageNumber, int pageSize, long totalRow) {
+ public Page(Number pageNumber, Number pageSize, Number totalRow) {
this.setPageNumber(pageNumber);
this.setPageSize(pageSize);
this.setTotalRow(totalRow);
@@ -129,7 +129,7 @@ public class Page implements Serializable {
* @param pageSize 每页数据数量
* @param totalRow 总数居数量
*/
- public Page(List records, int pageNumber, int pageSize, long totalRow) {
+ public Page(List records, Number pageNumber, Number pageSize, Number totalRow) {
this.setRecords(records);
this.setPageNumber(pageNumber);
this.setPageSize(pageSize);
@@ -162,7 +162,7 @@ public class Page implements Serializable {
*
* @return 页码
*/
- public int getPageNumber() {
+ public long getPageNumber() {
return pageNumber;
}
@@ -171,11 +171,11 @@ public class Page implements Serializable {
*
* @param pageNumber 页码
*/
- public void setPageNumber(int pageNumber) {
- if (pageNumber < 1) {
+ public void setPageNumber(Number pageNumber) {
+ if (pageNumber.longValue() < 1) {
throw new IllegalArgumentException("pageNumber must greater than or equal 1,current value is: " + pageNumber);
}
- this.pageNumber = pageNumber;
+ this.pageNumber = pageNumber.longValue();
}
/**
@@ -183,7 +183,7 @@ public class Page implements Serializable {
*
* @return 每页数据数量
*/
- public int getPageSize() {
+ public long getPageSize() {
return pageSize;
}
@@ -192,11 +192,11 @@ public class Page implements Serializable {
*
* @param pageSize 每页数据数量
*/
- public void setPageSize(int pageSize) {
- if (pageSize < 0) {
+ public void setPageSize(Number pageSize) {
+ if (pageSize.longValue() < 0) {
throw new IllegalArgumentException("pageSize must greater than or equal 0,current value is: " + pageSize);
}
- this.pageSize = pageSize;
+ this.pageSize = pageSize.longValue();
this.calcTotalPage();
}
@@ -232,8 +232,8 @@ public class Page implements Serializable {
*
* @param totalRow 数据总数
*/
- public void setTotalRow(long totalRow) {
- this.totalRow = totalRow;
+ public void setTotalRow(Number totalRow) {
+ this.totalRow = totalRow.longValue();
this.calcTotalPage();
}
@@ -280,7 +280,7 @@ public class Page implements Serializable {
*
* @return 偏移量
*/
- public int offset() {
+ public long offset() {
return getPageSize() * (getPageNumber() - 1);
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/provider/EntitySqlProvider.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/provider/EntitySqlProvider.java
index 4661d83f..c77cf81b 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/provider/EntitySqlProvider.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/provider/EntitySqlProvider.java
@@ -52,7 +52,7 @@ public class EntitySqlProvider {
public static String insert(Map params, ProviderContext context) {
Object entity = ProviderUtil.getEntity(params);
- FlexAssert.notNull(entity, "entity can not be null.");
+ FlexAssert.notNull(entity, "entity");
boolean ignoreNulls = ProviderUtil.isIgnoreNulls(params);
@@ -88,7 +88,7 @@ public class EntitySqlProvider {
public static String insertWithPk(Map params, ProviderContext context) {
Object entity = ProviderUtil.getEntity(params);
- FlexAssert.notNull(entity, "entity can not be null.");
+ FlexAssert.notNull(entity, "entity");
boolean ignoreNulls = ProviderUtil.isIgnoreNulls(params);
@@ -125,7 +125,7 @@ public class EntitySqlProvider {
public static String insertBatch(Map params, ProviderContext context) {
List