From a0ed39881beb3cf0c2811c9960c89a11140a0ec4 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Sat, 30 Dec 2017 04:07:44 +0800 Subject: [PATCH 001/933] Improve Chinese documentation quality --- src/site/zh/xdoc/getting-started.xml.vm | 35 ++++++------- src/site/zh/xdoc/index.xml | 66 +++++++++++-------------- 2 files changed, 46 insertions(+), 55 deletions(-) diff --git a/src/site/zh/xdoc/getting-started.xml.vm b/src/site/zh/xdoc/getting-started.xml.vm index 36e608d864..4c741dce71 100644 --- a/src/site/zh/xdoc/getting-started.xml.vm +++ b/src/site/zh/xdoc/getting-started.xml.vm @@ -20,26 +20,24 @@ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0%20http://maven.apache.org/xsd/xdoc-2.0.xsd"> - MyBatis-Spring | 第二章 入门 + MyBatis-Spring | 入门 Hunter Presnall Eduardo Macarron Nan Lei -
+

-本章将会以简略的步骤告诉你如何安装和创建 MyBatis-Spring,并构建一个简单的数据访问事务性的应用程序。 + 本章将会以简略的步骤告诉你如何安装和创建 MyBatis-Spring,并构建一个简单的数据访问事务性的应用程序。

-要使用MyBatis-Spring模块,只需要在类路径下包含 - mybatis-spring-${project.version}.jar -文件和相关依赖。 + 要使用 MyBatis-Spring 模块,只需要在类路径下包含 mybatis-spring-${project.version}.jar 文件和相关依赖即可。

-如果使用Maven,仅需要在pom.xml中加入以下代码即可: + 如果使用Maven,仅需要在pom.xml中加入以下代码即可:

@@ -51,11 +49,12 @@

-要和Spring一起使用MyBatis,需要在Spring应用上下文中定义至少两样东西:一个SqlSessionFactory和至少一个数据映射器类。 + 要和 Spring 一起使用 MyBatis,需要在 Spring 应用上下文中定义至少两样东西:一个 SqlSessionFactory 和至少一个数据映射器类。

-在MyBatis-Spring中,可使用SqlSessionFactoryBean来创建SqlSessionFactory。要配置这个工厂bean,只需要把下面代码放在Spring的XML配置文件中: + 在 MyBatis-Spring 中,可使用 SqlSessionFactoryBean来创建 SqlSessionFactory。 + 要配置这个工厂 bean,只需要把下面代码放在 Spring 的 XML 配置文件中:

-需要注意的是:SqlSessionFactory需要一个DataSource(数据源,译者注)。这可以是任意的DataSource,配置它就和配置其它Spring数据库连接一样。 + 注意:SqlSessionFactory 需要一个 DataSource(数据源,译者注)。 + 这可以是任意的 DataSource,只需要和配置其它 Spring 数据库连接一样配置它就可以了。

-假设你定义了一个如下的mapper接口: + 假设你定义了一个如下的 mapper 接口:

-那么可以通过MapperFactoryBean像下面那样把接口加入到Spring中: + 那么可以通过 MapperFactoryBean 将接口加入到 Spring 中:

]]>

-需要注意的是:所指定的映射器类必须是一个接口,而不是具体的实现类。在这个示例中通过注解来指定SQL语句,但是通过MyBatis映射器的XML文件也行。 + 需要注意的是:所指定的映射器类必须是一个接口,而不是具体的实现类。在这个示例中,通过注解来指定 SQL 语句,但是也可以使用 MyBatis mapper 的 XML 配置文件。

-一旦完成配置,你可以像其它Spring中的bean注入方法将映射器到业务(bussiness)或服务(service)对象中。MapperFactoryBean用来处理SqlSession的创建和关闭动作。 -如果使用了Spring的事务,那么当事务完成时,session将会被提交或回滚。最终任何异常都会被翻译成Spring的DataAccessException异常。 + 配置好之后,你就可以像 Spring 中普通的 bean 注入方法那样,将 mapper 注入到你的业务(bussiness)或服务(service)对象中。 + MapperFactoryBean 将会负责 SqlSession 的创建和关闭。 + 如果使用了 Spring 的事务功能,那么当事务完成时,session 将会被提交或回滚。最终任何异常都会被转换成 Spring 的 DataAccessException 异常。

- 如果你使用Java代码来配置: + 使用 Java 代码来配置的方式如下:

-调用MyBatis数据方法现在只需一行代码: + 要调用 MyBatis 的数据方法,只需一行代码:

- MyBatis-Spring | 第一章 简介 + MyBatis-Spring | 简介 Hunter Presnall Eduardo Macarron Nan Lei @@ -29,39 +29,32 @@
- +

- MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中。 -使用这个类库中的类, -Spring 将会加载必要的 MyBatis 工厂类和 session 类。 -这个类库也提供一个简单的方式来注入 -MyBatis 数据映射器和 SqlSession 到业务层的 bean 中。 -而且它也会处理事务, -翻译 MyBatis -的异常到 Spring 的 DataAccessException 异常(数据访问异常,译者注)中。最终,它并 -不会依赖于 MyBatis,Spring 或 MyBatis-Spring 来构建应用程序代码。 + MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中。 + 它将允许 MyBatis 参与到 Spring 的事务管理之中,创建 mapper 和 SqlSession 并注入到 bean 中, + 以及将 Mybatis 的异常转换为 Spring 的 DataAccessException。 + 最终,可以做到应用代码不依赖于 Mybatis,Spring 或 Mybatis-Spring。

- +

- 正如第二版那样,Spring 3.0 也仅支持 iBatis2。那么,我们就想将 MyBatis3 的支持添加 -到 Spring3.0(参考 Spring Jira 中的问题)中。而不幸的是,Spring 3.0 的开发在 MyBatis 3.0 -官方发布前就结束了。 -因为 Spring 开发团队不想发布一个基于非发布版的 MyBatis 的整合支 -持,那么 Spring 官方的支持就不得不继续等待了。要在 Spring 中支持 MyBatis,MyBatis 社 -区认为现在应该是自己团结贡献者和有兴趣的人一起来开始将 Spring 的整合作为 MyBatis 社 -区的子项目的时候了。 -

+ Spring 2.0 只支持 iBatis 2.0。那么,我们就想将 MyBatis3 的支持添加 + 到 Spring 3.0 中(参见 Spring Jira 中的问题)。 + 不幸的是,Spring 3.0 的开发在 MyBatis 3.0 官方发布前就结束了。 + 因为 Spring 开发团队不想发布一个基于未发布版的 MyBatis 的整合支持,如果要获得 Spring 官方的支持,只能等待下一次的发布了。 + 基于在 Spring 中对 MyBatis 提供支持的兴趣,MyBatis 社区认为,应该开始召集有兴趣参与其中的贡献者们,将对 Spring 的集成作为 MyBatis 的一个社区子项目。 +

- +

-在开始使用 MyBatis-Spring 的整合之前,很重要的一点是,你要熟悉 Spring 和 MyBatis -这两个框架还有和它们有关的术语,本手册中不会提供二者的基本内容,安装和配置教程。 + 在开始使用 MyBatis-Spring 之前,你需要先熟悉 Spring 和 MyBatis 这两个框架和有关它们的术语。 + 这很重要——因为本手册中不会提供二者的基本内容,安装和配置教程。

- MyBatis-Spring requires following versions: + MyBatis-Spring 要求 Java 5 及以上版本还有下面列出的 MyBatis 和 Spring 版本:

@@ -124,27 +117,24 @@ MyBatis 数据映射器和 SqlSession 到业务层的 bean 中。

-特别感谢那些使得本项目成为现实的人们(按字母顺序排序)。 -Eduardo Macarron, Hunter Presnall和Putthiphong Boonphong的编码, -测试和文档修改工作; -Andrius Juozapaitis, -Giovanni Cuccu,Raj Nagappan和Tomas Pinos的贡献;而Simone Tripodi发现了这些人并 -把他们带入项目之中。没有他们的努力,这个项目是不可能存在的。 + 特别感谢那些使本项目变为现实的人们(按字母顺序排序): + Eduardo Macarron, Hunter Presnall 和 Putthiphong Boonphong 负责本项目的代码实现,测试和编写文档工作; + Andrius Juozapaitis, Giovanni Cuccu, Raj Nagappan 和 Tomas Pinos 的贡献; + 而 Simone Tripodi 发现了这些人并邀请他们参与到这一个 Mybatis 子项目之中。没有他们的努力,这个项目只能沦为空谈。

- +

- 如果你以任何方式发现文档的缺失,或者文档缺少某一个功能点,最好的方式是你学习它 - 并自己写文档! + 如果你发现文档有任何的缺失,或者缺少某一个功能点的说明,最好的解决办法是先自己学习,并且为缺失的部份补上相应的文档。

- 手册的xdoc方式的来源可用地址: - project's Git - Fork仓库,更新它并提交合并的请求吧。 + 手册的 xdoc 出自 + 项目的 Git 仓库。 + Fork 仓库,更新它并提交 Pull Request 吧。

- 你是该文档最好的作者,像你一样大家都要阅读它! + 还有其它像你一样的人都需要阅读这份文档,而你,就是这份文档最好的作者。

@@ -156,7 +146,7 @@ Giovanni Cuccu,Raj Nagappan和Tomas Pinos的贡献;而Simone Tripodi发现了这
  • 한국어
  • 简体中文
  • -

    想用本土语言阅读这篇文档吗?那就用你的母语文档来丰富它吧!

    +

    想用自己的母语阅读这篇文档吗?那就用你的母语翻译它吧!

    From 3c4fe2cfbb65320eb165cb809eb582a00ed88b1d Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Sat, 30 Dec 2017 05:13:18 +0800 Subject: [PATCH 002/933] Still improvements --- src/site/site_zh.xml | 14 +++---- src/site/zh/xdoc/factorybean.xml | 64 ++++++++++++++++---------------- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/site/site_zh.xml b/src/site/site_zh.xml index c401a14678..85384c57d7 100644 --- a/src/site/site_zh.xml +++ b/src/site/site_zh.xml @@ -1,7 +1,7 @@ + @@ -287,8 +256,8 @@ public CompositeItemWriter interactionsItemWriter() { return compositeItemWriter; }]]> -

    Then each delegate writer will be configured as needed; for example for Interaction and - InteractionMetadata: +

    + 接下来需要配置每一个被委托的 writer;例如 InteractionInteractionMetadata 对应的 writer。

    interactionsItemWriter() { p:sqlSessionTemplate-ref="batchSessionTemplate" p:statementId="com.my.name.space.batch.InteractionRecordToWriteInMultipleTablesMapper.insertInteraction"/>]]> -

    Same as the reader the statementId can refer to the statement with the prefixed namespace.

    +

    和 reader 中的一样,通过 statementId 属性指定对应命名空间前缀的查询。

    -

    Now in the mapper file the statement have to be crafted for each kind of records in the following way:

    +

    而在映射器配置文件中,应该根据每种特定的记录编写特定的语句,如下所示:

    - + interactionsItemWriter() { keyProperty="interaction.id" keyColumn="id"> ]]> -

    What's happening is that first the insertInteractionMetadata will be called, and the update - statement is configured to return the ids created by the jdbc driver (keyProperty and keyColumn). - As the InteractionMetadata object were updated by this query the next query can be used to write the parent - object Interaction via insertInteraction. +

    + 执行的时候会怎么样呢?首先,insertInteractionMetadata 将会被调用,update 语句被设置为返回由 JDBC 驱动返回的主键(参考 keyPropertykeyColumn)。由于 InteractionMetadata 的对象被此查询更新了,下一个查询将可以通过 insertInteraction 开展父对象 Interaction 的写入工作。

    -

    However note that JDBC drivers don't behave the same in this regard. At the time of this writing - the H2 driver 1.3.168 will only return the latest index even in BATCH mode (see org.h2.jdbc.JdbcStatement#getGeneratedKeys), - while the MySQL JDBC driver will behave as expected and return all the IDs. +

    + 然而要注意,JDBC 驱动在这方面的行为并不总是与此相一致。在编写文档时,H2 的数据库驱动 1.3.168 甚至只在 BATCH 模式下返回最后的索引值(参考 org.h2.jdbc.JdbcStatement#getGeneratedKeys),而 MySQL 的 JDBC 驱动则工作良好并返回所有 ID。 +

    From 5d001aa6144e38827bbf4e313b11a5c8d652c782 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Mon, 23 Apr 2018 12:16:47 +0800 Subject: [PATCH 014/933] Typo fix --- src/site/zh/xdoc/boot.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/zh/xdoc/boot.xml b/src/site/zh/xdoc/boot.xml index fabe41bd2e..362d3cda80 100644 --- a/src/site/zh/xdoc/boot.xml +++ b/src/site/zh/xdoc/boot.xml @@ -28,7 +28,7 @@

    - 请查看 MyBatis Spring-boot-stater + 请查看 MyBatis Spring-boot-starter 子项目获取更多信息。

    From 69185715616f861bdc6e5fc483b74fc89dec01a2 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Mon, 23 Apr 2018 12:17:01 +0800 Subject: [PATCH 015/933] Minor fix --- src/site/zh/xdoc/getting-started.xml | 2 +- src/site/zh/xdoc/sample.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/zh/xdoc/getting-started.xml b/src/site/zh/xdoc/getting-started.xml index 078b1369c8..ea93319f6d 100644 --- a/src/site/zh/xdoc/getting-started.xml +++ b/src/site/zh/xdoc/getting-started.xml @@ -29,7 +29,7 @@

    - 本章将会以简略的步骤告诉你如何安装和创建 MyBatis-Spring,并构建一个简单的数据访问事务性的应用程序。 + 本章将会以简略的步骤告诉你如何安装和配置 MyBatis-Spring,并构建一个简单的具备事务管理功能的数据访问应用程序。

    diff --git a/src/site/zh/xdoc/sample.xml b/src/site/zh/xdoc/sample.xml index 0057d9db0c..641ba5db9d 100644 --- a/src/site/zh/xdoc/sample.xml +++ b/src/site/zh/xdoc/sample.xml @@ -61,7 +61,7 @@ public class FooService { } ]]>

    - 它是一个事务 bean,所以当调用它的任何方法时,事务被启动,在方法结束且没有抛出任何未经检查的异常的时候事务将会被提交。注意,事务的行为可以通过 @Transactional 的属性进行配置. 这不是必需的;你可以使用 Spring 提供的任何其他方式来划分你的事务范围。 + 它是一个事务 bean,所以当调用它的任何方法时,事务被启动,在方法结束且没有抛出任何未经检查的异常的时候事务将会被提交。注意,事务的行为可以通过 @Transactional 的属性进行配置。这不是必需的;你可以使用 Spring 提供的任何其他方式来划分你的事务范围。

    此服务调用使用 MyBatis 构建的数据访问层.。该层只包含一个接口,UserMapper.java,这将被 MyBatis 构建的动态代理使用,在运行时通过 Spring 注入到服务之中。 From b6a575a3b93608feeb4a8b26181fac205c0be6c5 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Mon, 23 Apr 2018 12:17:25 +0800 Subject: [PATCH 016/933] Update catalog --- src/site/site_zh.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/site_zh.xml b/src/site/site_zh.xml index 766f7cb011..4cc97c367f 100644 --- a/src/site/site_zh.xml +++ b/src/site/site_zh.xml @@ -37,9 +37,9 @@ - + - + From c0a8195da9171bfe91a7165cba93d436e4f15606 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Mon, 23 Apr 2018 12:27:02 +0800 Subject: [PATCH 017/933] Typo fix for Spring-boot-starter --- src/site/es/xdoc/boot.xml | 4 ++-- src/site/ja/xdoc/boot.xml | 4 ++-- src/site/ko/xdoc/boot.xml | 4 ++-- src/site/xdoc/boot.xml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/site/es/xdoc/boot.xml b/src/site/es/xdoc/boot.xml index 76432ac4d4..22e9e482e0 100644 --- a/src/site/es/xdoc/boot.xml +++ b/src/site/es/xdoc/boot.xml @@ -1,7 +1,7 @@ - org.codehaus.mojo.signature - java18 - 1.0 - - - - 2.19.1 @@ -172,14 +158,14 @@ org.junit.jupiter junit-jupiter-api - ${junit.version} + ${junit-engine.version} test org.junit.jupiter junit-jupiter-engine - ${junit.version} + ${junit-engine.version} test @@ -353,14 +339,9 @@ - org.junit.platform - junit-platform-surefire-provider - ${junit-platform.version} - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-engine.version} From 6116837b6d946baad65efe7805ec1515191cc04a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 28 Apr 2018 19:59:35 +0900 Subject: [PATCH 021/933] Support JDK10 on Travis CI Fixes gh-299 --- .travis.yml | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3fce0b70ab..6004d7702d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,35 @@ language: java sudo: false -jdk: - - oraclejdk9 - - oraclejdk8 - - openjdk8 +matrix: + include: +# 10 + - env: JDK='Oracle JDK 10' + jdk: openjdk8 + install: + - ./mvnw install -q -DskipTests=true + - . ./install-jdk.sh -F 10 -L BCL + - env: JDK='OpenJDK 10' + jdk: openjdk8 + install: + - ./mvnw install -q -DskipTests=true + - . ./install-jdk.sh -F 10 -L GPL +# 9 + - env: JDK='Oracle JDK 9' + jdk: oraclejdk9 +# 8 + - env: JDK='Oracle JDK 8' + jdk: oraclejdk8 + - env: JDK='OpenJDK 8' + jdk: openjdk8 + +before_install: + - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh + - echo "MAVEN_OPTS='-Dlicense.skip=true'" > ~/.mavenrc + +install: ./mvnw install -q -DskipTests=true + +script: ./mvnw clean verify after_success: - chmod -R 777 ./travis/after_success.sh From b0e61bd2df997f2dcbc8b3874a3393a08761e947 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 28 Apr 2018 20:15:01 +0900 Subject: [PATCH 022/933] Upgrade to MyBatis 3.5.0-SNAPSHOT Fixes gh-296 --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2f1ec55385..16935c65e6 100644 --- a/pom.xml +++ b/pom.xml @@ -105,6 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * + 3.5.0-SNAPSHOT 5.0.4.RELEASE 4.0.1.RELEASE @@ -115,7 +116,7 @@ org.mybatis mybatis - 3.4.6 + ${mybatis.version} provided From 188703e1b0407bdf139f8c2a9a3b15c85882fd85 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 29 Apr 2018 01:04:57 +0900 Subject: [PATCH 023/933] Polishing #299 --- .travis.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6004d7702d..9d6ecb6daf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,9 @@ matrix: include: # 10 - env: JDK='Oracle JDK 10' - jdk: openjdk8 - install: - - ./mvnw install -q -DskipTests=true - - . ./install-jdk.sh -F 10 -L BCL + install: . ./install-jdk.sh -F 10 -L BCL - env: JDK='OpenJDK 10' - jdk: openjdk8 - install: - - ./mvnw install -q -DskipTests=true - - . ./install-jdk.sh -F 10 -L GPL + install: . ./install-jdk.sh -F 10 -L GPL # 9 - env: JDK='Oracle JDK 9' jdk: oraclejdk9 @@ -26,8 +20,9 @@ matrix: before_install: - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh - echo "MAVEN_OPTS='-Dlicense.skip=true'" > ~/.mavenrc + - ./mvnw install -q -DskipTests=true -install: ./mvnw install -q -DskipTests=true +install: true script: ./mvnw clean verify From d4a000a4518a41007133ce0a36a22c8ead890736 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 29 Apr 2018 10:43:09 +0900 Subject: [PATCH 024/933] Upgrade to Spring 5.0.5 Fixes gh-302 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16935c65e6..94d3338fe2 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.0-SNAPSHOT - 5.0.4.RELEASE + 5.0.5.RELEASE 4.0.1.RELEASE From 028044218c44080e73638bd249fbe123e97ff797 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 29 Apr 2018 15:51:27 +0900 Subject: [PATCH 025/933] Polishing #177 --- pom.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pom.xml b/pom.xml index 94d3338fe2..b0180187da 100644 --- a/pom.xml +++ b/pom.xml @@ -163,20 +163,6 @@ test - - org.junit.jupiter - junit-jupiter-engine - ${junit-engine.version} - test - - - - org.junit.platform - junit-platform-runner - ${junit-platform.version} - test - - org.jboss.byteman byteman-bmunit From c5883dce44fd57b16a31bd4d2492aad17476017a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 26 Oct 2017 06:46:36 +0900 Subject: [PATCH 026/933] Support converting item to parameter object Fixes gh-21 --- .../spring/batch/MyBatisBatchItemWriter.java | 27 +++++++++- .../MyBatisBatchItemWriterBuilder.java | 17 ++++++ .../batch/MyBatisBatchItemWriterTest.java | 54 +++++++++++++++++++ .../MyBatisBatchItemWriterBuilderTest.java | 40 ++++++++++++-- 4 files changed, 134 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index edbfb31035..da8f6144df 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -29,6 +29,7 @@ import org.mybatis.spring.SqlSessionTemplate; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.convert.converter.Converter; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.InvalidDataAccessResourceUsageException; @@ -62,6 +63,8 @@ public class MyBatisBatchItemWriter implements ItemWriter, InitializingBea private boolean assertUpdates = true; + private Converter itemToParameterConverter = new PassThroughConverter<>(); + /** * Public setter for the flag that determines whether an assertion is made * that all items cause at least one row to be updated. @@ -102,6 +105,18 @@ public void setStatementId(String statementId) { this.statementId = statementId; } + /** + * Public setter for a converter that converting item to parameter object. + *

    + * By default implementation, an item does not convert. + * + * @param itemToParameterConverter a converter that converting item to parameter object + * @since 2.0.0 + */ + public void setItemToParameterConverter(Converter itemToParameterConverter) { + this.itemToParameterConverter = itemToParameterConverter; + } + /** * Check mandatory properties - there must be an SqlSession and a statementId. */ @@ -110,6 +125,7 @@ public void afterPropertiesSet() { notNull(sqlSessionTemplate, "A SqlSessionFactory or a SqlSessionTemplate is required."); isTrue(ExecutorType.BATCH == sqlSessionTemplate.getExecutorType(), "SqlSessionTemplate's executor type must be BATCH"); notNull(statementId, "A statementId is required."); + notNull(itemToParameterConverter, "A itemToParameterConverter is required."); } /** @@ -122,7 +138,7 @@ public void write(final List items) { LOGGER.debug(() -> "Executing batch with " + items.size() + " items."); for (T item : items) { - sqlSessionTemplate.update(statementId, item); + sqlSessionTemplate.update(statementId, itemToParameterConverter.convert(item)); } List results = sqlSessionTemplate.flushStatements(); @@ -146,4 +162,13 @@ public void write(final List items) { } } + private static class PassThroughConverter implements Converter { + + @Override + public T convert(T source) { + return source; + } + + } + } diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java index 3b52fffa4d..856ef0a15d 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java @@ -18,6 +18,7 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.batch.MyBatisBatchItemWriter; +import org.springframework.core.convert.converter.Converter; /** * A builder for the {@link MyBatisBatchItemWriter}. @@ -32,6 +33,7 @@ public class MyBatisBatchItemWriterBuilder { private SqlSessionFactory sqlSessionFactory; private String statementId; private Boolean assertUpdates; + private Converter itemToParameterConverter; /** * Set the {@link SqlSessionTemplate} to be used by writer for database access. @@ -83,6 +85,18 @@ public MyBatisBatchItemWriterBuilder assertUpdates(boolean assertUpdates) { return this; } + /** + * Set a converter that converting item to parameter object. + * + * @param itemToParameterConverter a converter that converting item to parameter object + * @return this instance for method chaining + * @see MyBatisBatchItemWriter#setItemToParameterConverter(Converter) + */ + public MyBatisBatchItemWriterBuilder itemToParameterConverter(Converter itemToParameterConverter) { + this.itemToParameterConverter = itemToParameterConverter; + return this; + } + /** * Returns a fully built {@link MyBatisBatchItemWriter}. * @@ -96,6 +110,9 @@ public MyBatisBatchItemWriter build() { if (this.assertUpdates != null) { writer.setAssertUpdates(this.assertUpdates); } + if (this.itemToParameterConverter != null) { + writer.setItemToParameterConverter(this.itemToParameterConverter); + } return writer; } diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index 3bec43b3fa..7a3563b7d0 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -16,20 +16,28 @@ package org.mybatis.spring.batch; import org.apache.ibatis.executor.BatchResult; +import org.apache.ibatis.session.ExecutorType; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.batch.domain.Employee; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.InvalidDataAccessResourceUsageException; +import java.time.Clock; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.BDDMockito.*; @@ -77,4 +85,50 @@ void testZeroUpdateCountShouldThrowException() { ); } + @Test + void testItemToParameterConverterIsDefault() { + this.writer.setAssertUpdates(false); + this.writer.setStatementId("updateEmployee"); + + Employee employee = new Employee(); + List employees = Collections.singletonList(employee); + writer.write(employees); + + Mockito.verify(this.mockSqlSessionTemplate).update("updateEmployee", employee); + } + + @Test + void testSetItemToParameterConverter() { + this.writer.setAssertUpdates(false); + this.writer.setStatementId("updateEmployee"); + this.writer.setItemToParameterConverter(item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("now", + LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); + return parameter; + }); + + Employee employee = new Employee(); + List employees = Collections.singletonList(employee); + writer.write(employees); + + Map parameter = new HashMap<>(); + parameter.put("item", employee); + parameter.put("now", + LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); + Mockito.verify(this.mockSqlSessionTemplate).update("updateEmployee", parameter); + } + + @Test + void testItemToParameterConverterIsNull() { + given(mockSqlSessionTemplate.getExecutorType()).willReturn(ExecutorType.BATCH); + this.writer.setStatementId("updateEmployee"); + writer.setItemToParameterConverter(null); + + assertThrows(IllegalArgumentException.class, () -> writer.afterPropertiesSet(), + "A itemToParameterConverter is required."); + + } + } diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index 5fedb5fcbe..bb92161cea 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -31,9 +31,11 @@ import org.mybatis.spring.batch.MyBatisBatchItemWriter; import javax.sql.DataSource; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.time.Clock; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; /** * Tests for {@link MyBatisBatchItemWriterBuilder}. @@ -137,6 +139,38 @@ void testConfigurationAssertUpdatesIsFalse() { } + @Test + void testConfigurationSetItemToParameterConverter() { + + // @formatter:off + MyBatisBatchItemWriter itemWriter = new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .statementId("updateFoo") + .itemToParameterConverter(item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("now", LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); + return parameter; + }) + .build(); + // @formatter:on + itemWriter.afterPropertiesSet(); + + List foos = getFoos(); + + itemWriter.write(foos); + + Map parameter = new HashMap<>(); + parameter.put("now", + LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); + parameter.put("item", foos.get(0)); + Mockito.verify(this.sqlSession).update("updateFoo", parameter); + parameter.put("item", foos.get(1)); + Mockito.verify(this.sqlSession).update("updateFoo", parameter); + parameter.put("item", foos.get(2)); + Mockito.verify(this.sqlSession).update("updateFoo", parameter); + } + private List getFoos() { return Arrays.asList(new Foo("foo1"), new Foo("foo2"), new Foo("foo3")); } From df2602e22e5fbd75d116ce6ace7a94846feb0c43 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 4 May 2018 13:13:00 +0900 Subject: [PATCH 027/933] Fix javadoc errors and warnings --- .../mybatis/spring/SqlSessionFactoryBean.java | 36 ++++++++++++++++--- .../org/mybatis/spring/SqlSessionHolder.java | 3 +- .../mybatis/spring/SqlSessionTemplate.java | 18 +++++----- .../org/mybatis/spring/SqlSessionUtils.java | 7 ++-- .../mybatis/spring/annotation/MapperScan.java | 22 ++++++++++-- .../spring/batch/MyBatisBatchItemWriter.java | 18 +++++----- .../spring/mapper/MapperFactoryBean.java | 8 ++--- .../mapper/MapperScannerConfigurer.java | 15 ++++---- .../spring/support/SqlSessionDaoSupport.java | 10 +++++- 9 files changed, 95 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 61c560ebdf..35f3af777f 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +125,7 @@ public class SqlSessionFactoryBean implements FactoryBean, In * Sets the ObjectFactory. * * @since 1.1.2 - * @param objectFactory + * @param objectFactory a custom ObjectFactory */ public void setObjectFactory(ObjectFactory objectFactory) { this.objectFactory = objectFactory; @@ -135,7 +135,7 @@ public void setObjectFactory(ObjectFactory objectFactory) { * Sets the ObjectWrapperFactory. * * @since 1.1.2 - * @param objectWrapperFactory + * @param objectWrapperFactory a specified ObjectWrapperFactory */ public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) { this.objectWrapperFactory = objectWrapperFactory; @@ -145,7 +145,7 @@ public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) { * Gets the DatabaseIdProvider * * @since 1.1.0 - * @return + * @return a specified DatabaseIdProvider */ public DatabaseIdProvider getDatabaseIdProvider() { return databaseIdProvider; @@ -156,24 +156,40 @@ public DatabaseIdProvider getDatabaseIdProvider() { * As of version 1.2.2 this variable is not initialized by default. * * @since 1.1.0 - * @param databaseIdProvider + * @param databaseIdProvider a DatabaseIdProvider */ public void setDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) { this.databaseIdProvider = databaseIdProvider; } + /** + * Gets the VFS. + * @return a specified VFS + */ public Class getVfs() { return this.vfs; } + /** + * Sets the VFS. + * @param vfs a VFS + */ public void setVfs(Class vfs) { this.vfs = vfs; } + /** + * Gets the Cache. + * @return a specified Cache + */ public Cache getCache() { return this.cache; } + /** + * Sets the Cache. + * @param cache a Cache + */ public void setCache(Cache cache) { this.cache = cache; } @@ -265,6 +281,8 @@ public void setFailFast(boolean failFast) { /** * Set the location of the MyBatis {@code SqlSessionFactory} config file. A typical value is * "WEB-INF/mybatis-configuration.xml". + * + * @param configLocation a location the MyBatis config file */ public void setConfigLocation(Resource configLocation) { this.configLocation = configLocation; @@ -286,6 +304,8 @@ public void setConfiguration(Configuration configuration) { * This is an alternative to specifying "<sqlmapper>" entries in an MyBatis config file. * This property being based on Spring's resource abstraction also allows for specifying * resource patterns here: e.g. "classpath*:sqlmap/*-mapper.xml". + * + * @param mapperLocations location of MyBatis mapper files */ public void setMapperLocations(Resource[] mapperLocations) { this.mapperLocations = mapperLocations; @@ -295,6 +315,8 @@ public void setMapperLocations(Resource[] mapperLocations) { * Set optional properties to be passed into the SqlSession configuration, as alternative to a * {@code <properties>} tag in the configuration xml file. This will be used to * resolve placeholders in the config file. + * + * @param sqlSessionFactoryProperties optional properties for the SqlSessionFactory */ public void setConfigurationProperties(Properties sqlSessionFactoryProperties) { this.configurationProperties = sqlSessionFactoryProperties; @@ -314,6 +336,8 @@ public void setConfigurationProperties(Properties sqlSessionFactoryProperties) { * underlying target {@code DataSource}. If there's nevertheless a {@code TransactionAwareDataSourceProxy} * passed in, it will be unwrapped to extract its target {@code DataSource}. * + * @param dataSource a JDBC {@code DataSource} + * */ public void setDataSource(DataSource dataSource) { if (dataSource instanceof TransactionAwareDataSourceProxy) { @@ -333,6 +357,8 @@ public void setDataSource(DataSource dataSource) { * This is mainly meant for testing so that mock SqlSessionFactory classes can be injected. By * default, {@code SqlSessionFactoryBuilder} creates {@code DefaultSqlSessionFactory} instances. * + * @param sqlSessionFactoryBuilder a SqlSessionFactoryBuilder + * */ public void setSqlSessionFactoryBuilder(SqlSessionFactoryBuilder sqlSessionFactoryBuilder) { this.sqlSessionFactoryBuilder = sqlSessionFactoryBuilder; diff --git a/src/main/java/org/mybatis/spring/SqlSessionHolder.java b/src/main/java/org/mybatis/spring/SqlSessionHolder.java index e4ced13a80..d55309b4e8 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionHolder.java +++ b/src/main/java/org/mybatis/spring/SqlSessionHolder.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2016 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ public final class SqlSessionHolder extends ResourceHolderSupport { * * @param sqlSession the {@code SqlSession} has to be hold. * @param executorType the {@code ExecutorType} has to be hold. + * @param exceptionTranslator the {@code PersistenceExceptionTranslator} has to be hold. */ public SqlSessionHolder(SqlSession sqlSession, ExecutorType executorType, diff --git a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java index 5933b21701..959aa9aaeb 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java +++ b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ public class SqlSessionTemplate implements SqlSession, DisposableBean { * Constructs a Spring managed SqlSession with the {@code SqlSessionFactory} * provided as an argument. * - * @param sqlSessionFactory + * @param sqlSessionFactory a factory of SqlSession */ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { this(sqlSessionFactory, sqlSessionFactory.getConfiguration().getDefaultExecutorType()); @@ -100,8 +100,8 @@ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { * {@code ExecutorType} cannot be changed once the {@code SqlSessionTemplate} * is constructed. * - * @param sqlSessionFactory - * @param executorType + * @param sqlSessionFactory a factory of SqlSession + * @param executorType an executor type on session */ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType executorType) { this(sqlSessionFactory, executorType, @@ -119,9 +119,9 @@ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType exec * exception translation will be done and MyBatis exceptions will be * thrown * - * @param sqlSessionFactory - * @param executorType - * @param exceptionTranslator + * @param sqlSessionFactory a factory of SqlSession + * @param executorType an executor type on session + * @param exceptionTranslator a translator of exception */ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType executorType, PersistenceExceptionTranslator exceptionTranslator) { @@ -408,8 +408,8 @@ public List flushStatements() { * The implementation of {@link DisposableBean} forces spring context to use {@link DisposableBean#destroy()} method instead of {@link SqlSessionTemplate#close()} to shutdown gently. * * @see SqlSessionTemplate#close() - * @see org.springframework.beans.factory.support.DisposableBeanAdapter#inferDestroyMethodIfNecessary - * @see org.springframework.beans.factory.support.DisposableBeanAdapter#CLOSE_METHOD_NAME + * @see "org.springframework.beans.factory.support.DisposableBeanAdapter#inferDestroyMethodIfNecessary(Object, RootBeanDefinition)" + * @see "org.springframework.beans.factory.support.DisposableBeanAdapter#CLOSE_METHOD_NAME" */ @Override public void destroy() throws Exception { diff --git a/src/main/java/org/mybatis/spring/SqlSessionUtils.java b/src/main/java/org/mybatis/spring/SqlSessionUtils.java index 11a2262bf4..fe155ccd45 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionUtils.java +++ b/src/main/java/org/mybatis/spring/SqlSessionUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,6 +77,7 @@ public static SqlSession getSqlSession(SqlSessionFactory sessionFactory) { * @param sessionFactory a MyBatis {@code SqlSessionFactory} to create new sessions * @param executorType The executor type of the SqlSession to create * @param exceptionTranslator Optional. Translates SqlSession.commit() exceptions to Spring exceptions. + * @return an SqlSession managed by Spring Transaction Manager * @throws TransientDataAccessResourceException if a transaction is active and the * {@code SqlSessionFactory} is not using a {@code SpringManagedTransactionFactory} * @see SpringManagedTransactionFactory @@ -162,8 +163,8 @@ private static SqlSession sessionHolder(ExecutorType executorType, SqlSessionHol * If it is not, it closes it, otherwise it just updates the reference counter and * lets Spring call the close callback when the managed transaction ends * - * @param session - * @param sessionFactory + * @param session a target SqlSession + * @param sessionFactory a factory of SqlSession */ public static void closeSqlSession(SqlSession session, SqlSessionFactory sessionFactory) { notNull(session, NO_SQL_SESSION_SPECIFIED); diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index 71401d1c08..7fa9b36777 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,8 +77,9 @@ /** * Alias for the {@link #basePackages()} attribute. Allows for more concise * annotation declarations e.g.: - * {@code @EnableMyBatisMapperScanner("org.my.pkg")} instead of {@code - * @EnableMyBatisMapperScanner(basePackages= "org.my.pkg"})}. + * {@code @MapperScan("org.my.pkg")} instead of {@code @MapperScan(basePackages = "org.my.pkg"})}. + * + * @return base package names */ String[] value() default {}; @@ -86,6 +87,8 @@ * Base packages to scan for MyBatis interfaces. Note that only interfaces * with at least one method will be registered; concrete classes will be * ignored. + * + * @return base package names for scanning mapper interface */ String[] basePackages() default {}; @@ -94,12 +97,16 @@ * to scan for annotated components. The package of each class specified will be scanned. *

    Consider creating a special no-op marker class or interface in each package * that serves no purpose other than being referenced by this attribute. + * + * @return classes that indicate base package for scanning mapper interface */ Class[] basePackageClasses() default {}; /** * The {@link BeanNameGenerator} class to be used for naming detected components * within the Spring container. + * + * @return the class of {@link BeanNameGenerator} */ Class nameGenerator() default BeanNameGenerator.class; @@ -110,6 +117,8 @@ * the specified annotation. *

    * Note this can be combined with markerInterface. + * + * @return the annotation that the scanner will search for */ Class annotationClass() default Annotation.class; @@ -120,6 +129,8 @@ * the specified interface class as a parent. *

    * Note this can be combined with annotationClass. + * + * @return the parent that the scanner will search for */ Class markerInterface() default Class.class; @@ -127,6 +138,8 @@ * Specifies which {@code SqlSessionTemplate} to use in the case that there is * more than one in the spring context. Usually this is only needed when you * have more than one datasource. + * + * @return the bean name of {@code SqlSessionTemplate} */ String sqlSessionTemplateRef() default ""; @@ -134,12 +147,15 @@ * Specifies which {@code SqlSessionFactory} to use in the case that there is * more than one in the spring context. Usually this is only needed when you * have more than one datasource. + * + * @return the bean name of {@code SqlSessionFactory} */ String sqlSessionFactoryRef() default ""; /** * Specifies a custom MapperFactoryBean to return a mybatis proxy as spring bean. * + * @return the class of {@code MapperFactoryBean} */ Class factoryBean() default MapperFactoryBean.class; diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index da8f6144df..eab5581048 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,16 +36,16 @@ /** * {@code ItemWriter} that uses the batching features from * {@code SqlSessionTemplate} to execute a batch of statements for all items - * provided.
    - * - * Provided to facilitate the migration from Spring-Batch iBATIS 2 writers to MyBatis 3
    - * + * provided. + *

    + * Provided to facilitate the migration from Spring-Batch iBATIS 2 writers to MyBatis 3. + *

    * The user must provide a MyBatis statement id that points to the SQL statement defined - * in the MyBatis.
    - * + * in the MyBatis. + *

    * It is expected that {@link #write(List)} is called inside a transaction. If it is not - * each statement call will be autocommitted and flushStatements will return no results.
    - * + * each statement call will be autocommitted and flushStatements will return no results. + *

    * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. * diff --git a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java index 13ba830efe..df938f745f 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -134,13 +134,13 @@ public Class getMapperInterface() { /** * If addToConfig is false the mapper will not be added to MyBatis. This means * it must have been included in mybatis-config.xml. - *

    + *

    * If it is true, the mapper will be added to MyBatis in the case it is not already * registered. - *

    + *

    * By default addToConfig is true. * - * @param addToConfig + * @param addToConfig a flag that whether add mapper to MyBatis or not */ public void setAddToConfig(boolean addToConfig) { this.addToConfig = addToConfig; diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 8ac71883e8..97370c3b6c 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,6 @@ * and bean name properties all support ${property} style substitution. *

    * Configuration sample: - *

    * *

      * {@code
    @@ -133,7 +132,7 @@ public void setBasePackage(String basePackage) {
       /**
        * Same as {@code MapperFactoryBean#setAddToConfig(boolean)}.
        *
    -   * @param addToConfig
    +   * @param addToConfig a flag that whether add mapper to MyBatis or not
        * @see MapperFactoryBean#setAddToConfig(boolean)
        */
       public void setAddToConfig(boolean addToConfig) {
    @@ -175,7 +174,7 @@ public void setMarkerInterface(Class superClass) {
        * 

    * @deprecated Use {@link #setSqlSessionTemplateBeanName(String)} instead * - * @param sqlSessionTemplate + * @param sqlSessionTemplate a template of SqlSession */ @Deprecated public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { @@ -206,7 +205,7 @@ public void setSqlSessionTemplateBeanName(String sqlSessionTemplateName) { *

    * @deprecated Use {@link #setSqlSessionFactoryBeanName(String)} instead. * - * @param sqlSessionFactory + * @param sqlSessionFactory a factory of SqlSession */ @Deprecated public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { @@ -231,10 +230,12 @@ public void setSqlSessionFactoryBeanName(String sqlSessionFactoryName) { } /** - * + * Specifies a flag that whether execute a property placeholder processing or not. + *

    + * The default is {@literal false}. This means that a property placeholder processing does not execute. * @since 1.1.1 * - * @param processPropertyPlaceHolders + * @param processPropertyPlaceHolders a flag that whether execute a property placeholder processing or not */ public void setProcessPropertyPlaceHolders(boolean processPropertyPlaceHolders) { this.processPropertyPlaceHolders = processPropertyPlaceHolders; diff --git a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java index 4aee710848..a969b5e271 100644 --- a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java +++ b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,8 @@ public abstract class SqlSessionDaoSupport extends DaoSupport { /** * Set MyBatis SqlSessionFactory to be used by this DAO. * Will automatically create SqlSessionTemplate for the given SqlSessionFactory. + * + * @param sqlSessionFactory a factory of SqlSession */ public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { if (this.sqlSessionTemplate == null || sqlSessionFactory != this.sqlSessionTemplate.getSqlSessionFactory()) { @@ -67,6 +69,8 @@ protected SqlSessionTemplate createSqlSessionTemplate(SqlSessionFactory sqlSessi /** * Return the MyBatis SqlSessionFactory used by this DAO. + * + * @return a factory of SqlSession */ public final SqlSessionFactory getSqlSessionFactory() { return (this.sqlSessionTemplate != null ? this.sqlSessionTemplate.getSqlSessionFactory() : null); @@ -76,6 +80,8 @@ public final SqlSessionFactory getSqlSessionFactory() { /** * Set the SqlSessionTemplate for this DAO explicitly, * as an alternative to specifying a SqlSessionFactory. + * + * @param sqlSessionTemplate a template of SqlSession * @see #setSqlSessionFactory */ public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { @@ -102,6 +108,8 @@ public SqlSession getSqlSession() { * Consider creating a custom SqlSessionTemplate instance via * {@code new SqlSessionTemplate(getSqlSessionFactory())}, in which case * you're allowed to customize the settings on the resulting instance. + * + * @return a template of SqlSession */ public SqlSessionTemplate getSqlSessionTemplate() { return this.sqlSessionTemplate; From 450362169d36dacfc33cd8e10d87a39f5d079931 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 4 May 2018 15:45:36 +0900 Subject: [PATCH 028/933] Add explanation for MyBatisBatchItemWriter#itemToParameterConverter on doc See #21 --- src/site/es/xdoc/batch.xml | 67 +++++++++++++++++- src/site/ja/xdoc/batch.xml | 70 ++++++++++++++++++- src/site/ko/xdoc/batch.xml | 68 +++++++++++++++++- src/site/xdoc/batch.xml | 66 ++++++++++++++++- src/site/zh/xdoc/batch.xml | 66 +++++++++++++++++ .../spring/sample/AbstractSampleJobTest.java | 16 ++++- .../sample/SampleJobJavaConfigTest.java | 6 +- .../spring/sample/SampleJobXmlConfigTest.java | 7 +- .../spring/sample/config/SampleJobConfig.java | 17 ++++- .../sample/config/applicationContext-job.xml | 8 ++- .../spring/sample/db/database-schema.sql | 6 +- .../spring/sample/mapper/PersonMapper.xml | 9 +-- 12 files changed, 391 insertions(+), 15 deletions(-) diff --git a/src/site/es/xdoc/batch.xml b/src/site/es/xdoc/batch.xml index f5de8c226b..7963bf740c 100644 --- a/src/site/es/xdoc/batch.xml +++ b/src/site/es/xdoc/batch.xml @@ -1,7 +1,7 @@ + + + + + + + + + + +]]> +

    Escribiendo en distintas tablas usando composite writers (con algunos condicionantes):

    Esta técnica sólo puede usarse con MyBatis 3.2+, por que había un diff --git a/src/site/ja/xdoc/batch.xml b/src/site/ja/xdoc/batch.xml index 28ee1b0461..b68b309d3c 100644 --- a/src/site/ja/xdoc/batch.xml +++ b/src/site/ja/xdoc/batch.xml @@ -1,7 +1,7 @@ + + + + + + + + + + +]]> + +

    Composite Writer を使って複数のテーブルに書き込む(注意事項あり)

    このテクニックを使うには MyBatis 3.2 以降が必要です。それ以前のバージョンには 問題 があるため、Writer が期待通りに動作しません。 diff --git a/src/site/ko/xdoc/batch.xml b/src/site/ko/xdoc/batch.xml index b1c0414fc5..5bb92c0a2f 100644 --- a/src/site/ko/xdoc/batch.xml +++ b/src/site/ko/xdoc/batch.xml @@ -1,7 +1,7 @@ + + + + + + + + + + +]]> + +

    여러개의 테이블에 데이터를 쓰려면 한꺼번에 처리할 수 있도록 만든 writer(몇가지 규칙을 가지고)를 사용하자.

    이 기능은 마이바티스 3.2이상에서만 사용할 수 있다. 이전의 버전에서는 예상과 다르게 동작하는데 그 내용은 diff --git a/src/site/xdoc/batch.xml b/src/site/xdoc/batch.xml index 507f4c9ae1..8083827f91 100644 --- a/src/site/xdoc/batch.xml +++ b/src/site/xdoc/batch.xml @@ -1,7 +1,7 @@ + + + + + + + + + + +]]> +

    Writing to different tables using composite writers (with some caveats):

    This technique can only be used with MyBatis 3.2+, as there was an diff --git a/src/site/zh/xdoc/batch.xml b/src/site/zh/xdoc/batch.xml index e9c90aa4c6..0e519959a3 100644 --- a/src/site/zh/xdoc/batch.xml +++ b/src/site/zh/xdoc/batch.xml @@ -200,6 +200,72 @@ public MyBatisBatchItemWriter writer() { .build(); }]]> + +

    Converting a item that read using ItemReader to an any parameter object:

    + +

    + By default behavior, the MyBatisBatchItemWriter passes a item that read using ItemReader + (or convert by ItemProcessor) to the MyBatis(SqlSession#update()) as the parameter object. + If you want to customize a parameter object that passes to the MyBatis, you can realize to use the itemToParameterConverter option. + For example using itemToParameterConverter option, you can passes any objects other than the item object to the MyBatis. + Follows below a sample: +

    + +

    + At first, you create a custom converter class (or factory method). The following sample uses a factory method. +

    + + Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; +}]]> + +

    + At next, you write a sql mapping. +

    + + + insert into persons (first_name, last_name, operation_by, operation_at) + values(#{item.firstName}, #{item.lastName}, #{operationBy}, #{operationAt}) +]]> + +

    + At last, you configure the MyBatisBatchItemWriter. +

    + + writer() throws Exception { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); +}]]> + + + + + + + + + + + + +]]> + +

    使用复合 writer 对多个表进行写入(但带有问题):

    diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java index 7740a0fc2d..918593066f 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,38 +47,52 @@ void testJob() throws Exception { List> persons = jdbcTemplate .queryForList("SELECT * FROM persons ORDER BY person_id", EmptySqlParameterSource.INSTANCE); Assertions.assertEquals(5, persons.size()); + Object operationBy = persons.get(0).get("OPERATION_BY"); + Object operationAt = persons.get(0).get("OPERATION_AT"); { Map person = persons.get(0); Assertions.assertEquals(0, person.get("PERSON_ID")); Assertions.assertEquals("Pocoyo", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); + Assertions.assertEquals(getExpectedOperationBy(), operationBy); + Assertions.assertNotNull(operationAt); } { Map person = persons.get(1); Assertions.assertEquals(1, person.get("PERSON_ID")); Assertions.assertEquals("Pato", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); + Assertions.assertEquals(operationBy, person.get("OPERATION_BY")); + Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } { Map person = persons.get(2); Assertions.assertEquals(2, person.get("PERSON_ID")); Assertions.assertEquals("Eli", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); + Assertions.assertEquals(operationBy, person.get("OPERATION_BY")); + Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } { Map person = persons.get(3); Assertions.assertEquals(3, person.get("PERSON_ID")); Assertions.assertEquals("Valentina", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); + Assertions.assertEquals(operationBy, person.get("OPERATION_BY")); + Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } { Map person = persons.get(4); Assertions.assertEquals(4, person.get("PERSON_ID")); Assertions.assertEquals("Taro", person.get("FIRST_NAME")); Assertions.assertEquals("Yamada", person.get("LAST_NAME")); + Assertions.assertEquals(operationBy, person.get("OPERATION_BY")); + Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } } + protected abstract String getExpectedOperationBy(); + @Configuration static class LocalContext { @Bean diff --git a/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java index afb4b9f667..6599c80356 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,4 +20,8 @@ @SpringJUnitConfig({SampleJobConfig.class, AbstractSampleJobTest.LocalContext.class}) class SampleJobJavaConfigTest extends AbstractSampleJobTest { + @Override + protected String getExpectedOperationBy() { + return "batch_java_config_user"; + } } diff --git a/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java index b387afdae8..8e7f7140b0 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,11 @@ SampleJobXmlConfigTest.LocalContext.class}) class SampleJobXmlConfigTest extends AbstractSampleJobTest { + @Override + protected String getExpectedOperationBy() { + return "batch_xml_config_user"; + } + @ImportResource("classpath:org/mybatis/spring/sample/config/applicationContext-job.xml") @Configuration static class LocalContext { diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java index 57847b1427..030d7a157d 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.converter.Converter; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; @@ -40,6 +41,9 @@ import org.springframework.transaction.PlatformTransactionManager; import javax.sql.DataSource; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; @Configuration @EnableBatchProcessing @@ -100,10 +104,21 @@ public MyBatisBatchItemWriter writer() throws Exception { return new MyBatisBatchItemWriterBuilder() .sqlSessionFactory(sqlSessionFactory()) .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) .build(); // @formatter:on } +public static Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; +} + @Bean public Job importUserJob() throws Exception { // @formatter:off diff --git a/src/test/java/org/mybatis/spring/sample/config/applicationContext-job.xml b/src/test/java/org/mybatis/spring/sample/config/applicationContext-job.xml index 6ae670680d..7cede1c8a4 100644 --- a/src/test/java/org/mybatis/spring/sample/config/applicationContext-job.xml +++ b/src/test/java/org/mybatis/spring/sample/config/applicationContext-job.xml @@ -1,7 +1,7 @@ + 5.2.0 + 1.2.0 From c155d0ce5206fefbdb79e647a12b3e79c4776bea Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 23 Sep 2018 18:30:53 -0400 Subject: [PATCH 035/933] [travis] Add other jdks --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9d6ecb6daf..1b92a59873 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,11 @@ sudo: false matrix: include: +# 11 + - env: JDK='Oracle JDK 11' + install: . ./install-jdk.sh -F 11 -L BCL + - env: JDK='OpenJDK 11' + install: . ./install-jdk.sh -F 11 -L GPL # 10 - env: JDK='Oracle JDK 10' install: . ./install-jdk.sh -F 10 -L BCL @@ -11,6 +16,8 @@ matrix: # 9 - env: JDK='Oracle JDK 9' jdk: oraclejdk9 + - env: JDK='OpenJDK 9' + install: . ./install-jdk.sh -F 9 # 8 - env: JDK='Oracle JDK 8' jdk: oraclejdk8 From 991ea2025536ec0e11026237d21f6b1d5b498397 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 18:45:26 +0900 Subject: [PATCH 036/933] Update settings for maven-surefire-plugin Fixes gh-322 --- pom.xml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 00072c98ee..61d76180b8 100644 --- a/pom.xml +++ b/pom.xml @@ -165,6 +165,18 @@ ${junit-engine.version} test + + org.junit.jupiter + junit-jupiter-engine + ${junit-engine.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-engine.version} + test + org.jboss.byteman @@ -327,13 +339,6 @@ - - - org.junit.vintage - junit-vintage-engine - ${junit-engine.version} - - org.apache.maven.plugins From c50ec9f9a54376a70059a2f589b0f4cb4370a2dc Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 18:53:14 +0900 Subject: [PATCH 037/933] Upgrade to Spring 5.0.10 Fixes gh-324 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 61d76180b8..a0d696614f 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.0-SNAPSHOT - 5.0.8.RELEASE + 5.0.10.RELEASE 4.0.1.RELEASE From 9843e3b90d9bb217581c7e0f29550ce5afe0ef1f Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 18:54:59 +0900 Subject: [PATCH 038/933] Upgrade to JUnit 5.3.1 Fixes gh-325 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0d696614f..aa5b8051ef 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.0.1.RELEASE - 5.2.0 + 5.3.1 1.2.0 From 64938bf5f74c970b33900d19dea8bb7c864b86f7 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 18:57:18 +0900 Subject: [PATCH 039/933] Remove unused property on pom.xml Fixes gh-326 --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa5b8051ef..d080b9b3fc 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,6 @@ 5.3.1 - 1.2.0 From 6ec20d020c29aaa8d45bea01578240d515048208 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 19:07:10 +0900 Subject: [PATCH 040/933] Upgrade to mockito 2.23.0 Fixes gh-327 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d080b9b3fc..98e7459b85 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ org.mockito mockito-core - 2.15.0 + 2.23.0 test From dc6ae53ae8ec339d098f4118d56d9d783ced4b32 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 19:16:25 +0900 Subject: [PATCH 041/933] Drop Oracle JDK 10 on Travis CI Fixes gh-328 --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b92a59873..0ac14b1efc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,6 @@ matrix: - env: JDK='OpenJDK 11' install: . ./install-jdk.sh -F 11 -L GPL # 10 - - env: JDK='Oracle JDK 10' - install: . ./install-jdk.sh -F 10 -L BCL - env: JDK='OpenJDK 10' install: . ./install-jdk.sh -F 10 -L GPL # 9 From a72730b852653aeeccbe5ddd57af32027f244061 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 26 Oct 2018 19:29:34 +0900 Subject: [PATCH 042/933] Polishing Travis CI settings --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ac14b1efc..eb6dba6ba4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ matrix: include: # 11 - env: JDK='Oracle JDK 11' - install: . ./install-jdk.sh -F 11 -L BCL + jdk: oraclejdk11 - env: JDK='OpenJDK 11' - install: . ./install-jdk.sh -F 11 -L GPL + jdk: openjdk11 # 10 - env: JDK='OpenJDK 10' install: . ./install-jdk.sh -F 10 -L GPL From f6d8faaa317a064f205616a55109fbd9fd8dad5f Mon Sep 17 00:00:00 2001 From: Julien KLAER Date: Mon, 29 Oct 2018 17:57:00 +0100 Subject: [PATCH 043/933] fix(paging item reader): Going through doOpen to initialize connection instead of afterPropertiesSet --- .../spring/batch/MyBatisPagingItemReader.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 5dd5fa0a8c..67de30a276 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -15,18 +15,17 @@ */ package org.mybatis.spring.batch; -import static org.springframework.util.Assert.notNull; -import static org.springframework.util.ClassUtils.getShortName; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.springframework.batch.item.database.AbstractPagingItemReader; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; -import org.apache.ibatis.session.ExecutorType; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionTemplate; -import org.springframework.batch.item.database.AbstractPagingItemReader; +import static org.springframework.util.Assert.notNull; +import static org.springframework.util.ClassUtils.getShortName; /** * {@code org.springframework.batch.item.ItemReader} for reading database @@ -44,7 +43,7 @@ public class MyBatisPagingItemReader extends AbstractPagingItemReader { private SqlSessionFactory sqlSessionFactory; - private SqlSessionTemplate sqlSessionTemplate; + private SqlSession sqlSession; private Map parameterValues; @@ -89,10 +88,23 @@ public void setParameterValues(Map parameterValues) { public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); notNull(sqlSessionFactory, "A SqlSessionFactory is required."); - sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); notNull(queryId, "A queryId is required."); } + @Override + protected void doOpen() throws Exception { + super.doOpen(); + sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + } + + @Override + protected void doClose() throws Exception { + if (sqlSession != null) { + sqlSession.close(); + } + super.doClose(); + } + @Override protected void doReadPage() { Map parameters = new HashMap<>(); @@ -107,7 +119,7 @@ protected void doReadPage() { } else { results.clear(); } - results.addAll(sqlSessionTemplate.selectList(queryId, parameters)); + results.addAll(sqlSession.selectList(queryId, parameters)); } @Override From 9749d2da6742fb14406d65ae1d68c802161cec2c Mon Sep 17 00:00:00 2001 From: Julien KLAER Date: Tue, 30 Oct 2018 09:06:42 +0100 Subject: [PATCH 044/933] fix(paging item reader): Using implementation SqlSessionTemplate instead of interface SqlSession. --- .../mybatis/spring/batch/MyBatisPagingItemReader.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 67de30a276..b0d6df569d 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -18,6 +18,7 @@ import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionTemplate; import org.springframework.batch.item.database.AbstractPagingItemReader; import java.util.HashMap; @@ -43,7 +44,7 @@ public class MyBatisPagingItemReader extends AbstractPagingItemReader { private SqlSessionFactory sqlSessionFactory; - private SqlSession sqlSession; + private SqlSessionTemplate sqlSessionTemplate; private Map parameterValues; @@ -94,13 +95,13 @@ public void afterPropertiesSet() throws Exception { @Override protected void doOpen() throws Exception { super.doOpen(); - sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); } @Override protected void doClose() throws Exception { - if (sqlSession != null) { - sqlSession.close(); + if (sqlSessionTemplate != null) { + sqlSessionTemplate.close(); } super.doClose(); } @@ -119,7 +120,7 @@ protected void doReadPage() { } else { results.clear(); } - results.addAll(sqlSession.selectList(queryId, parameters)); + results.addAll(sqlSessionTemplate.selectList(queryId, parameters)); } @Override From ccc51e629bed4449d90595dc71cca345ea34804f Mon Sep 17 00:00:00 2001 From: Julien KLAER Date: Fri, 2 Nov 2018 13:51:13 +0100 Subject: [PATCH 045/933] fix(paging item reader): Staying simple and and passing all tests locally. --- .../spring/batch/MyBatisPagingItemReader.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index b0d6df569d..286a99e665 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -92,22 +92,11 @@ public void afterPropertiesSet() throws Exception { notNull(queryId, "A queryId is required."); } - @Override - protected void doOpen() throws Exception { - super.doOpen(); - sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); - } - - @Override - protected void doClose() throws Exception { - if (sqlSessionTemplate != null) { - sqlSessionTemplate.close(); - } - super.doClose(); - } - @Override protected void doReadPage() { + if (sqlSessionTemplate == null) { + sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); + } Map parameters = new HashMap<>(); if (parameterValues != null) { parameters.putAll(parameterValues); From 189a698536440901022409142f61b1810243625b Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 13 Dec 2018 20:41:59 -0500 Subject: [PATCH 046/933] [pom] Reconfigure jdk usage --- .travis.yml | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb6dba6ba4..a1f7f261a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,9 @@ language: java sudo: false -matrix: - include: -# 11 - - env: JDK='Oracle JDK 11' - jdk: oraclejdk11 - - env: JDK='OpenJDK 11' - jdk: openjdk11 -# 10 - - env: JDK='OpenJDK 10' - install: . ./install-jdk.sh -F 10 -L GPL -# 9 - - env: JDK='Oracle JDK 9' - jdk: oraclejdk9 - - env: JDK='OpenJDK 9' - install: . ./install-jdk.sh -F 9 -# 8 - - env: JDK='Oracle JDK 8' - jdk: oraclejdk8 - - env: JDK='OpenJDK 8' - jdk: openjdk8 - -before_install: - - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh - - echo "MAVEN_OPTS='-Dlicense.skip=true'" > ~/.mavenrc - - ./mvnw install -q -DskipTests=true - -install: true - -script: ./mvnw clean verify +jdk: +- oraclejdk11 +- oraclejdk8 after_success: - chmod -R 777 ./travis/after_success.sh From a31d9fbb1950fb65eca3d665fd575688a19ec56c Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 13 Dec 2018 20:42:05 -0500 Subject: [PATCH 047/933] [travis] Remove sudo as now obsolete --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a1f7f261a0..78ffdfe5f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: java -sudo: false jdk: - oraclejdk11 From 9c1f503e85a5b00a0fb2154d10d02243a964422d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 20 Dec 2018 19:22:15 -0500 Subject: [PATCH 048/933] [pom] Remove obsolete comment --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 98e7459b85..f4c6534053 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,6 @@ 5.0.10.RELEASE 4.0.1.RELEASE - 5.3.1 From 2c3041401720d90afd3eac838bf698cfcc512975 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 20 Dec 2018 19:23:02 -0500 Subject: [PATCH 049/933] [pom] Update spring to 5.1.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f4c6534053..f39d2e4c6d 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.0-SNAPSHOT - 5.0.10.RELEASE + 5.1.3.RELEASE 4.0.1.RELEASE 5.3.1 From 7ae98d6a144671fda2bd8cb460d2b0d6d823c3b4 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 14:30:14 -0500 Subject: [PATCH 050/933] [mvn] Update wrapper to 3.6.0 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index cb7ff1fe7c..af632155e6 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,3 +1,3 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar From 20c18c01e919feac5956364657829726daa2f894 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 15:09:04 -0500 Subject: [PATCH 051/933] [travis] no-op formatting --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78ffdfe5f2..48cf2b99fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: java jdk: -- oraclejdk11 -- oraclejdk8 + - oraclejdk11 + - oraclejdk8 after_success: - chmod -R 777 ./travis/after_success.sh From 22cc20a17dacbdb707b43689bedd45148ede25a9 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:27:48 -0500 Subject: [PATCH 052/933] [pom] Cleanup junit jupiter and update to 5.3.2 --- pom.xml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index f39d2e4c6d..a117f7936c 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ 5.1.3.RELEASE 4.0.1.RELEASE - 5.3.1 + 5.3.2 @@ -157,22 +157,10 @@ test - - org.junit.jupiter - junit-jupiter-api - ${junit-engine.version} - test - org.junit.jupiter junit-jupiter-engine - ${junit-engine.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-engine.version} + ${junit.version} test From e58ffbdd906d6f2fae074f7240022679afc99d55 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:47:11 -0500 Subject: [PATCH 053/933] [pom] Update javax.servlet-api --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a117f7936c..153893a2d6 100644 --- a/pom.xml +++ b/pom.xml @@ -283,7 +283,7 @@ javax.servlet javax.servlet-api - 4.0.0 + 4.0.1 test From a3dd63dcf0845191e5dd0b7ea6e11687c46752cc Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:47:26 -0500 Subject: [PATCH 054/933] [pom] Update javax.transaction-api to 1.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 153893a2d6..14226cac86 100644 --- a/pom.xml +++ b/pom.xml @@ -277,7 +277,7 @@ javax.transaction javax.transaction-api - 1.2 + 1.3 test From e429850f8d5beb916fc5fa3f89e66a28fce3e894 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:47:36 -0500 Subject: [PATCH 055/933] [pom] Exclude commons-logging --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 14226cac86..eb5d5e5a86 100644 --- a/pom.xml +++ b/pom.xml @@ -272,6 +272,12 @@ mockrunner-jdbc 1.1.2 test + + + commons-logging + commons-logging + + From 65eb5972168cfff42fc3fbd6632c7ea1eca11801 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:48:09 -0500 Subject: [PATCH 056/933] [pom] Update mockrunner to 2.0.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index eb5d5e5a86..4e6cc9493a 100644 --- a/pom.xml +++ b/pom.xml @@ -230,7 +230,7 @@ com.mockrunner mockrunner-core - 1.1.2 + 2.0.1 test @@ -254,7 +254,7 @@ com.mockrunner mockrunner-ejb - 1.1.2 + 2.0.1 test @@ -270,7 +270,7 @@ com.mockrunner mockrunner-jdbc - 1.1.2 + 2.0.1 test From 6786edd0a23b2c6ade58cae564133d06ba77f6c4 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:48:20 -0500 Subject: [PATCH 057/933] [pom] Update assertj to 3.11.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e6cc9493a..d85c555659 100644 --- a/pom.xml +++ b/pom.xml @@ -223,7 +223,7 @@ org.assertj assertj-core - 3.8.0 + 3.11.1 test From 61d47dda09930e72d40b77bc4b9ab218462fb7ff Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:48:30 -0500 Subject: [PATCH 058/933] [pom] Update hsqldb to 2.4.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d85c555659..4882c8b285 100644 --- a/pom.xml +++ b/pom.xml @@ -202,7 +202,7 @@ org.hsqldb hsqldb - 2.4.0 + 2.4.1 test From 43b3b20512df92f97f2bd50851af3d8904901f73 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:48:42 -0500 Subject: [PATCH 059/933] [pom] Update byteman to 4.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4882c8b285..0c012bed7d 100644 --- a/pom.xml +++ b/pom.xml @@ -167,7 +167,7 @@ org.jboss.byteman byteman-bmunit - 3.0.10 + 4.0.5 test From 68cfe8129190b7410a5e232d2fafde28fc20d7cb Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:48:53 -0500 Subject: [PATCH 060/933] [pom] Update derby to 10.14.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c012bed7d..5102a60101 100644 --- a/pom.xml +++ b/pom.xml @@ -153,7 +153,7 @@ org.apache.derby derby - 10.14.1.0 + 10.14.2.0 test From d98b05992a4276551589628672a4c682fa24836c Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:49:04 -0500 Subject: [PATCH 061/933] [pom] Update mockito to 2.23.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5102a60101..1541bc9bfd 100644 --- a/pom.xml +++ b/pom.xml @@ -216,7 +216,7 @@ org.mockito mockito-core - 2.23.0 + 2.23.4 test From cd6133b068a4a5dc390da482a91febd7500d3ce2 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:49:14 -0500 Subject: [PATCH 062/933] [pom] Update transaction-jdbc to 4.0.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1541bc9bfd..e56b4eefd2 100644 --- a/pom.xml +++ b/pom.xml @@ -146,7 +146,7 @@ com.atomikos transactions-jdbc - 4.0.5 + 4.0.6 test From ea4b64511ebd64bc04ed6e0bafd0a4ccf90b88b7 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:49:25 -0500 Subject: [PATCH 063/933] [pom] Update spring-batch to 4.1.0.RELEASE --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e56b4eefd2..d9432ccfc8 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.0-SNAPSHOT 5.1.3.RELEASE - 4.0.1.RELEASE + 4.1.0.RELEASE 5.3.2 From 9733146e923fa9340fb4185fcc1bee6c6a5444d4 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 17:03:29 -0500 Subject: [PATCH 064/933] [tests] Exclude junit 4 entirely --- pom.xml | 10 ++++++++++ .../SqlSessionTemplateAsyncAfterCompletionTest.java | 8 +++----- .../spring/batch/MyBatisCursorItemReaderTest.java | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index d9432ccfc8..d4e35f0779 100644 --- a/pom.xml +++ b/pom.xml @@ -197,6 +197,12 @@ spring-batch-test ${spring-batch.version} test + + + junit + junit + + @@ -249,6 +255,10 @@ nekohtml nekohtml + + junit + junit + diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java b/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java index d8519e74a5..f97ee8533f 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java @@ -16,9 +16,7 @@ package org.mybatis.spring.asyncsynchronization; import org.jboss.byteman.contrib.bmunit.BMRule; -import org.jboss.byteman.contrib.bmunit.BMUnitRunner; -import org.junit.Ignore; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; import org.mybatis.spring.SqlSessionTemplateTest; @@ -29,8 +27,8 @@ * @author Alex Rykov * */ -@Ignore // FIXME: Enable after migrate BMUnitRunner to BMUnitExtension -@RunWith(BMUnitRunner.class) +@Disabled // FIXME: Enable after migrate BMUnitRunner to BMUnitExtension +// @ExtendWith(BMUnitRunner.class) @BMRule(name = "proxy synchronizations", targetClass = "TransactionSynchronizationManager", targetMethod = "registerSynchronization(TransactionSynchronization)", helper = "org.mybatis.spring.asyncsynchronization.AsyncAfterCompletionHelper", action = "$1=createSynchronizationWithAsyncAfterComplete($1)") public class SqlSessionTemplateAsyncAfterCompletionTest extends SqlSessionTemplateTest { } diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index d0247c2615..f8c2fa6193 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -32,7 +32,7 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStreamException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests for {@link MyBatisCursorItemReader}. From c40732a7a2e793a9490584e2447ea9cc3be3f3c0 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 30 Dec 2018 12:21:15 +0900 Subject: [PATCH 065/933] [pom] Add property declaring Automatic-Module-Name See https://github.com/mybatis/parent/pull/123 --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index d4e35f0779..22464cbf8d 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,7 @@ 3.5.0-SNAPSHOT 5.1.3.RELEASE 4.1.0.RELEASE + org.mybatis.spring 5.3.2 From 8d4816b4a5ac33dcbd500c966de87a9742b7cb08 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 2 Jan 2019 23:03:59 -0500 Subject: [PATCH 066/933] [site] Update site xsd --- src/site/site.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/site.xml b/src/site/site.xml index db1a01bb68..a69b5564a9 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -16,8 +16,8 @@ limitations under the License. --> - +

    From 9c46b6edd0fd35e0fcd15a7e7664ce9b10c77124 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 9 Jan 2019 01:59:49 +0900 Subject: [PATCH 067/933] Polishing tests --- .../org/mybatis/spring/MyBatisSpringTest.java | 54 +++++++++---------- .../spring/SqlSessionFactoryBeanTest.java | 12 ++--- .../spring/SqlSessionTemplateTest.java | 8 +-- .../spring/annotation/MapperScanTest.java | 12 ++--- .../AsyncAfterCompletionHelper.java | 5 +- ...ssionTemplateAsyncAfterCompletionTest.java | 4 +- .../batch/MyBatisCursorItemReaderTest.java | 4 +- .../mybatis/spring/batch/SpringBatchTest.java | 4 +- .../MyBatisBatchItemWriterBuilderTest.java | 4 +- .../MyBatisCursorItemReaderBuilderTest.java | 20 +++---- .../MyBatisPagingItemReaderBuilderTest.java | 24 ++++----- .../mybatis/spring/config/NamespaceTest.java | 8 +-- .../spring/mapper/MapperFactoryBeanTest.java | 4 +- .../mapper/MapperScannerConfigurerTest.java | 10 ++-- .../spring/sample/AbstractSampleTest.java | 4 +- .../spring/sample/SampleBatchTest.java | 4 +- .../spring/sample/SampleEnableTest.java | 4 +- .../spring/sample/SampleJavaConfigTest.java | 4 +- .../spring/sample/SampleMapperTest.java | 4 +- .../spring/sample/SampleNamespaceTest.java | 4 +- .../spring/sample/SampleScannerTest.java | 4 +- .../spring/sample/SampleSqlSessionTest.java | 4 +- .../submitted/autowire/AutowireTest.java | 20 +++---- .../WebappPlaceholderTest.java | 6 +-- .../spring/submitted/xa/UserServiceTest.java | 4 +- .../support/SqlSessionDaoSupportTest.java | 4 +- .../SpringTransactionManagerTest.java | 4 +- 27 files changed, 120 insertions(+), 123 deletions(-) diff --git a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java index b259798094..444718cefc 100644 --- a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,12 +38,12 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.assertThrows; -public final class MyBatisSpringTest extends AbstractMyBatisSpringTest { +class MyBatisSpringTest extends AbstractMyBatisSpringTest { private SqlSession session; @AfterEach - public void validateSessionClose() { + void validateSessionClose() { // assume if the Executor is closed, the Session is too if ((session != null) && !executorInterceptor.isExecutorClosed()) { session = null; @@ -55,7 +55,7 @@ public void validateSessionClose() { // ensure MyBatis API still works with SpringManagedTransaction @Test - public void testMyBatisAPI() { + void testMyBatisAPI() { session = sqlSessionFactory.openSession(); session.getMapper(TestMapper.class).findTest(); session.close(); @@ -66,7 +66,7 @@ public void testMyBatisAPI() { } @Test - public void testMyBatisAPIWithCommit() { + void testMyBatisAPIWithCommit() { session = sqlSessionFactory.openSession(); session.getMapper(TestMapper.class).findTest(); session.commit(true); @@ -78,7 +78,7 @@ public void testMyBatisAPIWithCommit() { } @Test - public void testMyBatisAPIWithRollback() { + void testMyBatisAPIWithRollback() { session = sqlSessionFactory.openSession(); session.getMapper(TestMapper.class).findTest(); session.rollback(true); @@ -91,7 +91,7 @@ public void testMyBatisAPIWithRollback() { // basic tests using SqlSessionUtils instead of using the MyBatis API directly @Test - public void testSpringAPI() { + void testSpringAPI() { session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); SqlSessionUtils.closeSqlSession(session, sqlSessionFactory); @@ -102,7 +102,7 @@ public void testSpringAPI() { } @Test - public void testSpringAPIWithCommit() { + void testSpringAPIWithCommit() { session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); session.commit(true); @@ -113,7 +113,7 @@ public void testSpringAPIWithCommit() { } @Test - public void testSpringAPIWithRollback() { + void testSpringAPIWithRollback() { session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); session.rollback(true); @@ -124,7 +124,7 @@ public void testSpringAPIWithRollback() { } @Test - public void testSpringAPIWithMyBatisClose() { + void testSpringAPIWithMyBatisClose() { // This is a programming error and could lead to connection leak if there is a transaction // in progress. But, the API allows it, so make sure it at least works without a tx. session = SqlSessionUtils.getSqlSession(sqlSessionFactory); @@ -137,7 +137,7 @@ public void testSpringAPIWithMyBatisClose() { // Spring API should work with a MyBatis TransactionFactories @Test - public void testWithNonSpringTransactionFactory() { + void testWithNonSpringTransactionFactory() { Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); @@ -159,7 +159,7 @@ public void testWithNonSpringTransactionFactory() { // Spring TX, non-Spring TransactionFactory, Spring managed DataSource // this should not work since the DS will be out of sync with MyBatis @Test - public void testNonSpringTxFactoryWithTx() throws Exception { + void testNonSpringTxFactoryWithTx() throws Exception { Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); @@ -184,7 +184,7 @@ public void testNonSpringTxFactoryWithTx() throws Exception { // Spring TX, non-Spring TransactionFactory, MyBatis managed DataSource // this should work since the DS is managed MyBatis @Test - public void testNonSpringTxFactoryNonSpringDSWithTx() throws java.sql.SQLException { + void testNonSpringTxFactoryNonSpringDSWithTx() throws java.sql.SQLException { Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); MockDataSource mockDataSource = new MockDataSource(); @@ -222,7 +222,7 @@ public void testNonSpringTxFactoryNonSpringDSWithTx() throws java.sql.SQLExcepti } @Test - public void testChangeExecutorTypeInTx() throws Exception { + void testChangeExecutorTypeInTx() throws Exception { TransactionStatus status = null; try { @@ -244,7 +244,7 @@ public void testChangeExecutorTypeInTx() throws Exception { } @Test - public void testChangeExecutorTypeInTxRequiresNew() throws Exception { + void testChangeExecutorTypeInTxRequiresNew() throws Exception { try { txManager.setDataSource(dataSource); @@ -276,7 +276,7 @@ public void testChangeExecutorTypeInTxRequiresNew() throws Exception { } @Test - public void testWithJtaTxManager() { + void testWithJtaTxManager() { JtaTransactionManager jtaManager = new JtaTransactionManager(new MockUserTransaction()); DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); @@ -297,7 +297,7 @@ public void testWithJtaTxManager() { } @Test - public void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException { + void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException { Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); MockDataSource mockDataSource = new MockDataSource(); @@ -344,7 +344,7 @@ public void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLExcep } @Test - public void testWithTxSupports() { + void testWithTxSupports() { DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_SUPPORTS"); @@ -363,7 +363,7 @@ public void testWithTxSupports() { @Test - public void testRollbackWithTxSupports() { + void testRollbackWithTxSupports() { DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_SUPPORTS"); @@ -381,7 +381,7 @@ public void testRollbackWithTxSupports() { } @Test - public void testWithTxRequired() { + void testWithTxRequired() { DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); @@ -399,7 +399,7 @@ public void testWithTxRequired() { } @Test - public void testSqlSessionCommitWithTx() { + void testSqlSessionCommitWithTx() { DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); @@ -424,7 +424,7 @@ public void testSqlSessionCommitWithTx() { } @Test - public void testWithInterleavedTx() throws Exception { + void testWithInterleavedTx() { // this session will use one Connection session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); @@ -460,7 +460,7 @@ public void testWithInterleavedTx() throws Exception { } @Test - public void testSuspendAndResume() throws Exception { + void testSuspendAndResume() { try { txManager.setDataSource(dataSource); @@ -512,7 +512,7 @@ public void testSuspendAndResume() throws Exception { } @Test - public void testBatch() { + void testBatch() { setupBatchStatements(); session = SqlSessionUtils.getSqlSession(sqlSessionFactory, ExecutorType.BATCH, exceptionTranslator); @@ -533,7 +533,7 @@ public void testBatch() { } @Test - public void testBatchInTx() { + void testBatchInTx() { setupBatchStatements(); DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); @@ -557,7 +557,7 @@ public void testBatchInTx() { } @Test - public void testBatchWithError() { + void testBatchWithError() { try { setupBatchStatements(); @@ -577,7 +577,7 @@ public void testBatchWithError() { } @Test - public void testBatchInTxWithError() { + void testBatchInTxWithError() { setupBatchStatements(); DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 6f32911faf..d26297f498 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ import com.mockrunner.mock.jdbc.MockDataSource; -public final class SqlSessionFactoryBeanTest { +class SqlSessionFactoryBeanTest { private static final class TestObjectFactory extends DefaultObjectFactory { private static final long serialVersionUID = 1L;} @@ -57,7 +57,7 @@ private static final class TestObjectWrapperFactory extends DefaultObjectWrapper private SqlSessionFactoryBean factoryBean; - public void setupFactoryBean() { + void setupFactoryBean() { factoryBean = new SqlSessionFactoryBean(); factoryBean.setDataSource(dataSource); } @@ -72,20 +72,20 @@ void testDefaults() throws Exception { // DataSource is the only required property that does not have a default value, so test for both // not setting it at all and setting it to null @Test - void testNullDataSource() throws Exception { + void testNullDataSource() { factoryBean = new SqlSessionFactoryBean(); assertThrows(IllegalArgumentException.class, factoryBean::getObject); } @Test - void testSetNullDataSource() throws Exception { + void testSetNullDataSource() { factoryBean = new SqlSessionFactoryBean(); factoryBean.setDataSource(null); assertThrows(IllegalArgumentException.class, factoryBean::getObject); } @Test - void testNullSqlSessionFactoryBuilder() throws Exception { + void testNullSqlSessionFactoryBuilder() { setupFactoryBean(); factoryBean.setSqlSessionFactoryBuilder(null); assertThrows(IllegalArgumentException.class, factoryBean::getObject); diff --git a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java index 7cbcc357a3..e248424f2c 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,17 +79,17 @@ void testGetConnectionInTx() throws java.sql.SQLException { } @Test - void testCommit() throws SQLException { + void testCommit() { assertThrows(UnsupportedOperationException.class, sqlSessionTemplate::commit); } @Test - void testClose() throws SQLException { + void testClose() { assertThrows(UnsupportedOperationException.class, sqlSessionTemplate::close); } @Test - void testRollback() throws SQLException { + void testRollback() { assertThrows(UnsupportedOperationException.class, sqlSessionTemplate::rollback); } diff --git a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java index f2f5efaf11..98281c4f1b 100644 --- a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java +++ b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,14 +46,14 @@ *

    * This test works fine with Spring 3.1 and 3.2 but with 3.1 the registrar is called twice. */ -public final class MapperScanTest { +class MapperScanTest { private AnnotationConfigApplicationContext applicationContext; @BeforeEach void setupContext() { applicationContext = new AnnotationConfigApplicationContext(); - setupSqlSessionFactory("sqlSessionFactory"); + setupSqlSessionFactory(); // assume support for autowiring fields is added by MapperScannerConfigurer // via @@ -195,11 +195,11 @@ void testScanWithNameConflict() { .isSameAs(Object.class); } - private void setupSqlSessionFactory(String name) { + private void setupSqlSessionFactory() { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); definition.getPropertyValues().add("dataSource", new MockDataSource()); - applicationContext.registerBeanDefinition(name, definition); + applicationContext.registerBeanDefinition("sqlSessionFactory", definition); } private void assertBeanNotLoaded(String name) { @@ -225,7 +225,7 @@ void testScanWithExplicitSqlSessionFactory() { } @Test - void testScanWithExplicitSqlSessionTemplate() throws Exception { + void testScanWithExplicitSqlSessionTemplate() { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionTemplate.class); ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues(); diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java index f6c44ca170..a45a7eeda4 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,9 +80,6 @@ public Object invoke(final Object proxy, final Method method, /** * Creates proxy that performs afterCompletion call on a separate thread - * - * @param synchronization - * @return */ public TransactionSynchronization createSynchronizationWithAsyncAfterComplete( TransactionSynchronization synchronization) { diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java b/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java index f97ee8533f..5931d518af 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/SqlSessionTemplateAsyncAfterCompletionTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,5 +30,5 @@ @Disabled // FIXME: Enable after migrate BMUnitRunner to BMUnitExtension // @ExtendWith(BMUnitRunner.class) @BMRule(name = "proxy synchronizations", targetClass = "TransactionSynchronizationManager", targetMethod = "registerSynchronization(TransactionSynchronization)", helper = "org.mybatis.spring.asyncsynchronization.AsyncAfterCompletionHelper", action = "$1=createSynchronizationWithAsyncAfterComplete($1)") -public class SqlSessionTemplateAsyncAfterCompletionTest extends SqlSessionTemplateTest { +class SqlSessionTemplateAsyncAfterCompletionTest extends SqlSessionTemplateTest { } diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index f8c2fa6193..a9ca7ba55a 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ private List getFoos() { private static class Foo { private final String name; - public Foo(String name) { + Foo(String name) { this.name = name; } diff --git a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java index 2f947f92b3..5ee9e9c3bd 100644 --- a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java +++ b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.transaction.annotation.Transactional; @SpringJUnitConfig(locations = {"classpath:org/mybatis/spring/batch/applicationContext.xml"}) -public class SpringBatchTest { +class SpringBatchTest { @Autowired @Qualifier("pagingNoNestedItemReader") diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index bb92161cea..cdac5b47f3 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -178,7 +178,7 @@ private List getFoos() { private static class Foo { private final String name; - public Foo(String name) { + Foo(String name) { this.name = name; } diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index c7559dc598..af3cb00085 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,9 +75,9 @@ void testConfiguration() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo3"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo3"); itemReader.update(executionContext); Assertions.assertThat(executionContext.getInt("MyBatisCursorItemReader.read.count")) @@ -104,9 +104,9 @@ void testConfigurationSaveStateIsFalse() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo3"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo3"); itemReader.update(executionContext); Assertions.assertThat(executionContext.isEmpty()).isTrue(); @@ -129,8 +129,8 @@ void testConfigurationMaxItemCount() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); itemReader.update(executionContext); Assertions.assertThat(executionContext.getInt("MyBatisCursorItemReader.read.count.max")) @@ -146,7 +146,7 @@ private List getFoos() { private static class Foo { private final String name; - public Foo(String name) { + Foo(String name) { this.name = name; } diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index 550763ba41..20d60fbec3 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,9 +87,9 @@ void testConfiguration() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo3"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo3"); itemReader.update(executionContext); Assertions.assertThat(executionContext.getInt("MyBatisPagingItemReader.read.count")) @@ -115,9 +115,9 @@ void testConfigurationSaveStateIsFalse() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo3"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo3"); itemReader.update(executionContext); Assertions.assertThat(executionContext.isEmpty()).isTrue(); @@ -138,8 +138,8 @@ void testConfigurationMaxItemCount() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); itemReader.update(executionContext); Assertions.assertThat(executionContext.getInt("MyBatisPagingItemReader.read.count.max")) @@ -170,8 +170,8 @@ void testConfigurationPageSize() throws Exception { ExecutionContext executionContext = new ExecutionContext(); itemReader.open(executionContext); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo1"); - Assertions.assertThat(itemReader.read().getName()).isEqualTo("foo2"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); + Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo2"); Assertions.assertThat(itemReader.read()).isNull(); } @@ -182,7 +182,7 @@ private List getFoos() { private static class Foo { private final String name; - public Foo(String name) { + Foo(String name) { this.name = name; } diff --git a/src/test/java/org/mybatis/spring/config/NamespaceTest.java b/src/test/java/org/mybatis/spring/config/NamespaceTest.java index fff82c5177..060e004106 100644 --- a/src/test/java/org/mybatis/spring/config/NamespaceTest.java +++ b/src/test/java/org/mybatis/spring/config/NamespaceTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ * This test works fine with Spring 3.1 and 3.2 but with 3.1 the registrar is * called twice. */ -public final class NamespaceTest { +class NamespaceTest { private ClassPathXmlApplicationContext applicationContext; private void startContext() { @@ -143,7 +143,7 @@ void testMarkerInterfaceAndAnnotationScan() { } @Test - void testScanWithExplicitSqlSessionFactory() throws Exception { + void testScanWithExplicitSqlSessionFactory() { applicationContext = new ClassPathXmlApplicationContext(new String[] { "org/mybatis/spring/config/factory-ref.xml" }, setupSqlSessionFactory()); @@ -157,7 +157,7 @@ void testScanWithExplicitSqlSessionFactory() throws Exception { } @Test - void testScanWithExplicitSqlSessionTemplate() throws Exception { + void testScanWithExplicitSqlSessionTemplate() { applicationContext = new ClassPathXmlApplicationContext(new String[] { "org/mybatis/spring/config/factory-ref.xml" }, setupSqlSessionTemplate()); diff --git a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java index 3aae939b8b..3473095483 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import com.mockrunner.mock.jdbc.MockConnection; import com.mockrunner.mock.jdbc.MockDataSource; -public final class MapperFactoryBeanTest extends AbstractMyBatisSpringTest { +class MapperFactoryBeanTest extends AbstractMyBatisSpringTest { private static SqlSessionTemplate sqlSessionTemplate; diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index 313a3b8f46..6643a62abf 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import com.mockrunner.mock.jdbc.MockDataSource; -public final class MapperScannerConfigurerTest { +class MapperScannerConfigurerTest { private GenericApplicationContext applicationContext; @BeforeEach @@ -160,7 +160,7 @@ void testMarkerInterfaceAndAnnotationScan() { } @Test - void testScanWithExplicitSqlSessionFactory() throws Exception { + void testScanWithExplicitSqlSessionFactory() { setupSqlSessionFactory("sqlSessionFactory2"); applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add( @@ -170,7 +170,7 @@ void testScanWithExplicitSqlSessionFactory() throws Exception { } @Test - void testScanWithExplicitSqlSessionTemplate() throws Exception { + void testScanWithExplicitSqlSessionTemplate() { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionTemplate.class); ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues(); @@ -185,7 +185,7 @@ void testScanWithExplicitSqlSessionTemplate() throws Exception { } @Test - void testScanWithExplicitSqlSessionFactoryViaPlaceholder() throws Exception { + void testScanWithExplicitSqlSessionFactoryViaPlaceholder() { setupSqlSessionFactory("sqlSessionFactory2"); // use a property placeholder for the session factory name diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java index ad6cb46869..523a37756d 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.springframework.test.annotation.DirtiesContext; @DirtiesContext -public abstract class AbstractSampleTest { +abstract class AbstractSampleTest { @Autowired protected FooService fooService; diff --git a/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java b/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java index 1c99a31023..f3fdf43a9d 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ * Example of MyBatis-Spring batch integration usage. */ @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-batch.xml" }) -public class SampleBatchTest extends AbstractSampleTest { +class SampleBatchTest extends AbstractSampleTest { // Note this does not actually test batch functionality since FooService // only calls one DAO method. This class and associated Spring context // simply show that no implementation changes are needed to enable diff --git a/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java b/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java index 7d5ccdd308..3063f2934a 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ * @since 1.2.0 */ @SpringJUnitConfig -public class SampleEnableTest extends AbstractSampleTest { +class SampleEnableTest extends AbstractSampleTest { @Configuration @ImportResource("classpath:org/mybatis/spring/sample/config/applicationContext-infrastructure.xml") diff --git a/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java index 1373ab1c94..d3d027a695 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @SpringJUnitConfig(classes = SampleConfig.class) -public class SampleJavaConfigTest { +class SampleJavaConfigTest { @Autowired private FooService fooService; diff --git a/src/test/java/org/mybatis/spring/sample/SampleMapperTest.java b/src/test/java/org/mybatis/spring/sample/SampleMapperTest.java index 832b01cadb..db10752fd2 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleMapperTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleMapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,5 +22,5 @@ * MapperFactoryBean. */ @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-mapper.xml" }) -public class SampleMapperTest extends AbstractSampleTest { +class SampleMapperTest extends AbstractSampleTest { } diff --git a/src/test/java/org/mybatis/spring/sample/SampleNamespaceTest.java b/src/test/java/org/mybatis/spring/sample/SampleNamespaceTest.java index 0bf5b72d98..8aeaece16d 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleNamespaceTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleNamespaceTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,5 +22,5 @@ * MapperScannerConfigurer. */ @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-namespace.xml" }) -public class SampleNamespaceTest extends AbstractSampleTest { +class SampleNamespaceTest extends AbstractSampleTest { } diff --git a/src/test/java/org/mybatis/spring/sample/SampleScannerTest.java b/src/test/java/org/mybatis/spring/sample/SampleScannerTest.java index 6e9a46e8b1..b401f03499 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleScannerTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleScannerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,5 +22,5 @@ * MapperScannerConfigurer. */ @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-scanner.xml" }) -public class SampleScannerTest extends AbstractSampleTest { +class SampleScannerTest extends AbstractSampleTest { } diff --git a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java index f472fa6ee7..8f061b7696 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ */ @DirtiesContext @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-sqlsession.xml" }) -public class SampleSqlSessionTest { +class SampleSqlSessionTest { @Autowired private BarService barService; diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java b/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java index cec0071d03..1922462bfa 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,20 +20,20 @@ import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; -public class AutowireTest { - private ClassPathXmlApplicationContext context; +class AutowireTest { @Test void shouldReturnMapper() { - context = new ClassPathXmlApplicationContext("classpath:org/mybatis/spring/submitted/autowire/spring.xml"); + try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:org/mybatis/spring/submitted/autowire/spring.xml")) { - FooMapper fooMapper = (FooMapper) context.getBean("fooMapper"); - assertThat(fooMapper).isNotNull(); - fooMapper.executeFoo(); + FooMapper fooMapper = (FooMapper) context.getBean("fooMapper"); + assertThat(fooMapper).isNotNull(); + fooMapper.executeFoo(); - BarMapper barMapper = (BarMapper) context.getBean("barMapper"); - assertThat(barMapper).isNotNull(); - barMapper.executeBar(); + BarMapper barMapper = (BarMapper) context.getBean("barMapper"); + assertThat(barMapper).isNotNull(); + barMapper.executeBar(); + } } } diff --git a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java index 41e0a71dd6..ae61535f3e 100644 --- a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java +++ b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,13 +27,13 @@ @ExtendWith(SpringExtension.class) @WebAppConfiguration @SpringJUnitConfig(locations = "file:src/test/java/org/mybatis/spring/submitted/webapp_placeholder/spring.xml") -public class WebappPlaceholderTest { +class WebappPlaceholderTest { @Autowired private Mapper mapper; @Test - void testName() throws Exception { + void testName() { assertThat(mapper).isNotNull(); } } diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java index f4bef0609a..7d1571e1ac 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ @ExtendWith(SpringExtension.class) @SpringJUnitConfig(locations = "classpath:org/mybatis/spring/submitted/xa/applicationContext.xml") -public class UserServiceTest { +class UserServiceTest { @Autowired UserTransaction userTransaction; diff --git a/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java b/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java index c441605055..927f60dca9 100644 --- a/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java +++ b/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.support.GenericApplicationContext; -public final class SqlSessionDaoSupportTest extends AbstractMyBatisSpringTest { +class SqlSessionDaoSupportTest extends AbstractMyBatisSpringTest { private SqlSessionDaoSupport sqlSessionDaoSupport; private GenericApplicationContext applicationContext; diff --git a/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java b/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java index 45272e24a6..e3ab0f7267 100644 --- a/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java +++ b/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.DefaultTransactionDefinition; -public final class SpringTransactionManagerTest extends AbstractMyBatisSpringTest { +class SpringTransactionManagerTest extends AbstractMyBatisSpringTest { @Test void shouldNoOpWithTx() throws Exception { From 82555b4034899044c36cc7e560f2e9c547eb6068 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 9 Jan 2019 02:01:29 +0900 Subject: [PATCH 068/933] Update license header --- src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index a69b5564a9..e91f2c7d3a 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,7 +1,7 @@ + + + + diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index 6643a62abf..068ecda273 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -16,6 +16,7 @@ package org.mybatis.spring.mapper; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.util.Properties; @@ -28,6 +29,7 @@ import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.mapper.child.MapperChildInterface; +import org.mybatis.spring.type.DummyMapperFactoryBean; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConstructorArgumentValues; @@ -254,6 +256,23 @@ void testScanWithPropertyPlaceholders() { assertThat(sessionFactory.getConfiguration().getDefaultExecutorType()).isSameAs(ExecutorType.REUSE); } + @Test + void testScanWithMapperFactoryBeanClass() { + DummyMapperFactoryBean.clear(); + applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add( + "mapperFactoryBeanClass", DummyMapperFactoryBean.class); + + startContext(); + + applicationContext.getBean("mapperInterface"); + applicationContext.getBean("mapperSubinterface"); + applicationContext.getBean("mapperChildInterface"); + applicationContext.getBean("annotatedMapper"); + + assertTrue(DummyMapperFactoryBean.getMapperCount() > 0); + } + + private void setupSqlSessionFactory(String name) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); diff --git a/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java b/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java index e070594934..413ee6ac43 100644 --- a/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java +++ b/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,4 +77,9 @@ private SqlSessionFactory getCustomSessionFactoryForClass() { public static int getMapperCount(){ return mapperInstanceCount.get(); } + + public static void clear() { + mapperInstanceCount.set(0); + } + } From 8cbe76c024905dbc372208b7f4efac147c2452a3 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 1 Apr 2019 00:21:40 +0900 Subject: [PATCH 085/933] Upgrade to Spring 5.1.6 Fixes gh-353 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a67f1b4d36..bd7caa7597 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.0 - 5.1.5.RELEASE + 5.1.6.RELEASE 4.1.1.RELEASE org.mybatis.spring From a9f5895cabb86d76957670ccf933e227fa5b532c Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 1 Apr 2019 00:39:41 +0900 Subject: [PATCH 086/933] Change comparison version to 1.3.2 for Clirr Fixes gh-354 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bd7caa7597..0e48041ed5 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ - 1.2.2 + 1.3.2 org.mybatis.spring.*,org.mybatis.spring.mapper.*,org.mybatis.spring.support.*,org.mybatis.spring.transaction.* Spring org.springframework.batch.*;resolution:=optional,* From 3522ab2889c7980743f7053d25163968b86e8eb3 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Mon, 1 Apr 2019 13:22:07 +0800 Subject: [PATCH 087/933] Translate explanation for MyBatisBatchItemWriter#itemToParameterConverter --- src/site/zh/xdoc/batch.xml | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/site/zh/xdoc/batch.xml b/src/site/zh/xdoc/batch.xml index 0e519959a3..a28118e4b5 100644 --- a/src/site/zh/xdoc/batch.xml +++ b/src/site/zh/xdoc/batch.xml @@ -1,7 +1,7 @@ + From 5f042d53330fd01767cc8a847c6257ad7ad07531 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 3 Apr 2019 22:45:31 +0900 Subject: [PATCH 088/933] Optimize xsd for ide hints. Using to let ide recognize the attribute is kind of , so ide can provide more information for this attribute. Affected attribute: - factory-ref - template-ref Apply gh-284 to master branch --- .../org/mybatis/spring/config/mybatis-spring.xsd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/config/mybatis-spring.xsd b/src/main/java/org/mybatis/spring/config/mybatis-spring.xsd index 404663555d..c2ff96e749 100644 --- a/src/main/java/org/mybatis/spring/config/mybatis-spring.xsd +++ b/src/main/java/org/mybatis/spring/config/mybatis-spring.xsd @@ -78,7 +78,12 @@ - + + + + + + @@ -88,6 +93,11 @@ Specifies which SqlSessionTemplate to use in the case that there is more than one in the spring context. Usually this is only needed when you have more than one datasource. ]]> + + + + + From 457c6854d5ce9e18b9165de224d5e2b490f0ec23 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 4 Apr 2019 09:53:58 +0900 Subject: [PATCH 089/933] Update license year --- .../java/org/mybatis/spring/batch/MyBatisPagingItemReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 286a99e665..d2fe9b8f73 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 73e1c6bc9766e207449857345a32074d2823ec93 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 4 Apr 2019 12:37:09 +0900 Subject: [PATCH 090/933] Allow to specify a wildcard at typeAliasesPackage and typeHandlersPackage Related with gh-175 --- .../mybatis/spring/SqlSessionFactoryBean.java | 79 +++++++++++++------ .../spring/SqlSessionFactoryBeanTest.java | 28 ++++++- 2 files changed, 81 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index faa8444fb4..be8889873e 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -15,24 +15,21 @@ */ package org.mybatis.spring; -import static org.springframework.util.Assert.notNull; -import static org.springframework.util.Assert.state; -import static org.springframework.util.ObjectUtils.isEmpty; -import static org.springframework.util.StringUtils.hasLength; -import static org.springframework.util.StringUtils.tokenizeToStringArray; - +import javax.sql.DataSource; import java.io.IOException; +import java.lang.reflect.Modifier; import java.sql.SQLException; +import java.util.HashSet; import java.util.Optional; import java.util.Properties; +import java.util.Set; import java.util.stream.Stream; -import javax.sql.DataSource; - import org.apache.ibatis.builder.xml.XMLConfigBuilder; import org.apache.ibatis.builder.xml.XMLMapperBuilder; import org.apache.ibatis.cache.Cache; import org.apache.ibatis.executor.ErrorContext; +import org.apache.ibatis.io.Resources; import org.apache.ibatis.io.VFS; import org.apache.ibatis.mapping.DatabaseIdProvider; import org.apache.ibatis.mapping.Environment; @@ -55,7 +52,19 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.core.NestedIOException; import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.core.type.ClassMetadata; +import org.springframework.core.type.classreading.CachingMetadataReaderFactory; +import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; +import org.springframework.util.ClassUtils; + +import static org.springframework.util.Assert.notNull; +import static org.springframework.util.Assert.state; +import static org.springframework.util.ObjectUtils.isEmpty; +import static org.springframework.util.StringUtils.hasLength; +import static org.springframework.util.StringUtils.tokenizeToStringArray; /** * {@code FactoryBean} that creates an MyBatis {@code SqlSessionFactory}. @@ -79,6 +88,9 @@ public class SqlSessionFactoryBean implements FactoryBean, In private static final Logger LOGGER = LoggerFactory.getLogger(SqlSessionFactoryBean.class); + private static final ResourcePatternResolver RESOURCE_PATTERN_RESOLVER = new PathMatchingResourcePatternResolver(); + private static final MetadataReaderFactory METADATA_READER_FACTORY = new CachingMetadataReaderFactory(); + private Resource configLocation; private Configuration configuration; @@ -211,6 +223,8 @@ public void setPlugins(Interceptor[] plugins) { /** * Packages to search for type aliases. * + *

    Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.model}. + * * @since 1.0.1 * * @param typeAliasesPackage package to scan for domain objects @@ -236,6 +250,8 @@ public void setTypeAliasesSuperType(Class typeAliasesSuperType) { /** * Packages to search for type handlers. * + *

    Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.typehandler}. + * @since 1.0.1 * * @param typeHandlersPackage package to scan for type handlers @@ -416,9 +432,9 @@ public void afterPropertiesSet() throws Exception { * Since 1.3.0, it can be specified a {@link Configuration} instance directly(without config file). * * @return SqlSessionFactory - * @throws IOException if loading the config file failed + * @throws Exception if configuration is failed */ - protected SqlSessionFactory buildSqlSessionFactory() throws IOException { + protected SqlSessionFactory buildSqlSessionFactory() throws Exception { final Configuration targetConfiguration; @@ -444,13 +460,8 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException { Optional.ofNullable(this.vfs).ifPresent(targetConfiguration::setVfsImpl); if (hasLength(this.typeAliasesPackage)) { - String[] typeAliasPackageArray = tokenizeToStringArray(this.typeAliasesPackage, - ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); - Stream.of(typeAliasPackageArray).forEach(packageToScan -> { - targetConfiguration.getTypeAliasRegistry().registerAliases(packageToScan, - typeAliasesSuperType == null ? Object.class : typeAliasesSuperType); - LOGGER.debug(() -> "Scanned package: '" + packageToScan + "' for aliases"); - }); + scanClasses(this.typeAliasesPackage, this.typeAliasesSuperType) + .forEach(targetConfiguration.getTypeAliasRegistry()::registerAlias); } if (!isEmpty(this.typeAliases)) { @@ -468,12 +479,11 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException { } if (hasLength(this.typeHandlersPackage)) { - String[] typeHandlersPackageArray = tokenizeToStringArray(this.typeHandlersPackage, - ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); - Stream.of(typeHandlersPackageArray).forEach(packageToScan -> { - targetConfiguration.getTypeHandlerRegistry().register(packageToScan); - LOGGER.debug(() -> "Scanned package: '" + packageToScan + "' for type handlers"); - }); + scanClasses(this.typeHandlersPackage, TypeHandler.class).stream() + .filter(clazz -> !clazz.isInterface()) + .filter(clazz -> !Modifier.isAbstract(clazz.getModifiers())) + .filter(clazz -> ClassUtils.getConstructorIfAvailable(clazz) != null) + .forEach(targetConfiguration.getTypeHandlerRegistry()::register); } if (!isEmpty(this.typeHandlers)) { @@ -571,4 +581,27 @@ public void onApplicationEvent(ApplicationEvent event) { } } + private Set> scanClasses(String packagePatterns, Class assignableType) + throws IOException { + Set> classes = new HashSet<>(); + String[] packagePatternArray = tokenizeToStringArray(packagePatterns, + ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); + for (String packagePattern : packagePatternArray) { + Resource[] resources = RESOURCE_PATTERN_RESOLVER.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + + ClassUtils.convertClassNameToResourcePath(packagePattern) + "/**/*.class"); + for (Resource resource : resources) { + try { + ClassMetadata classMetadata = METADATA_READER_FACTORY.getMetadataReader(resource).getClassMetadata(); + Class clazz = Resources.classForName(classMetadata.getClassName()); + if (assignableType == null || assignableType.isAssignableFrom(clazz)) { + classes.add(clazz); + } + } catch (Throwable e) { + LOGGER.warn(() -> "Cannot load the '" + resource + "'. Cause by " + e.toString()); + } + } + } + return classes; + } + } diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index d26297f498..6ac564fb70 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -341,7 +341,7 @@ void testAddATypeAlias() throws Exception { @Test void testSearchATypeAliasPackage() throws Exception { setupFactoryBean(); - factoryBean.setTypeAliasesPackage("org/mybatis/spring/type"); + factoryBean.setTypeAliasesPackage("org.mybatis.spring.type"); TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias"); @@ -354,7 +354,7 @@ void testSearchATypeAliasPackage() throws Exception { void testSearchATypeAliasPackageWithSuperType() throws Exception { setupFactoryBean(); factoryBean.setTypeAliasesSuperType(SuperType.class); - factoryBean.setTypeAliasesPackage("org/mybatis/spring/type"); + factoryBean.setTypeAliasesPackage("org.mybatis.*.type"); TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias2"); @@ -364,10 +364,32 @@ void testSearchATypeAliasPackageWithSuperType() throws Exception { assertThrows(TypeException.class, () -> typeAliasRegistry.resolveAlias("dummyTypeHandler")); } + @Test + void testSearchATypeAliasPackageWithSamePackage() throws Exception { + setupFactoryBean(); + factoryBean.setTypeAliasesPackage("org.mybatis.spring.type, org.*.spring.type"); + + TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); + typeAliasRegistry.resolveAlias("testAlias"); + typeAliasRegistry.resolveAlias("testAlias2"); + typeAliasRegistry.resolveAlias("dummyTypeHandler"); + typeAliasRegistry.resolveAlias("superType"); + } + @Test void testSearchATypeHandlerPackage() throws Exception { setupFactoryBean(); - factoryBean.setTypeHandlersPackage("org/mybatis/spring/type"); + factoryBean.setTypeHandlersPackage("org.**.type"); + + TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); + assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); + assertThat(typeHandlerRegistry.hasTypeHandler(BigDecimal.class)).isTrue(); + } + + @Test + void testSearchATypeHandlerPackageWithSamePackage() throws Exception { + setupFactoryBean(); + factoryBean.setTypeHandlersPackage("org.mybatis.spring.type, org.mybatis.*.type"); TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); From 5879993c7bd32efeb71bafc4bf6efd46a9b7f69d Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 5 Apr 2019 23:00:41 +0900 Subject: [PATCH 091/933] Change sample code for creating Mapper bean using JavaConfig on doc Fixes gh-124 --- src/site/es/xdoc/mappers.xml | 20 +++++--------------- src/site/ja/xdoc/mappers.xml | 18 +++++------------- src/site/ko/xdoc/mappers.xml | 14 +++++--------- src/site/xdoc/mappers.xml | 23 +++++------------------ src/site/zh/xdoc/mappers.xml | 16 +++++----------- 5 files changed, 25 insertions(+), 66 deletions(-) diff --git a/src/site/es/xdoc/mappers.xml b/src/site/es/xdoc/mappers.xml index 5f0656b734..c5bb5133c0 100644 --- a/src/site/es/xdoc/mappers.xml +++ b/src/site/es/xdoc/mappers.xml @@ -1,7 +1,7 @@ + + + + From 482df3d20e0e69521cca33a3da1333f131d3755d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 22 Dec 2018 16:29:03 -0500 Subject: [PATCH 103/933] [ci] Start enforcing formatting --- format.xml | 2 +- .../spring/MyBatisExceptionTranslator.java | 19 +- .../spring/MyBatisSystemException.java | 9 +- .../mybatis/spring/SqlSessionFactoryBean.java | 191 ++++++++++-------- .../org/mybatis/spring/SqlSessionHolder.java | 21 +- .../mybatis/spring/SqlSessionTemplate.java | 128 ++++++------ .../org/mybatis/spring/SqlSessionUtils.java | 110 +++++----- .../mybatis/spring/annotation/MapperScan.java | 53 +++-- .../annotation/MapperScannerRegistrar.java | 25 +-- .../spring/annotation/MapperScans.java | 10 +- .../spring/batch/MyBatisBatchItemWriter.java | 51 ++--- .../spring/batch/MyBatisCursorItemReader.java | 16 +- .../spring/batch/MyBatisPagingItemReader.java | 19 +- .../MyBatisBatchItemWriterBuilder.java | 21 +- .../MyBatisCursorItemReaderBuilder.java | 20 +- .../MyBatisPagingItemReaderBuilder.java | 23 ++- .../MapperScannerBeanDefinitionParser.java | 13 +- .../spring/mapper/ClassPathMapperScanner.java | 49 ++--- .../spring/mapper/MapperFactoryBean.java | 28 +-- .../mapper/MapperScannerConfigurer.java | 138 +++++++------ .../mybatis/spring/mapper/package-info.java | 5 +- .../spring/support/SqlSessionDaoSupport.java | 55 +++-- .../transaction/SpringManagedTransaction.java | 30 ++- src/site/es/xdoc/getting-started.xml.vm | 2 +- src/site/ja/xdoc/getting-started.xml.vm | 2 +- src/site/ko/xdoc/getting-started.xml.vm | 2 +- src/site/xdoc/getting-started.xml.vm | 2 +- src/site/zh/xdoc/getting-started.xml.vm | 2 +- .../spring/AbstractMyBatisSpringTest.java | 10 +- .../mybatis/spring/ExecutorInterceptor.java | 14 +- .../org/mybatis/spring/MyBatisSpringTest.java | 27 +-- .../spring/SqlSessionFactoryBeanTest.java | 33 +-- .../spring/SqlSessionTemplateTest.java | 5 +- .../spring/annotation/MapperScanTest.java | 13 +- .../AsyncAfterCompletionHelper.java | 9 +- ...ssionTemplateAsyncAfterCompletionTest.java | 1 - .../batch/MyBatisBatchItemWriterTest.java | 18 +- .../batch/MyBatisCursorItemReaderTest.java | 6 +- .../mybatis/spring/batch/SpringBatchTest.java | 2 +- .../MyBatisBatchItemWriterBuilderTest.java | 11 +- .../MyBatisCursorItemReaderBuilderTest.java | 15 +- .../MyBatisPagingItemReaderBuilderTest.java | 12 +- .../mybatis/spring/batch/domain/Employee.java | 9 +- .../mybatis/spring/config/NamespaceTest.java | 27 ++- .../spring/mapper/MapperFactoryBeanTest.java | 12 +- .../mapper/MapperScannerConfigurerTest.java | 51 ++--- .../spring/sample/AbstractSampleJobTest.java | 6 +- .../spring/sample/SampleEnableTest.java | 13 +- .../sample/SampleJobJavaConfigTest.java | 12 +- .../spring/sample/SampleJobXmlConfigTest.java | 5 +- .../spring/sample/SampleMapperTest.java | 3 +- .../spring/sample/SampleNamespaceTest.java | 3 +- .../spring/sample/SampleScannerTest.java | 3 +- .../spring/sample/SampleSqlSessionTest.java | 4 +- .../spring/sample/config/SampleConfig.java | 8 +- .../spring/sample/config/SampleJobConfig.java | 27 ++- .../spring/sample/dao/UserDaoImpl.java | 9 +- .../mybatis/spring/sample/domain/Person.java | 5 +- .../spring/sample/mapper/UserMapper.java | 6 +- .../spring/sample/mapper/package-info.java | 3 +- .../mybatis/spring/sample/package-info.java | 7 +- .../org/mybatis/spring/scan/ScanClass1.java | 10 +- .../org/mybatis/spring/scan/ScanClass2.java | 10 +- .../submitted/autowire/AutowireTest.java | 3 +- .../org/mybatis/spring/submitted/xa/User.java | 4 +- .../spring/submitted/xa/UserMapper.java | 12 +- .../spring/submitted/xa/UserService.java | 4 +- .../spring/submitted/xa/UserServiceImpl.java | 10 +- .../spring/submitted/xa/UserServiceTest.java | 13 +- .../support/SqlSessionDaoSupportTest.java | 3 +- .../SpringTransactionManagerTest.java | 39 ++-- .../spring/type/DummyMapperFactoryBean.java | 21 +- .../spring/type/TypeHandlerFactory.java | 2 +- 73 files changed, 784 insertions(+), 782 deletions(-) diff --git a/format.xml b/format.xml index 24b6985d56..79299fcf65 100644 --- a/format.xml +++ b/format.xml @@ -1,7 +1,7 @@ diff --git a/license.txt b/license.txt index 4ce1777ad3..7b093985c2 100644 --- a/license.txt +++ b/license.txt @@ -1,13 +1,13 @@ - Copyright ${license.git.copyrightYears} the original author or authors. +Copyright ${license.git.copyrightYears} the original author or authors. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/pom.xml b/pom.xml index 910a6e360f..62c3bf47fc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,19 +1,19 @@ diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 4eb2bf9920..5152e1e5b9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -1,19 +1,19 @@ diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java b/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java index 229ecbf040..06c7f4ccec 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java @@ -1,17 +1,17 @@ /** - * Copyright 2010-2017 the original author or authors. + * Copyright 2010-2017 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.mybatis.spring.submitted.autowire; diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.xml b/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.xml index 0fc3998111..34b9ccedef 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.xml +++ b/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.xml @@ -1,19 +1,19 @@ diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/IBar.java b/src/test/java/org/mybatis/spring/submitted/autowire/IBar.java index 01214a1676..85c519feea 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/IBar.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/IBar.java @@ -1,17 +1,17 @@ /** - * Copyright 2010-2015 the original author or authors. + * Copyright 2010-2015 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.mybatis.spring.submitted.autowire; diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/IFoo.java b/src/test/java/org/mybatis/spring/submitted/autowire/IFoo.java index cf653f95d2..a37698d4f2 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/IFoo.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/IFoo.java @@ -1,17 +1,17 @@ /** - * Copyright 2010-2015 the original author or authors. + * Copyright 2010-2015 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.mybatis.spring.submitted.autowire; diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-bar.sql b/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-bar.sql index 482d804eec..a9817a2418 100755 --- a/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-bar.sql +++ b/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-bar.sql @@ -1,17 +1,17 @@ -- --- Copyright 2010-2016 the original author or authors. +-- Copyright 2010-2016 the original author or authors. -- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- http://www.apache.org/licenses/LICENSE-2.0 -- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. -- create table bar ( diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-foo.sql b/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-foo.sql index 7274a7be13..553655e968 100755 --- a/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-foo.sql +++ b/src/test/java/org/mybatis/spring/submitted/autowire/database-schema-foo.sql @@ -1,17 +1,17 @@ -- --- Copyright 2010-2016 the original author or authors. +-- Copyright 2010-2016 the original author or authors. -- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- http://www.apache.org/licenses/LICENSE-2.0 -- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. -- create table foo ( diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml b/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml index fca573a572..228629cc04 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml +++ b/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml @@ -1,19 +1,19 @@ diff --git a/travis/after_success.sh b/travis/after_success.sh index a37744227e..ec77ede661 100644 --- a/travis/after_success.sh +++ b/travis/after_success.sh @@ -1,18 +1,18 @@ #!/bin/bash # -# Copyright 2010-2017 the original author or authors. +# Copyright 2010-2017 the original author or authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # diff --git a/travis/settings.xml b/travis/settings.xml index 44eb340264..367e020125 100644 --- a/travis/settings.xml +++ b/travis/settings.xml @@ -1,19 +1,19 @@ Date: Sun, 21 Apr 2019 20:50:44 -0400 Subject: [PATCH 116/933] [ci] Update copyright headers after fixing license headers --- src/changes/changes.xml | 2 +- src/main/java/org/mybatis/logging/Logger.java | 2 +- src/main/java/org/mybatis/spring/annotation/package-info.java | 2 +- .../java/org/mybatis/spring/batch/builder/package-info.java | 2 +- src/main/java/org/mybatis/spring/batch/package-info.java | 2 +- src/main/java/org/mybatis/spring/config/NamespaceHandler.java | 2 +- src/main/java/org/mybatis/spring/config/package-info.java | 2 +- src/main/java/org/mybatis/spring/package-info.java | 2 +- src/main/java/org/mybatis/spring/support/package-info.java | 2 +- .../spring/transaction/SpringManagedTransactionFactory.java | 2 +- src/main/java/org/mybatis/spring/transaction/package-info.java | 2 +- src/site/es/xdoc/batch.xml | 2 +- src/site/es/xdoc/boot.xml | 2 +- src/site/es/xdoc/factorybean.xml | 2 +- src/site/es/xdoc/index.xml | 2 +- src/site/es/xdoc/sample.xml | 2 +- src/site/es/xdoc/sqlsession.xml | 2 +- src/site/es/xdoc/transactions.xml | 2 +- src/site/es/xdoc/using-api.xml | 2 +- src/site/ja/xdoc/batch.xml | 2 +- src/site/ja/xdoc/boot.xml | 2 +- src/site/ja/xdoc/factorybean.xml | 2 +- src/site/ja/xdoc/index.xml | 2 +- src/site/ja/xdoc/sample.xml | 2 +- src/site/ja/xdoc/sqlsession.xml | 2 +- src/site/ja/xdoc/transactions.xml | 2 +- src/site/ja/xdoc/using-api.xml | 2 +- src/site/ko/xdoc/batch.xml | 2 +- src/site/ko/xdoc/boot.xml | 2 +- src/site/ko/xdoc/factorybean.xml | 2 +- src/site/ko/xdoc/index.xml | 2 +- src/site/ko/xdoc/sample.xml | 2 +- src/site/ko/xdoc/sqlsession.xml | 2 +- src/site/ko/xdoc/transactions.xml | 2 +- src/site/ko/xdoc/using-api.xml | 2 +- src/site/resources/css/site.css | 2 +- src/site/resources/es/css/site.css | 2 +- src/site/resources/ja/css/site.css | 2 +- src/site/resources/ko/css/site.css | 2 +- src/site/resources/zh/css/site.css | 2 +- src/site/site_es.xml | 2 +- src/site/site_ja.xml | 2 +- src/site/site_ko.xml | 2 +- src/site/site_zh.xml | 2 +- src/site/xdoc/batch.xml | 2 +- src/site/xdoc/boot.xml | 2 +- src/site/xdoc/factorybean.xml | 2 +- src/site/xdoc/index.xml | 2 +- src/site/xdoc/sample.xml | 2 +- src/site/xdoc/sqlsession.xml | 2 +- src/site/xdoc/transactions.xml | 2 +- src/site/xdoc/using-api.xml | 2 +- src/site/zh/xdoc/boot.xml | 2 +- src/site/zh/xdoc/factorybean.xml | 2 +- src/site/zh/xdoc/index.xml | 2 +- src/site/zh/xdoc/sample.xml | 2 +- src/site/zh/xdoc/sqlsession.xml | 2 +- src/site/zh/xdoc/transactions.xml | 2 +- src/site/zh/xdoc/using-api.xml | 2 +- src/test/java/org/mybatis/spring/PooledMockDataSource.java | 2 +- src/test/java/org/mybatis/spring/TestMapper.java | 2 +- src/test/java/org/mybatis/spring/TestMapper.xml | 2 +- .../org/mybatis/spring/annotation/mapper/ds1/Ds1Mapper.java | 2 +- .../org/mybatis/spring/annotation/mapper/ds2/Ds2Mapper.java | 2 +- src/test/java/org/mybatis/spring/batch/applicationContext.xml | 2 +- src/test/java/org/mybatis/spring/batch/dao/EmployeeMapper.xml | 2 +- src/test/java/org/mybatis/spring/batch/db/database-schema.sql | 2 +- .../java/org/mybatis/spring/batch/db/database-test-data.sql | 2 +- src/test/java/org/mybatis/spring/config/annotation.xml | 2 +- src/test/java/org/mybatis/spring/config/base-package.xml | 2 +- src/test/java/org/mybatis/spring/config/factory-ref.xml | 2 +- .../java/org/mybatis/spring/config/marker-and-annotation.xml | 2 +- src/test/java/org/mybatis/spring/config/marker-interface.xml | 2 +- src/test/java/org/mybatis/spring/config/name-generator.xml | 2 +- src/test/java/org/mybatis/spring/config/template-ref.xml | 2 +- src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java | 2 +- .../org/mybatis/spring/mapper/AnnotatedMapperZeroMethods.java | 2 +- src/test/java/org/mybatis/spring/mapper/MapperClass.java | 2 +- .../java/org/mybatis/spring/mapper/MapperImplementation.java | 2 +- src/test/java/org/mybatis/spring/mapper/MapperInterface.java | 2 +- src/test/java/org/mybatis/spring/mapper/MapperSubinterface.java | 2 +- .../org/mybatis/spring/mapper/child/MapperChildInterface.java | 2 +- src/test/java/org/mybatis/spring/mybatis-config.xml | 2 +- .../mybatis/spring/sample/batch/UserToPersonItemProcessor.java | 2 +- .../mybatis/spring/sample/config/applicationContext-batch.xml | 2 +- .../spring/sample/config/applicationContext-infrastructure.xml | 2 +- .../org/mybatis/spring/sample/config/applicationContext-job.xml | 2 +- .../mybatis/spring/sample/config/applicationContext-mapper.xml | 2 +- .../spring/sample/config/applicationContext-namespace.xml | 2 +- .../mybatis/spring/sample/config/applicationContext-scanner.xml | 2 +- .../spring/sample/config/applicationContext-sqlsession.xml | 2 +- src/test/java/org/mybatis/spring/sample/dao/UserDao.java | 2 +- src/test/java/org/mybatis/spring/sample/db/database-schema.sql | 2 +- .../java/org/mybatis/spring/sample/db/database-test-data.sql | 2 +- src/test/java/org/mybatis/spring/sample/domain/User.java | 2 +- src/test/java/org/mybatis/spring/sample/mapper/PersonMapper.xml | 2 +- src/test/java/org/mybatis/spring/sample/mapper/UserMapper.xml | 2 +- src/test/java/org/mybatis/spring/sample/service/BarService.java | 2 +- src/test/java/org/mybatis/spring/sample/service/FooService.java | 2 +- .../java/org/mybatis/spring/submitted/autowire/BarMapper.java | 2 +- .../java/org/mybatis/spring/submitted/autowire/BarMapper.xml | 2 +- .../java/org/mybatis/spring/submitted/autowire/FooMapper.java | 2 +- .../java/org/mybatis/spring/submitted/autowire/FooMapper.xml | 2 +- src/test/java/org/mybatis/spring/submitted/autowire/IBar.java | 2 +- src/test/java/org/mybatis/spring/submitted/autowire/IFoo.java | 2 +- .../mybatis/spring/submitted/autowire/database-schema-bar.sql | 2 +- .../mybatis/spring/submitted/autowire/database-schema-foo.sql | 2 +- src/test/java/org/mybatis/spring/submitted/autowire/spring.xml | 2 +- .../org/mybatis/spring/submitted/webapp_placeholder/Mapper.java | 2 +- .../mybatis/spring/submitted/webapp_placeholder/conf.properties | 2 +- .../org/mybatis/spring/submitted/webapp_placeholder/spring.xml | 2 +- .../java/org/mybatis/spring/submitted/xa/applicationContext.xml | 2 +- .../java/org/mybatis/spring/submitted/xa/database-schema.sql | 2 +- src/test/java/org/mybatis/spring/type/DummyTypeAlias.java | 2 +- src/test/java/org/mybatis/spring/type/DummyTypeAlias2.java | 2 +- src/test/java/org/mybatis/spring/type/DummyTypeHandler.java | 2 +- src/test/java/org/mybatis/spring/type/DummyTypeHandler2.java | 2 +- src/test/java/org/mybatis/spring/type/SuperType.java | 2 +- src/test/resources/log4j2-test.xml | 2 +- travis/after_success.sh | 2 +- travis/settings.xml | 2 +- 121 files changed, 121 insertions(+), 121 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 5152e1e5b9..b06d48f20b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -1,7 +1,7 @@ + + + + + + diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index a85cef06e0..393cd4c1f5 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -16,6 +16,7 @@ package org.mybatis.spring.mapper; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -89,6 +90,10 @@ void assertNoMapperClass() { void testInterfaceScan() { startContext(); + SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + + assertEquals(5, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + // all interfaces with methods should be loaded applicationContext.getBean("mapperInterface"); applicationContext.getBean("mapperSubinterface"); @@ -166,7 +171,13 @@ void testScanWithExplicitSqlSessionFactory() { applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add("sqlSessionFactoryBeanName", "sqlSessionFactory2"); - testInterfaceScan(); + startContext(); + + // all interfaces with methods should be loaded + applicationContext.getBean("mapperInterface"); + applicationContext.getBean("mapperSubinterface"); + applicationContext.getBean("mapperChildInterface"); + applicationContext.getBean("annotatedMapper"); } @Test @@ -181,7 +192,13 @@ void testScanWithExplicitSqlSessionTemplate() { applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add("sqlSessionTemplateBeanName", "sqlSessionTemplate"); - testInterfaceScan(); + startContext(); + + // all interfaces with methods should be loaded + applicationContext.getBean("mapperInterface"); + applicationContext.getBean("mapperSubinterface"); + applicationContext.getBean("mapperChildInterface"); + applicationContext.getBean("annotatedMapper"); } @Test @@ -201,7 +218,13 @@ void testScanWithExplicitSqlSessionFactoryViaPlaceholder() { applicationContext.registerBeanDefinition("propertiesPlaceholder", propertyDefinition); - testInterfaceScan(); + startContext(); + + // all interfaces with methods should be loaded + applicationContext.getBean("mapperInterface"); + applicationContext.getBean("mapperSubinterface"); + applicationContext.getBean("mapperChildInterface"); + applicationContext.getBean("annotatedMapper"); } @Test @@ -224,6 +247,8 @@ void testScanWithPropertyPlaceholders() { definition.getPropertyValues().removePropertyValue("basePackage"); definition.getPropertyValues().add("basePackage", "${basePackageProperty}"); definition.getPropertyValues().add("processPropertyPlaceHolders", true); + // for lazy initialization + definition.getPropertyValues().add("lazyInitialization", "${mybatis.lazy-initialization:false}"); // also use a property placeholder for an SqlSessionFactory property // to make sure the configLocation was setup correctly and MapperScanner did not change @@ -235,6 +260,7 @@ void testScanWithPropertyPlaceholders() { Properties props = new java.util.Properties(); props.put("basePackageProperty", "org.mybatis.spring.mapper"); props.put("configLocationProperty", "classpath:org/mybatis/spring/mybatis-config.xml"); + props.put("mybatis.lazy-initialization", "true"); GenericBeanDefinition propertyDefinition = new GenericBeanDefinition(); propertyDefinition.setBeanClass(PropertyPlaceholderConfigurer.class); @@ -242,7 +268,19 @@ void testScanWithPropertyPlaceholders() { applicationContext.registerBeanDefinition("propertiesPlaceholder", propertyDefinition); - testInterfaceScan(); + startContext(); + + SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + System.out.println(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()); + assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + + // all interfaces with methods should be loaded + applicationContext.getBean("mapperInterface"); + applicationContext.getBean("mapperSubinterface"); + applicationContext.getBean("mapperChildInterface"); + applicationContext.getBean("annotatedMapper"); + + assertEquals(5, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); // make sure the configLocation was setup correctly // mybatis-config.xml changes the executor from the default SIMPLE type diff --git a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java index 9ba579f7c0..0562d3444d 100644 --- a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java +++ b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java @@ -17,9 +17,12 @@ import static org.assertj.core.api.Assertions.assertThat; +import org.apache.ibatis.session.SqlSessionFactory; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.web.WebAppConfiguration; @@ -30,10 +33,16 @@ class WebappPlaceholderTest { @Autowired - private Mapper mapper; + private SqlSessionFactory sqlSessionFactory; + + @Autowired + private ApplicationContext applicationContext; @Test void testName() { + Assertions.assertEquals(0, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + Mapper mapper = applicationContext.getBean(Mapper.class); assertThat(mapper).isNotNull(); + Assertions.assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); } } diff --git a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/conf.properties b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/conf.properties index ec1b941cb0..16f70c3dad 100644 --- a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/conf.properties +++ b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/conf.properties @@ -15,3 +15,5 @@ # basePkg=org.mybatis.spring.submitted.webapp_placeholder + +mybatis.lazy-initialization=true diff --git a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/spring.xml b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/spring.xml index 8942482467..379bb64429 100644 --- a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/spring.xml +++ b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/spring.xml @@ -36,6 +36,7 @@ + From be560d93781df3b84eda530aa3743ffbf947b310 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 1 May 2019 03:52:51 +0900 Subject: [PATCH 121/933] Update document See gh-376 --- src/site/es/xdoc/mappers.xml | 23 +++++++++++++++++++++-- src/site/ja/xdoc/mappers.xml | 19 ++++++++++++++++++- src/site/ko/xdoc/mappers.xml | 21 ++++++++++++++++++++- src/site/xdoc/mappers.xml | 21 ++++++++++++++++++++- src/site/zh/xdoc/mappers.xml | 19 +++++++++++++++++++ 5 files changed, 98 insertions(+), 5 deletions(-) diff --git a/src/site/es/xdoc/mappers.xml b/src/site/es/xdoc/mappers.xml index 709b18ca85..fe967fbf0b 100644 --- a/src/site/es/xdoc/mappers.xml +++ b/src/site/es/xdoc/mappers.xml @@ -121,7 +121,26 @@ public MapperFactoryBean userMapper() throws Exception {

    Tango <mybatis:scan/> como @MapperScan son características añadidas en MyBatis-Spring 1.2.0. - @MapperScan requiere Spring 3.1+.

    + @MapperScan requiere Spring 3.1+.

    + +

    + Since 2.0.2, mapper scanning feature support a option (lazy-initialization) + that control lazy initialization enabled/disabled of mapper bean. + The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. + The default of this option is false (= not use lazy initialization). + If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. +

    +

    + IMPORTANT If use the lazy initialization feature, + the developer need to understand following limitations. If any of following conditions are matches, + the lazy initialization feature cannot use on your application. +

    +
      +
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • +
    • When includes to the fragment of other mapper using ]]>
    • +
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • +
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • +

    <mybatis:scan/>

    @@ -228,4 +247,4 @@ public class AppConfig { - \ No newline at end of file + diff --git a/src/site/ja/xdoc/mappers.xml b/src/site/ja/xdoc/mappers.xml index 1f8fc2508c..ff7f13a4dd 100644 --- a/src/site/ja/xdoc/mappers.xml +++ b/src/site/ja/xdoc/mappers.xml @@ -110,7 +110,24 @@ public MapperFactoryBean userMapper() throws Exception {
  • Spring の XML 設定ファイルに MapperScannerConfigurer のエントリーを追加する。
  • -

    <mybatis:scan/> または @MapperScan を使う場合は MyBatis-Spring 1.2.0 以降が必要です。また @MapperScan を使う場合は Spring 3.1 以降が必要となります。

    +

    <mybatis:scan/> または @MapperScan を使う場合は MyBatis-Spring 1.2.0 以降が必要です。また @MapperScan を使う場合は Spring 3.1 以降が必要となります。

    + +

    + 2.0.2以降では、Mapperの自動検出機能は、Mapper Beanの遅延初期化の有効/無効を制御するオプション(lazy-initialization)をサポートします。 + このオプションを追加する動機は、Spring Boot 2.2でサポートされた遅延初期化を制御する機能をサポートすることです。 + このオプションのデフォルトはfalseです(遅延初期化を使用しません)。 + 開発者がMapper Beanを遅延初期化したい場合は、明示的にこのオプションをtrueに設定する必要があります。 +

    +

    + 重要 遅延初期化機能を使用する場合は、開発者は以下の制限を理解しておく必要があります。 + 以下の条件のいずれかに一致する場合、あなたのアプリケーションで遅延初期化機能を使用することはできません。 +

    +
      +
    • ]]>(@One) and ]]>(@Many)を利用して、他のMapperのステートメントを参照している場合
    • +
    • ]]>を利用して、他のMapperのフラグメントをインクルードしている場合
    • +
    • ]]>(@CacheNamespaceRef)を利用して、他のMapperのキャッシュを参照している場合
    • +
    • ]]>(@ResultMap)を利用して、他のMapperの結果マッピングを参照している場合
    • +

    <mybatis:scan/>

    diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml index 6c2ab86f2a..b08b0721c0 100644 --- a/src/site/ko/xdoc/mappers.xml +++ b/src/site/ko/xdoc/mappers.xml @@ -97,7 +97,26 @@ public MapperFactoryBean userMapper() throws Exception {

    <mybatis:scan/>@MapperScan 모두 마이바티스 스프링 연동모듈 1.2.0에서 추가된 기능이다. - @MapperScan 은 스프링 버전이 3.1이상이어야 한다.

    + @MapperScan 은 스프링 버전이 3.1이상이어야 한다.

    + +

    + Since 2.0.2, mapper scanning feature support a option (lazy-initialization) + that control lazy initialization enabled/disabled of mapper bean. + The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. + The default of this option is false (= not use lazy initialization). + If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. +

    +

    + IMPORTANT If use the lazy initialization feature, + the developer need to understand following limitations. If any of following conditions are matches, + the lazy initialization feature cannot use on your application. +

    +
      +
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • +
    • When includes to the fragment of other mapper using ]]>
    • +
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • +
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • +

    <mybatis:scan/>

    diff --git a/src/site/xdoc/mappers.xml b/src/site/xdoc/mappers.xml index edba0ee76d..59095723ca 100644 --- a/src/site/xdoc/mappers.xml +++ b/src/site/xdoc/mappers.xml @@ -124,7 +124,26 @@ public MapperFactoryBean userMapper() throws Exception {

    Both <mybatis:scan/> and @MapperScan are features introduced in MyBatis-Spring 1.2.0. - @MapperScan requires Spring 3.1+.

    + @MapperScan requires Spring 3.1+.

    + +

    + Since 2.0.2, mapper scanning feature support a option (lazy-initialization) + that control lazy initialization enabled/disabled of mapper bean. + The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. + The default of this option is false (= not use lazy initialization). + If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. +

    +

    + IMPORTANT If use the lazy initialization feature, + the developer need to understand following limitations. If any of following conditions are matches, + the lazy initialization feature cannot use on your application. +

    +
      +
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • +
    • When includes to the fragment of other mapper using ]]>
    • +
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • +
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • +

    <mybatis:scan/>

    diff --git a/src/site/zh/xdoc/mappers.xml b/src/site/zh/xdoc/mappers.xml index 94937d442d..c10140ce31 100644 --- a/src/site/zh/xdoc/mappers.xml +++ b/src/site/zh/xdoc/mappers.xml @@ -107,6 +107,25 @@ public MapperFactoryBean userMapper() throws Exception {

    <mybatis:scan/>@MapperScan 都在 MyBatis-Spring 1.2.0 中被引入。@MapperScan 需要你使用 Spring 3.1+。

    +

    + Since 2.0.2, mapper scanning feature support a option (lazy-initialization) + that control lazy initialization enabled/disabled of mapper bean. + The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. + The default of this option is false (= not use lazy initialization). + If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. +

    +

    + IMPORTANT If use the lazy initialization feature, + the developer need to understand following limitations. If any of following conditions are matches, + the lazy initialization feature cannot use on your application. +

    +
      +
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • +
    • When includes to the fragment of other mapper using ]]>
    • +
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • +
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • +
    +

    <mybatis:scan/>

    From 133756b5304c72dcf74767a3fbab26fc9d1aa6d4 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 1 May 2019 15:41:33 +0900 Subject: [PATCH 122/933] Update document See gh-376 --- src/site/es/xdoc/mappers.xml | 11 ++++++++++- src/site/ja/xdoc/mappers.xml | 12 +++++++++++- src/site/ko/xdoc/mappers.xml | 11 ++++++++++- src/site/xdoc/mappers.xml | 13 +++++++++++-- src/site/zh/xdoc/mappers.xml | 11 ++++++++++- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/site/es/xdoc/mappers.xml b/src/site/es/xdoc/mappers.xml index fe967fbf0b..0baebebce8 100644 --- a/src/site/es/xdoc/mappers.xml +++ b/src/site/es/xdoc/mappers.xml @@ -133,7 +133,7 @@ public MapperFactoryBean userMapper() throws Exception {

    IMPORTANT If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, - the lazy initialization feature cannot use on your application. + usually the lazy initialization feature cannot use on your application.

    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • @@ -142,6 +142,15 @@ public MapperFactoryBean userMapper() throws Exception {
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    +

    + NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: +

    + + +

    <mybatis:scan/>

    diff --git a/src/site/ja/xdoc/mappers.xml b/src/site/ja/xdoc/mappers.xml index ff7f13a4dd..1890b478df 100644 --- a/src/site/ja/xdoc/mappers.xml +++ b/src/site/ja/xdoc/mappers.xml @@ -120,7 +120,7 @@ public MapperFactoryBean userMapper() throws Exception {

    重要 遅延初期化機能を使用する場合は、開発者は以下の制限を理解しておく必要があります。 - 以下の条件のいずれかに一致する場合、あなたのアプリケーションで遅延初期化機能を使用することはできません。 + 以下の条件のいずれかに一致する場合、通常あなたのアプリケーションで遅延初期化機能を使用することはできません。

    • ]]>(@One) and ]]>(@Many)を利用して、他のMapperのステートメントを参照している場合
    • @@ -129,6 +129,16 @@ public MapperFactoryBean userMapper() throws Exception {
    • ]]>(@ResultMap)を利用して、他のMapperの結果マッピングを参照している場合
    +

    + NOTE しかしながら、以下のように@DependsOn(Springの機能)を利用して、 + 依存するMapper Beanも同時に初期化すると遅延初期化機能を利用することができるようになります。 +

    + + +

    <mybatis:scan/>

    diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml index b08b0721c0..3a2acb6b30 100644 --- a/src/site/ko/xdoc/mappers.xml +++ b/src/site/ko/xdoc/mappers.xml @@ -109,7 +109,7 @@ public MapperFactoryBean userMapper() throws Exception {

    IMPORTANT If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, - the lazy initialization feature cannot use on your application. + usually the lazy initialization feature cannot use on your application.

    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • @@ -118,6 +118,15 @@ public MapperFactoryBean userMapper() throws Exception {
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    +

    + NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: +

    + + +

    <mybatis:scan/>

    <mybatis:scan/> XML엘리먼트는 스프링에서 제공하는 <context:component-scan/> 엘리먼트와 매우 유사한 방법으로 매퍼를 검색할 것이다.

    diff --git a/src/site/xdoc/mappers.xml b/src/site/xdoc/mappers.xml index 59095723ca..304b6fecab 100644 --- a/src/site/xdoc/mappers.xml +++ b/src/site/xdoc/mappers.xml @@ -136,7 +136,7 @@ public MapperFactoryBean userMapper() throws Exception {

    IMPORTANT If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, - the lazy initialization feature cannot use on your application. + usually the lazy initialization feature cannot use on your application.

    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • @@ -145,6 +145,15 @@ public MapperFactoryBean userMapper() throws Exception {
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    +

    + NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: +

    + + +

    <mybatis:scan/>

    @@ -161,7 +170,7 @@ public MapperFactoryBean userMapper() throws Exception { xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd"> - + diff --git a/src/site/zh/xdoc/mappers.xml b/src/site/zh/xdoc/mappers.xml index c10140ce31..34320c51b3 100644 --- a/src/site/zh/xdoc/mappers.xml +++ b/src/site/zh/xdoc/mappers.xml @@ -117,7 +117,7 @@ public MapperFactoryBean userMapper() throws Exception {

    IMPORTANT If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, - the lazy initialization feature cannot use on your application. + usually the lazy initialization feature cannot use on your application.

    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • @@ -126,6 +126,15 @@ public MapperFactoryBean userMapper() throws Exception {
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    +

    + NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: +

    + + +

    <mybatis:scan/>

    From b4042aded41cab7d9ec16e1225365a3db462c956 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 1 May 2019 17:57:58 +0900 Subject: [PATCH 123/933] Add license header --- .editorconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.editorconfig b/.editorconfig index a7dcff48e0..7cd8a144e3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,19 @@ +# +# Copyright 2010-2019 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + root = true [*.{java, xml, sql}] From 54f6166ef3f50f04b910141fcd9a00333a1b95fe Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 2 May 2019 17:26:37 +0900 Subject: [PATCH 124/933] Support to configure LanguageDriver via SqlSessionFactoryBean Fixes gh-378 --- .../mybatis/spring/SqlSessionFactoryBean.java | 36 +++++++++++++++ .../spring/SqlSessionFactoryBeanTest.java | 46 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index c42679fae9..1674a2de99 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -36,6 +36,7 @@ import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.reflection.factory.ObjectFactory; import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory; +import org.apache.ibatis.scripting.LanguageDriver; import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; @@ -125,6 +126,10 @@ public class SqlSessionFactoryBean private Class typeAliasesSuperType; + private LanguageDriver[] scriptingLanguageDrivers; + + private Class defaultScriptingLanguageDriver; + // issue #19. No default provider. private DatabaseIdProvider databaseIdProvider; @@ -435,6 +440,28 @@ public void setEnvironment(String environment) { this.environment = environment; } + /** + * Set scripting language drivers. + * + * @param scriptingLanguageDrivers + * scripting language drivers + * @since 2.0.2 + */ + public void setScriptingLanguageDrivers(LanguageDriver... scriptingLanguageDrivers) { + this.scriptingLanguageDrivers = scriptingLanguageDrivers; + } + + /** + * Set a default scripting language driver class. + * + * @param defaultScriptingLanguageDriver + * A default scripting language driver class + * @since 2.0.2 + */ + public void setDefaultScriptingLanguageDriver(Class defaultScriptingLanguageDriver) { + this.defaultScriptingLanguageDriver = defaultScriptingLanguageDriver; + } + /** * {@inheritDoc} */ @@ -519,6 +546,15 @@ protected SqlSessionFactory buildSqlSessionFactory() throws Exception { }); } + if (!isEmpty(this.scriptingLanguageDrivers)) { + Stream.of(this.scriptingLanguageDrivers).forEach(languageDriver -> { + targetConfiguration.getLanguageRegistry().register(languageDriver); + LOGGER.debug(() -> "Registered scripting language driver: '" + languageDriver + "'"); + }); + } + Optional.ofNullable(this.defaultScriptingLanguageDriver) + .ifPresent(targetConfiguration::setDefaultScriptingLanguage); + if (this.databaseIdProvider != null) {// fix #64 set databaseId before parse mapper xmls try { targetConfiguration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource)); diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index abcb81d70e..27a156e346 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -29,6 +29,10 @@ import org.apache.ibatis.reflection.factory.ObjectFactory; import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory; +import org.apache.ibatis.scripting.LanguageDriver; +import org.apache.ibatis.scripting.LanguageDriverRegistry; +import org.apache.ibatis.scripting.defaults.RawLanguageDriver; +import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver; import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSessionFactory; @@ -440,6 +444,42 @@ void testAddCache() { assertThat(this.factoryBean.getCache().getId()).isEqualTo("test-cache"); } + @Test + void testScriptingLanguageDriverEmpty() throws Exception { + setupFactoryBean(); + this.factoryBean.setScriptingLanguageDrivers(); + LanguageDriverRegistry registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); + assertThat(registry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); + assertThat(registry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); + } + + @Test + void testScriptingLanguageDriver() throws Exception { + setupFactoryBean(); + this.factoryBean.setScriptingLanguageDrivers(new MyLanguageDriver1(), new MyLanguageDriver2()); + LanguageDriverRegistry registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); + assertThat(registry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); + assertThat(registry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); + assertThat(registry.getDriver(MyLanguageDriver1.class)).isNotNull(); + assertThat(registry.getDriver(MyLanguageDriver2.class)).isNotNull(); + assertThat(registry.getDriver(XMLLanguageDriver.class)).isNotNull(); + assertThat(registry.getDriver(RawLanguageDriver.class)).isNotNull(); + } + + @Test + void testScriptingLanguageDriverWithDefault() throws Exception { + setupFactoryBean(); + this.factoryBean.setScriptingLanguageDrivers(new MyLanguageDriver1(), new MyLanguageDriver2()); + this.factoryBean.setDefaultScriptingLanguageDriver(MyLanguageDriver1.class); + LanguageDriverRegistry registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); + assertThat(registry.getDefaultDriver()).isInstanceOf(MyLanguageDriver1.class); + assertThat(registry.getDefaultDriverClass()).isEqualTo(MyLanguageDriver1.class); + assertThat(registry.getDriver(MyLanguageDriver1.class)).isNotNull(); + assertThat(registry.getDriver(MyLanguageDriver2.class)).isNotNull(); + assertThat(registry.getDriver(XMLLanguageDriver.class)).isNotNull(); + assertThat(registry.getDriver(RawLanguageDriver.class)).isNotNull(); + } + private void assertDefaultConfig(SqlSessionFactory factory) { assertConfig(factory, SqlSessionFactoryBean.class.getSimpleName(), org.mybatis.spring.transaction.SpringManagedTransactionFactory.class); @@ -464,4 +504,10 @@ private void assertConfig(SqlSessionFactory factory, String environment, assertThat(factory.getConfiguration().getSqlFragments().size()).isEqualTo(0); } + private static class MyLanguageDriver1 extends RawLanguageDriver { + } + + private static class MyLanguageDriver2 extends RawLanguageDriver { + } + } From 1fafc59997fa806168578ffc7c0b117403724520 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 3 May 2019 00:37:18 +0900 Subject: [PATCH 125/933] Change to Variable-length argument from array argument on SqlSessionFactoryBean --- .../java/org/mybatis/spring/SqlSessionFactoryBean.java | 8 ++++---- .../org/mybatis/spring/AbstractMyBatisSpringTest.java | 4 ++-- .../org/mybatis/spring/SqlSessionFactoryBeanTest.java | 8 ++++---- .../org/mybatis/spring/mapper/MapperFactoryBeanTest.java | 2 +- .../org/mybatis/spring/sample/config/SampleConfig.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 1674a2de99..0689f317cb 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -231,7 +231,7 @@ public void setCache(Cache cache) { * list of plugins * */ - public void setPlugins(Interceptor[] plugins) { + public void setPlugins(Interceptor... plugins) { this.plugins = plugins; } @@ -289,7 +289,7 @@ public void setTypeHandlersPackage(String typeHandlersPackage) { * @param typeHandlers * Type handler list */ - public void setTypeHandlers(TypeHandler[] typeHandlers) { + public void setTypeHandlers(TypeHandler... typeHandlers) { this.typeHandlers = typeHandlers; } @@ -301,7 +301,7 @@ public void setTypeHandlers(TypeHandler[] typeHandlers) { * @param typeAliases * Type aliases list */ - public void setTypeAliases(Class[] typeAliases) { + public void setTypeAliases(Class... typeAliases) { this.typeAliases = typeAliases; } @@ -351,7 +351,7 @@ public void setConfiguration(Configuration configuration) { * @param mapperLocations * location of MyBatis mapper files */ - public void setMapperLocations(Resource[] mapperLocations) { + public void setMapperLocations(Resource... mapperLocations) { this.mapperLocations = mapperLocations; } diff --git a/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java b/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java index 784686f6fe..7c01b9d1c3 100644 --- a/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java @@ -53,10 +53,10 @@ public abstract class AbstractMyBatisSpringTest { public static void setupBase() throws Exception { // create an SqlSessionFactory that will use SpringManagedTransactions SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); - factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") }); + factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml")); // note running without SqlSessionFactoryBean.configLocation set => default configuration factoryBean.setDataSource(dataSource); - factoryBean.setPlugins(new Interceptor[] { executorInterceptor }); + factoryBean.setPlugins(executorInterceptor); exceptionTranslator = new MyBatisExceptionTranslator(dataSource, true); diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 27a156e346..396c8011d1 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -301,7 +301,7 @@ void testSpecifyConfigurationAndConfigLocation() throws Exception { void testFragmentsAreReadWithMapperLocations() throws Exception { setupFactoryBean(); - factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") }); + factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml")); SqlSessionFactory factory = factoryBean.getObject(); @@ -321,7 +321,7 @@ void testNullMapperLocations() throws Exception { @Test void testEmptyMapperLocations() throws Exception { setupFactoryBean(); - factoryBean.setMapperLocations(new org.springframework.core.io.Resource[0]); + factoryBean.setMapperLocations(); assertDefaultConfig(factoryBean.getObject()); } @@ -337,7 +337,7 @@ void testMapperLocationsWithNullEntry() throws Exception { @Test void testAddATypeHandler() throws Exception { setupFactoryBean(); - factoryBean.setTypeHandlers(new TypeHandler[] { new DummyTypeHandler() }); + factoryBean.setTypeHandlers(new DummyTypeHandler()); TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); @@ -347,7 +347,7 @@ void testAddATypeHandler() throws Exception { void testAddATypeAlias() throws Exception { setupFactoryBean(); - factoryBean.setTypeAliases(new Class[] { DummyTypeAlias.class }); + factoryBean.setTypeAliases(DummyTypeAlias.class); TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias"); } diff --git a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java index 953c7ef4dd..bf08452d2c 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java @@ -64,7 +64,7 @@ void testAddToConfigTrue() throws Exception { factoryBean.setDatabaseIdProvider(null); // mapperLocations properties defaults to null factoryBean.setDataSource(dataSource); - factoryBean.setPlugins(new Interceptor[] { executorInterceptor }); + factoryBean.setPlugins(executorInterceptor); SqlSessionFactory sqlSessionFactory = factoryBean.getObject(); diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java index 7682170aa7..b09bbe07c0 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java @@ -50,7 +50,7 @@ public PlatformTransactionManager transactionalManager() { public SqlSessionFactory sqlSessionFactory() throws Exception { SqlSessionFactoryBean ss = new SqlSessionFactoryBean(); ss.setDataSource(dataSource()); - ss.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml") }); + ss.setMapperLocations(new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml")); return ss.getObject(); } From 1e1bf2a73b375118015e9926f99160d66332c21d Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 6 May 2019 00:27:56 +0900 Subject: [PATCH 126/933] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a278b46aa1..95f4235b90 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ MyBatis Spring Adapter [![Build Status](https://travis-ci.org/mybatis/spring.svg?branch=master)](https://travis-ci.org/mybatis/spring) [![Coverage Status](https://coveralls.io/repos/mybatis/spring/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/spring?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring) +[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring) [![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) ![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png) From 9cfac7459bd132bf374fec1a535a39c755cd6fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=B3=E9=98=B3?= <260893248@qq.com> Date: Mon, 17 Jun 2019 09:34:30 +0800 Subject: [PATCH 127/933] an -> a an -> a --- src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 0689f317cb..3db0b2ce56 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -68,7 +68,7 @@ import static org.springframework.util.StringUtils.tokenizeToStringArray; /** - * {@code FactoryBean} that creates an MyBatis {@code SqlSessionFactory}. This is the usual way to set up a shared + * {@code FactoryBean} that creates a MyBatis {@code SqlSessionFactory}. This is the usual way to set up a shared * MyBatis {@code SqlSessionFactory} in a Spring application context; the SqlSessionFactory can then be passed to * MyBatis-based DAOs via dependency injection. * From ae65b320c6081ae56b5a0bdad321bbbfbd2cec56 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 29 Jun 2019 14:21:01 +0900 Subject: [PATCH 128/933] Replace to openjdk11 on Travis CI Fixes gh-384 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 48cf2b99fa..cc2019d621 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java jdk: - - oraclejdk11 + - openjdk11 - oraclejdk8 after_success: From 046f250651327a095c7e8d5254568d5cc6bdedd7 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 2 Jul 2019 00:27:06 +0900 Subject: [PATCH 129/933] Support openjdk12 on Travis CI Fixes gh-385 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cc2019d621..a427b76232 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: java jdk: + - openjdk12 - openjdk11 - oraclejdk8 From 33b79ca6609bf76d70d998a39fc5ef7e5678c35a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 3 Jul 2019 13:33:52 +0900 Subject: [PATCH 130/933] Upgrade to spring 5.1.8 Fixes gh-387 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5502714cef..3a20787d4e 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.1 - 5.1.6.RELEASE + 5.1.8.RELEASE 4.1.2.RELEASE org.mybatis.spring From e07508ef47bba8699d16db3eb17f59b5129650e7 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 6 Jul 2019 23:13:20 +0900 Subject: [PATCH 131/933] Upgrade to JUnit 5.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a20787d4e..16b01ed7e8 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.1.2.RELEASE org.mybatis.spring - 5.4.2 + 5.5.0 From c428e8cac3c61683bf327792148b906895d95297 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 15 Jul 2019 11:36:48 +0900 Subject: [PATCH 132/933] Upgrade to mybatis 3.5.2 Fixes gh-388 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16b01ed7e8..65130a356a 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.1 + 3.5.2 5.1.8.RELEASE 4.1.2.RELEASE org.mybatis.spring From 89cc8b8697278c2bb493b81c728e3975990df2f6 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Mon, 15 Jul 2019 12:10:54 +0900 Subject: [PATCH 133/933] [maven-release-plugin] prepare release mybatis-spring-2.0.2 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 65130a356a..c816a08c8d 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.2-SNAPSHOT + 2.0.2 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-2.0.2 GitHub Issue Management From f7db7f36059a9761a9453aad20402b2d0a55ce54 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Mon, 15 Jul 2019 12:11:01 +0900 Subject: [PATCH 134/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c816a08c8d..1c11db0e5c 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.2 + 2.0.3-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-2.0.2 + HEAD GitHub Issue Management From 6fd6f1081fe3d2d9e96246a91c829ad24c9aadea Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 15 Jul 2019 19:10:00 -0400 Subject: [PATCH 135/933] [mvn] Update maven wrapper to 0.5.5 --- .mvn/wrapper/MavenWrapperDownloader.java | 4 ++-- .mvn/wrapper/maven-wrapper.properties | 3 +-- mvnw | 9 +++++-- mvnw.cmd | 30 ++++++++++++++++-------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index b20a55a7a9..c32394f140 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -20,12 +20,12 @@ public class MavenWrapperDownloader { - private static final String WRAPPER_VERSION = "0.5.3"; + private static final String WRAPPER_VERSION = "0.5.5"; /** * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + " .jar"; + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; /** * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 33ccdc4c9a..fa87ad7ddf 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,3 +1,2 @@ distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar - +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar diff --git a/mvnw b/mvnw index 34d9dae8d0..d2f0ea3808 100755 --- a/mvnw +++ b/mvnw @@ -212,9 +212,9 @@ else echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" fi while IFS="=" read key value; do case "$key" in (wrapperUrl) jarUrl="$value"; break ;; @@ -296,6 +296,11 @@ if $cygwin; then MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ diff --git a/mvnw.cmd b/mvnw.cmd index 77b451d837..b26ab24f03 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -37,7 +37,7 @@ @echo off @REM set title of command window title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -120,7 +120,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B @@ -129,14 +129,18 @@ FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven- @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central @REM This allows using the maven wrapper in projects that prohibit checking in binary data. if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) ) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" - ) - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + powershell -Command "&{"^ "$webclient = new-object System.Net.WebClient;"^ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ @@ -144,10 +148,16 @@ if exist %WRAPPER_JAR% ( "}"^ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ "}" - echo Finished downloading %WRAPPER_JAR% + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) ) @REM End of extension +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end From 03c62f3e991bcbaa25a199308fc311499737c12d Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 19 Jul 2019 02:53:29 +0900 Subject: [PATCH 136/933] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95f4235b90..c9998ae095 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ MyBatis Spring Adapter [![Build Status](https://travis-ci.org/mybatis/spring.svg?branch=master)](https://travis-ci.org/mybatis/spring) [![Coverage Status](https://coveralls.io/repos/mybatis/spring/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/spring?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring) -[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring) +[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring/) [![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) ![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png) From dd5a9ffba2e35f43e1f53f888b9ebfafe600877a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 21 Jul 2019 04:58:08 +0900 Subject: [PATCH 137/933] Allow to scan TypeHandler that pass Class to constructor Fixes gh-394 --- .../mybatis/spring/SqlSessionFactoryBean.java | 13 +++-- .../jdk/type/AtomicNumberTypeHandler.java | 54 +++++++++++++++++++ .../spring/SqlSessionFactoryBeanTest.java | 7 ++- 3 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 3db0b2ce56..fb7463e168 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -186,7 +186,7 @@ public void setDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) { /** * Gets the VFS. - * + * * @return a specified VFS */ public Class getVfs() { @@ -195,7 +195,7 @@ public Class getVfs() { /** * Sets the VFS. - * + * * @param vfs * a VFS */ @@ -205,7 +205,7 @@ public void setVfs(Class vfs) { /** * Gets the Cache. - * + * * @return a specified Cache */ public Cache getCache() { @@ -214,7 +214,7 @@ public Cache getCache() { /** * Sets the Cache. - * + * * @param cache * a Cache */ @@ -270,7 +270,7 @@ public void setTypeAliasesSuperType(Class typeAliasesSuperType) { * *

    * Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.typehandler}. - * + * * @since 1.0.1 * * @param typeHandlersPackage @@ -331,7 +331,7 @@ public void setConfigLocation(Resource configLocation) { /** * Set a customized MyBatis configuration. - * + * * @param configuration * MyBatis configuration * @since 1.3.0 @@ -535,7 +535,6 @@ protected SqlSessionFactory buildSqlSessionFactory() throws Exception { if (hasLength(this.typeHandlersPackage)) { scanClasses(this.typeHandlersPackage, TypeHandler.class).stream().filter(clazz -> !clazz.isAnonymousClass()) .filter(clazz -> !clazz.isInterface()).filter(clazz -> !Modifier.isAbstract(clazz.getModifiers())) - .filter(clazz -> ClassUtils.getConstructorIfAvailable(clazz) != null) .forEach(targetConfiguration.getTypeHandlerRegistry()::register); } diff --git a/src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java b/src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java new file mode 100644 index 0000000000..b1935e3c01 --- /dev/null +++ b/src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java @@ -0,0 +1,54 @@ +/** + * Copyright 2010-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.core.jdk.type; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedTypes; +import org.apache.ibatis.type.TypeHandler; + +@MappedTypes({ AtomicInteger.class, AtomicLong.class }) +public class AtomicNumberTypeHandler implements TypeHandler { + + public AtomicNumberTypeHandler(Class type) { + } + + @Override + public void setParameter(PreparedStatement ps, int i, Number parameter, JdbcType jdbcType) throws SQLException { + } + + @Override + public Number getResult(ResultSet rs, String columnName) throws SQLException { + return null; + } + + @Override + public Number getResult(CallableStatement cs, int columnIndex) throws SQLException { + return null; + } + + @Override + public Number getResult(ResultSet rs, int columnIndex) throws SQLException { + return null; + } + +} diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 396c8011d1..d373ff51db 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -22,6 +22,8 @@ import java.math.BigInteger; import java.util.Properties; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import org.apache.ibatis.cache.impl.PerpetualCache; import org.apache.ibatis.io.JBoss6VFS; @@ -43,6 +45,7 @@ import org.apache.ibatis.type.TypeHandler; import org.apache.ibatis.type.TypeHandlerRegistry; import org.junit.jupiter.api.Test; +import org.mybatis.core.jdk.type.AtomicNumberTypeHandler; import org.mybatis.spring.transaction.SpringManagedTransactionFactory; import org.mybatis.spring.type.DummyTypeAlias; import org.mybatis.spring.type.DummyTypeHandler; @@ -400,12 +403,14 @@ void testSearchATypeAliasPackageWithSamePackage() throws Exception { @Test void testSearchATypeHandlerPackage() throws Exception { setupFactoryBean(); - factoryBean.setTypeHandlersPackage("org.**.type"); + factoryBean.setTypeHandlersPackage("org.mybatis.**.type"); TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); assertThat(typeHandlerRegistry.hasTypeHandler(BigDecimal.class)).isTrue(); assertThat(typeHandlerRegistry.getTypeHandler(UUID.class)).isInstanceOf(TypeHandlerFactory.InnerTypeHandler.class); + assertThat(typeHandlerRegistry.getTypeHandler(AtomicInteger.class)).isInstanceOf(AtomicNumberTypeHandler.class); + assertThat(typeHandlerRegistry.getTypeHandler(AtomicLong.class)).isInstanceOf(AtomicNumberTypeHandler.class); } @Test From 2e7b4f8466c773b63bfb06379b9caafa0575a0bd Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 10 Aug 2019 02:32:45 +0900 Subject: [PATCH 138/933] Change sonar.host.url --- travis/after_success.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/after_success.sh b/travis/after_success.sh index ee45ba6b5b..d09d4f2f0e 100644 --- a/travis/after_success.sh +++ b/travis/after_success.sh @@ -50,7 +50,7 @@ if [ $TRAVIS_REPO_SLUG == "mybatis/spring" ] && [ "$TRAVIS_PULL_REQUEST" == "fal # echo -e "Successfully deploy site under Travis job ${TRAVIS_JOB_NUMBER}" # Notify Sonar - ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=ccf0be39fd0ca5ea5aa712247c79da7233cd3caa + ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=ccf0be39fd0ca5ea5aa712247c79da7233cd3caa echo -e "Successfully ran Sonar integration under Travis job ${TRAVIS_JOB_NUMBER}" else echo "Java Version does not support additonal activity for travis CI" From ec803eccd9c74e93efdabebfea7f427861c1a8fd Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 10 Aug 2019 02:41:16 +0900 Subject: [PATCH 139/933] Switch to use openjdk8 instead of oraclejdk8 on Travis CI --- .travis.yml | 2 +- travis/after_success.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a427b76232..bc5e980816 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: java jdk: - openjdk12 - openjdk11 - - oraclejdk8 + - openjdk8 after_success: - chmod -R 777 ./travis/after_success.sh diff --git a/travis/after_success.sh b/travis/after_success.sh index d09d4f2f0e..d8e4c7bb89 100644 --- a/travis/after_success.sh +++ b/travis/after_success.sh @@ -34,7 +34,7 @@ echo "Current commit detected: ${commit_message}" if [ $TRAVIS_REPO_SLUG == "mybatis/spring" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ] && [[ "$commit_message" != *"[maven-release-plugin]"* ]]; then - if [ $TRAVIS_JDK_VERSION == "oraclejdk8" ]; then + if [ $TRAVIS_JDK_VERSION == "openjdk8" ]; then # Deploy to sonatype ./mvnw clean deploy -q --settings ./travis/settings.xml From b04ba3740b7ca5c2c3bb02be0cc473d919c13f7e Mon Sep 17 00:00:00 2001 From: evans810 <48586010+evans810@users.noreply.github.com> Date: Mon, 19 Aug 2019 16:31:56 +0800 Subject: [PATCH 140/933] Update comment in MyBatisBatchItemWriter.java Modify comment in Line 67. As in code line 150, if assertUpdates is true, only results.size()==1 can pass the validation --- .../java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index f51f898522..d389d7ff76 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -64,7 +64,7 @@ public class MyBatisBatchItemWriter implements ItemWriter, InitializingBea private Converter itemToParameterConverter = new PassThroughConverter<>(); /** - * Public setter for the flag that determines whether an assertion is made that all items cause at least one row to be + * Public setter for the flag that determines whether an assertion is made that all items cause only one row to be * updated. * * @param assertUpdates From e03dd5f728cecac7f9a3ed7753b06c73be36500c Mon Sep 17 00:00:00 2001 From: evans810 <48586010+evans810@users.noreply.github.com> Date: Wed, 21 Aug 2019 11:19:03 +0800 Subject: [PATCH 141/933] Update comment in MyBatisBatchItemWriter.java Modify comment in Line 67. As if assertUpdates is true, only results.size() == 1 and results.get(0).getUpdateCounts()[i] != 0 can pass the validation --- .../java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index d389d7ff76..caf784028c 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -64,7 +64,7 @@ public class MyBatisBatchItemWriter implements ItemWriter, InitializingBea private Converter itemToParameterConverter = new PassThroughConverter<>(); /** - * Public setter for the flag that determines whether an assertion is made that all items cause only one row to be + * Public setter for the flag that determines whether an assertion is made that number of BatchResult objects returned is one and all items cause at least one row to be * updated. * * @param assertUpdates From 81efd343a8527c063a93efde08887479f27765b1 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 10 Sep 2019 01:11:55 +0900 Subject: [PATCH 142/933] Allow to configure the SQLExceptionTranslator on MyBatisExceptionTranslator Fixes gh-400 --- .../spring/MyBatisExceptionTranslator.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index f98cf6b126..1f917ff535 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -16,6 +16,7 @@ package org.mybatis.spring; import java.sql.SQLException; +import java.util.function.Supplier; import javax.sql.DataSource; @@ -37,12 +38,11 @@ */ public class MyBatisExceptionTranslator implements PersistenceExceptionTranslator { - private final DataSource dataSource; - + private final Supplier exceptionTranslatorSupplier; private SQLExceptionTranslator exceptionTranslator; /** - * Creates a new {@code DataAccessExceptionTranslator} instance. + * Creates a new {@code PersistenceExceptionTranslator} instance with {@code SQLErrorCodeSQLExceptionTranslator}. * * @param dataSource * DataSource to use to find metadata and establish which error codes are usable. @@ -51,8 +51,22 @@ public class MyBatisExceptionTranslator implements PersistenceExceptionTranslato * exceptions. */ public MyBatisExceptionTranslator(DataSource dataSource, boolean exceptionTranslatorLazyInit) { - this.dataSource = dataSource; + this(() -> new SQLErrorCodeSQLExceptionTranslator(dataSource), exceptionTranslatorLazyInit); + } + /** + * Creates a new {@code PersistenceExceptionTranslator} instance with specified {@code SQLExceptionTranslator}. + * + * @param exceptionTranslatorSupplier + * Supplier for creating a {@code SQLExceptionTranslator} instance + * @param exceptionTranslatorLazyInit + * if true, the translator instantiates internal stuff only the first time will have the need to translate + * exceptions. + * @since 2.0.3 + */ + public MyBatisExceptionTranslator(Supplier exceptionTranslatorSupplier, + boolean exceptionTranslatorLazyInit) { + this.exceptionTranslatorSupplier = exceptionTranslatorSupplier; if (!exceptionTranslatorLazyInit) { this.initExceptionTranslator(); } @@ -85,7 +99,7 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { */ private synchronized void initExceptionTranslator() { if (this.exceptionTranslator == null) { - this.exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(this.dataSource); + this.exceptionTranslator = exceptionTranslatorSupplier.get(); } } From c86af18115573890f61b9b35dc6590a3bcba7c09 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 10 Sep 2019 01:53:57 +0900 Subject: [PATCH 143/933] Apply formatter --- .../java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index caf784028c..19e16fe7e8 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -64,8 +64,8 @@ public class MyBatisBatchItemWriter implements ItemWriter, InitializingBea private Converter itemToParameterConverter = new PassThroughConverter<>(); /** - * Public setter for the flag that determines whether an assertion is made that number of BatchResult objects returned is one and all items cause at least one row to be - * updated. + * Public setter for the flag that determines whether an assertion is made that number of BatchResult objects returned + * is one and all items cause at least one row to be updated. * * @param assertUpdates * the flag to set. Defaults to true; From 01386e7e2568c4b110aecbe7fda03de25bb812ab Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 14 Oct 2019 15:02:04 +0900 Subject: [PATCH 144/933] Upgrade to spring 5.1.10 Fixes gh-404 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1c11db0e5c..70634b436a 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.2 - 5.1.8.RELEASE + 5.1.10.RELEASE 4.1.2.RELEASE org.mybatis.spring From 01b244446e49924b490a2d41a44140c72d1c60e3 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 14 Oct 2019 15:08:52 +0900 Subject: [PATCH 145/933] Support spring 5.2 and spring-batch 4.2 on Travis CI Fixes gh-405 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index bc5e980816..982f8be0ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,10 @@ jdk: - openjdk11 - openjdk8 +script: + - ./mvnw clean verify + - ./mvnw clean verify -Dspring.version=5.2.0.RELEASE -Dspring-batch.version=4.2.0.RELEASE -Denforcer.fail=false + after_success: - chmod -R 777 ./travis/after_success.sh - ./travis/after_success.sh From e16c6bb1372d0bcd4e9a0217337ecaeb54e84abd Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 20 Oct 2019 20:34:52 +0900 Subject: [PATCH 146/933] Upgrade to mybatis 3.5.3 Fixes gh-406 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70634b436a..335f53cc60 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.2 + 3.5.3 5.1.10.RELEASE 4.1.2.RELEASE org.mybatis.spring From 7572f3e52f49bb15dd0dfdb0696813a1ab2bef52 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 20 Oct 2019 20:51:17 +0900 Subject: [PATCH 147/933] [maven-release-plugin] prepare release mybatis-spring-2.0.3 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 335f53cc60..63ac682afd 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.3-SNAPSHOT + 2.0.3 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-2.0.3 GitHub Issue Management From 12ff817724ade950f7dfda817189f7a2a493e1b9 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 20 Oct 2019 20:51:25 +0900 Subject: [PATCH 148/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 63ac682afd..2073f9a26b 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.3 + 2.0.4-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-2.0.3 + HEAD GitHub Issue Management From 7356e2ee6836cd009d9f3b5e89ff7c11b353a1e8 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 20 Oct 2019 22:38:28 +0900 Subject: [PATCH 149/933] Support openjdk13 on Travis CI Fixes gh-407 --- .travis.yml | 1 + pom.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 982f8be0ac..5f0793f150 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: java jdk: + - openjdk13 - openjdk12 - openjdk11 - openjdk8 diff --git a/pom.xml b/pom.xml index 2073f9a26b..2322044692 100644 --- a/pom.xml +++ b/pom.xml @@ -111,6 +111,9 @@ org.mybatis.spring 5.5.0 + + + 0.8.4 From e62fa0f73139ab10e3e3b8b13b945bcb79d43f53 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 21 Oct 2019 00:36:31 +0900 Subject: [PATCH 150/933] Support openjdk-ea on Travis CI Fixes gh-386 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5f0793f150..e69d708a09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: java jdk: + - openjdk-ea - openjdk13 - openjdk12 - openjdk11 From 7889c9810a399d9615ad90b6758d8207e4a5d7e5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2019 08:33:56 +0000 Subject: [PATCH 151/933] Bump hsqldb from 2.4.1 to 2.5.0 Bumps hsqldb from 2.4.1 to 2.5.0. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2322044692..ca1db1d36b 100644 --- a/pom.xml +++ b/pom.xml @@ -212,7 +212,7 @@ org.hsqldb hsqldb - 2.4.1 + 2.5.0 test From 1edf5b9ba64dfdc60827dbfebfda76060314d6e1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2019 08:35:05 +0000 Subject: [PATCH 152/933] Bump jakarta.transaction-api from 1.3.2 to 1.3.3 Bumps [jakarta.transaction-api](https://github.com/eclipse-ee4j/jta-api) from 1.3.2 to 1.3.3. - [Release notes](https://github.com/eclipse-ee4j/jta-api/releases) - [Commits](https://github.com/eclipse-ee4j/jta-api/compare/1.3.2...1.3.3) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2322044692..de778f9044 100644 --- a/pom.xml +++ b/pom.xml @@ -297,7 +297,7 @@ jakarta.transaction jakarta.transaction-api - 1.3.2 + 1.3.3 test From ab901a5d33c40e04e60e0d177657c5dc8c76958e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2019 08:35:25 +0000 Subject: [PATCH 153/933] Bump jakarta.servlet-api from 4.0.2 to 4.0.3 Bumps [jakarta.servlet-api](https://github.com/eclipse-ee4j/servlet-api) from 4.0.2 to 4.0.3. - [Release notes](https://github.com/eclipse-ee4j/servlet-api/releases) - [Commits](https://github.com/eclipse-ee4j/servlet-api/commits) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2322044692..1581a1f379 100644 --- a/pom.xml +++ b/pom.xml @@ -303,7 +303,7 @@ jakarta.servlet jakarta.servlet-api - 4.0.2 + 4.0.3 test From 5cb0cf423973b44b3ad95bc518ee1e6a1c502c1f Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 11 Nov 2019 00:05:36 +0900 Subject: [PATCH 154/933] Upgrade to spring-framework 5.1.11 Fixes gh-417 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b96fcc650..4fc7bfe49e 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.3 - 5.1.10.RELEASE + 5.1.11.RELEASE 4.1.2.RELEASE org.mybatis.spring From 6f26832afdda625cd933cc99f58a5840622fbc6c Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 11 Nov 2019 00:08:52 +0900 Subject: [PATCH 155/933] Upgrade to spring-framework 5.2.1 on Travis CI Fixes gh-418 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e69d708a09..42b8fe9c89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ jdk: script: - ./mvnw clean verify - - ./mvnw clean verify -Dspring.version=5.2.0.RELEASE -Dspring-batch.version=4.2.0.RELEASE -Denforcer.fail=false + - ./mvnw clean verify -Dspring.version=5.2.1.RELEASE -Dspring-batch.version=4.2.0.RELEASE -Denforcer.fail=false after_success: - chmod -R 777 ./travis/after_success.sh From 91069f7ecdea3e07e1e950fe14afc4761ed19c80 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2019 09:52:32 +0000 Subject: [PATCH 156/933] Bump mockito-core from 2.27.0 to 3.1.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 2.27.0 to 3.1.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v2.27.0...v3.1.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fc7bfe49e..01f06e9e1f 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.mockito mockito-core - 2.27.0 + 3.1.0 test From 48c9fde31188a03bef2d6d5bfe58b1d16706b48b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2019 09:53:23 +0000 Subject: [PATCH 157/933] Bump byteman-bmunit from 4.0.6 to 4.0.8 Bumps byteman-bmunit from 4.0.6 to 4.0.8. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fc7bfe49e..793fe76979 100644 --- a/pom.xml +++ b/pom.xml @@ -171,7 +171,7 @@ org.jboss.byteman byteman-bmunit - 4.0.6 + 4.0.8 test From 7030348b2946b2d281e8242dcbea96e6a8a4d764 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2019 09:54:19 +0000 Subject: [PATCH 158/933] Bump junit-jupiter-engine from 5.5.0 to 5.5.2 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.5.0 to 5.5.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.5.0...r5.5.2) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fc7bfe49e..7e34cd1819 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.1.2.RELEASE org.mybatis.spring - 5.5.0 + 5.5.2 0.8.4 From 4158a0670a9ebdfaf5246f03fe3b371f525acc20 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2019 06:57:31 +0000 Subject: [PATCH 159/933] Bump assertj-core from 3.12.2 to 3.14.0 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.12.2 to 3.14.0. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.12.2...assertj-core-3.14.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c52a902b01..ec75aa08a8 100644 --- a/pom.xml +++ b/pom.xml @@ -233,7 +233,7 @@ org.assertj assertj-core - 3.12.2 + 3.14.0 test From ae1198602cef77748d96b816e95407a7f25af067 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 13 Nov 2019 01:54:40 +0900 Subject: [PATCH 160/933] Bump transactions-jdbc from 4.0.6 to 5.0.3 Fixes gh-420 --- pom.xml | 2 +- .../mybatis/spring/submitted/xa/applicationContext.xml | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index cb34d79e66..010a055400 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,7 @@ com.atomikos transactions-jdbc - 4.0.6 + 5.0.3 test diff --git a/src/test/java/org/mybatis/spring/submitted/xa/applicationContext.xml b/src/test/java/org/mybatis/spring/submitted/xa/applicationContext.xml index a8739f70dd..0e6098cdb3 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/applicationContext.xml +++ b/src/test/java/org/mybatis/spring/submitted/xa/applicationContext.xml @@ -47,11 +47,11 @@ - - @@ -78,6 +78,7 @@ init-method="init" destroy-method="close"> + 1 @@ -96,6 +97,7 @@ init-method="init" destroy-method="close"> + 1 @@ -146,4 +148,4 @@ - + From afcce3d1a3da43c2b0400ddde41d2d88bb7b554e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2019 07:04:48 +0000 Subject: [PATCH 161/933] Bump byteman-bmunit from 4.0.8 to 4.0.9 Bumps byteman-bmunit from 4.0.8 to 4.0.9. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 010a055400..7ecdc0b2b7 100644 --- a/pom.xml +++ b/pom.xml @@ -171,7 +171,7 @@ org.jboss.byteman byteman-bmunit - 4.0.8 + 4.0.9 test From de2dd1827c67be2f4775d6199001b0a3996c18a4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 06:59:21 +0000 Subject: [PATCH 162/933] Bump mockito-core from 3.1.0 to 3.2.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.1.0...v3.2.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ecdc0b2b7..5b1631d663 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.mockito mockito-core - 3.1.0 + 3.2.0 test From 9d62e0cc56e7bd7cc56e3b99680c37c7b6890966 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 06:59:43 +0000 Subject: [PATCH 163/933] Bump transactions-jdbc from 5.0.3 to 5.0.4 Bumps transactions-jdbc from 5.0.3 to 5.0.4. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ecdc0b2b7..a6634c0f85 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,7 @@ com.atomikos transactions-jdbc - 5.0.3 + 5.0.4 test From 35fbf55ad9c175e4f5087dc6bdf225abfbc6d103 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 3 Dec 2019 02:09:07 +0900 Subject: [PATCH 164/933] Revert "Remove unnecessary throws clause" This reverts commit 5ca5f2df3577f8b670292cfb0864a57e9b8685e6. --- src/main/java/org/mybatis/spring/SqlSessionTemplate.java | 4 ++-- .../org/mybatis/spring/batch/MyBatisCursorItemReader.java | 4 ++-- .../mybatis/spring/transaction/SpringManagedTransaction.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java index f573d6317e..7f11156f6f 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java +++ b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java @@ -389,7 +389,7 @@ public List flushStatements() { /** * Allow gently dispose bean: - * + * *

        * {@code
        *
    @@ -407,7 +407,7 @@ public List flushStatements() {
        * @see "org.springframework.beans.factory.support.DisposableBeanAdapter#CLOSE_METHOD_NAME"
        */
       @Override
    -  public void destroy() {
    +  public void destroy() throws Exception {
         // This method forces spring disposer to avoid call of SqlSessionTemplate.close() which gives
         // UnsupportedOperationException
       }
    diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java
    index a1527a7f4c..ee2626cce7 100644
    --- a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java
    +++ b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java
    @@ -50,7 +50,7 @@ public MyBatisCursorItemReader() {
       }
     
       @Override
    -  protected T doRead() {
    +  protected T doRead() throws Exception {
         T next = null;
         if (cursorIterator.hasNext()) {
           next = cursorIterator.next();
    @@ -59,7 +59,7 @@ protected T doRead() {
       }
     
       @Override
    -  protected void doOpen() {
    +  protected void doOpen() throws Exception {
         Map parameters = new HashMap<>();
         if (parameterValues != null) {
           parameters.putAll(parameterValues);
    diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java
    index 32cb92146b..6d90052cd9 100644
    --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java
    +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java
    @@ -111,7 +111,7 @@ public void rollback() throws SQLException {
        * {@inheritDoc}
        */
       @Override
    -  public void close() {
    +  public void close() throws SQLException {
         DataSourceUtils.releaseConnection(this.connection, this.dataSource);
       }
     
    @@ -119,7 +119,7 @@ public void close() {
        * {@inheritDoc}
        */
       @Override
    -  public Integer getTimeout() {
    +  public Integer getTimeout() throws SQLException {
         ConnectionHolder holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
         if (holder != null && holder.hasTimeout()) {
           return holder.getTimeToLiveInSeconds();
    
    From 76946c55bcd8e6c8f99a50c95c3989b2b420b9d8 Mon Sep 17 00:00:00 2001
    From: "dependabot-preview[bot]"
     <27856297+dependabot-preview[bot]@users.noreply.github.com>
    Date: Wed, 4 Dec 2019 06:53:52 +0000
    Subject: [PATCH 165/933] Bump spring.version from 5.1.11.RELEASE to
     5.2.2.RELEASE
    
    Bumps `spring.version` from 5.1.11.RELEASE to 5.2.2.RELEASE.
    
    Updates `spring-context` from 5.1.11.RELEASE to 5.2.2.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-framework/releases)
    - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.1.11.RELEASE...v5.2.2.RELEASE)
    
    Updates `spring-jdbc` from 5.1.11.RELEASE to 5.2.2.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-framework/releases)
    - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.1.11.RELEASE...v5.2.2.RELEASE)
    
    Updates `spring-test` from 5.1.11.RELEASE to 5.2.2.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-framework/releases)
    - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.1.11.RELEASE...v5.2.2.RELEASE)
    
    Updates `spring-web` from 5.1.11.RELEASE to 5.2.2.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-framework/releases)
    - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.1.11.RELEASE...v5.2.2.RELEASE)
    
    Signed-off-by: dependabot-preview[bot] 
    ---
     pom.xml | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/pom.xml b/pom.xml
    index 966fd1d55f..3ec1d8cc50 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -106,7 +106,7 @@
         *
     
         3.5.3
    -    5.1.11.RELEASE
    +    5.2.2.RELEASE
         4.1.2.RELEASE
         org.mybatis.spring
     
    
    From 0ba4237fa50e62012c624d592cee158c3307b53e Mon Sep 17 00:00:00 2001
    From: "dependabot-preview[bot]"
     <27856297+dependabot-preview[bot]@users.noreply.github.com>
    Date: Fri, 6 Dec 2019 02:31:22 +0000
    Subject: [PATCH 166/933] Bump spring-batch.version from 4.1.2.RELEASE to
     4.2.1.RELEASE
    
    Bumps `spring-batch.version` from 4.1.2.RELEASE to 4.2.1.RELEASE.
    
    Updates `spring-batch-infrastructure` from 4.1.2.RELEASE to 4.2.1.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-batch/releases)
    - [Commits](https://github.com/spring-projects/spring-batch/compare/4.1.2.RELEASE...4.2.1.RELEASE)
    
    Updates `spring-batch-core` from 4.1.2.RELEASE to 4.2.1.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-batch/releases)
    - [Commits](https://github.com/spring-projects/spring-batch/compare/4.1.2.RELEASE...4.2.1.RELEASE)
    
    Updates `spring-batch-test` from 4.1.2.RELEASE to 4.2.1.RELEASE
    - [Release notes](https://github.com/spring-projects/spring-batch/releases)
    - [Commits](https://github.com/spring-projects/spring-batch/compare/4.1.2.RELEASE...4.2.1.RELEASE)
    
    Signed-off-by: dependabot-preview[bot] 
    ---
     pom.xml | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/pom.xml b/pom.xml
    index 3ec1d8cc50..329f0822cb 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -107,7 +107,7 @@
     
         3.5.3
         5.2.2.RELEASE
    -    4.1.2.RELEASE
    +    4.2.1.RELEASE
         org.mybatis.spring
     
         5.5.2
    
    From 6ec8be05e64b7043b3619923dc155decca595774 Mon Sep 17 00:00:00 2001
    From: Kazuki Shimizu 
    Date: Fri, 6 Dec 2019 11:44:11 +0900
    Subject: [PATCH 167/933] Change version to spring 5.1.x and spring-batch 4.1.x
     on Travis CI Fixes gh-434
    
    ---
     .travis.yml | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/.travis.yml b/.travis.yml
    index 42b8fe9c89..76074e2dbb 100644
    --- a/.travis.yml
    +++ b/.travis.yml
    @@ -9,7 +9,7 @@ jdk:
     
     script:
       - ./mvnw clean verify
    -  - ./mvnw clean verify -Dspring.version=5.2.1.RELEASE -Dspring-batch.version=4.2.0.RELEASE -Denforcer.fail=false
    +  - ./mvnw clean verify -Dspring.version=5.1.12.RELEASE -Dspring-batch.version=4.1.3.RELEASE
     
     after_success:
       - chmod -R 777 ./travis/after_success.sh
    
    From cbfea6642bfa1ecb1bc82cc1140e5fc8a59813d3 Mon Sep 17 00:00:00 2001
    From: "dependabot-preview[bot]"
     <27856297+dependabot-preview[bot]@users.noreply.github.com>
    Date: Mon, 9 Dec 2019 07:02:28 +0000
    Subject: [PATCH 168/933] Bump transactions-jdbc from 5.0.4 to 5.0.5
    
    Bumps transactions-jdbc from 5.0.4 to 5.0.5.
    
    Signed-off-by: dependabot-preview[bot] 
    ---
     pom.xml | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/pom.xml b/pom.xml
    index 329f0822cb..e492cae503 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -150,7 +150,7 @@
         
           com.atomikos
           transactions-jdbc
    -      5.0.4
    +      5.0.5
           test
         
     
    
    From 94ac8c6ba99b8a6277278b07a4f4de188f8cd287 Mon Sep 17 00:00:00 2001
    From: "dependabot-preview[bot]"
     <27856297+dependabot-preview[bot]@users.noreply.github.com>
    Date: Thu, 12 Dec 2019 06:53:36 +0000
    Subject: [PATCH 169/933] Bump transactions-jdbc from 5.0.5 to 5.0.6
    
    Bumps transactions-jdbc from 5.0.5 to 5.0.6.
    
    Signed-off-by: dependabot-preview[bot] 
    ---
     pom.xml | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/pom.xml b/pom.xml
    index e492cae503..34a6f0dfdb 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -150,7 +150,7 @@
         
           com.atomikos
           transactions-jdbc
    -      5.0.5
    +      5.0.6
           test
         
     
    
    From aa5de2fd65dd4a21c77718821803dbe11d6d1c35 Mon Sep 17 00:00:00 2001
    From: Tatsuya Shimoda 
    Date: Thu, 12 Dec 2019 17:02:19 +0900
    Subject: [PATCH 170/933] Scan mappers from the package of the class that
     declares MapperScan annotation if basePackages attrubute is not present
    
    ---
     .../org/mybatis/spring/annotation/MapperScan.java  |  5 +++++
     .../spring/annotation/MapperScannerRegistrar.java  | 14 +++++++++++---
     .../mybatis/spring/annotation/MapperScanTest.java  | 14 ++++++++++++++
     .../mapper/AppConfigWithDefaultPackageScan.java    | 10 ++++++++++
     4 files changed, 40 insertions(+), 3 deletions(-)
     create mode 100644 src/test/java/org/mybatis/spring/mapper/AppConfigWithDefaultPackageScan.java
    
    diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java
    index ee587e1775..8be5d010a6 100644
    --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java
    +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java
    @@ -31,6 +31,11 @@
     /**
      * Use this annotation to register MyBatis mapper interfaces when using Java Config. It performs when same work as
      * {@link MapperScannerConfigurer} via {@link MapperScannerRegistrar}.
    + * 
    + * 

    Either {@link #basePackageClasses} or {@link #basePackages} (or its alias + * {@link #value}) may be specified to define specific packages to scan. If specific + * packages are not defined, scanning will occur from the package of the + * class that declares this annotation. * *

    * Configuration example: diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index af99f0406f..e77167de5f 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -70,11 +70,11 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B AnnotationAttributes mapperScanAttrs = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName())); if (mapperScanAttrs != null) { - registerBeanDefinitions(mapperScanAttrs, registry, generateBaseBeanName(importingClassMetadata, 0)); + registerBeanDefinitions(mapperScanAttrs, registry, generateBaseBeanName(importingClassMetadata, 0), getDefaultBasePackage(importingClassMetadata)); } } - void registerBeanDefinitions(AnnotationAttributes annoAttrs, BeanDefinitionRegistry registry, String beanName) { + void registerBeanDefinitions(AnnotationAttributes annoAttrs, BeanDefinitionRegistry registry, String beanName, String defaultBasePackage) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); builder.addPropertyValue("processPropertyPlaceHolders", true); @@ -119,6 +119,10 @@ void registerBeanDefinitions(AnnotationAttributes annoAttrs, BeanDefinitionRegis basePackages.addAll(Arrays.stream(annoAttrs.getClassArray("basePackageClasses")).map(ClassUtils::getPackageName) .collect(Collectors.toList())); + if (basePackages.isEmpty()) { + basePackages.add(defaultBasePackage); + } + String lazyInitialization = annoAttrs.getString("lazyInitialization"); if (StringUtils.hasText(lazyInitialization)) { builder.addPropertyValue("lazyInitialization", lazyInitialization); @@ -134,6 +138,10 @@ private static String generateBaseBeanName(AnnotationMetadata importingClassMeta return importingClassMetadata.getClassName() + "#" + MapperScannerRegistrar.class.getSimpleName() + "#" + index; } + private static String getDefaultBasePackage(AnnotationMetadata importingClassMetadata) { + return ClassUtils.getPackageName(importingClassMetadata.getClassName()); + } + /** * A {@link MapperScannerRegistrar} for {@link MapperScans}. * @@ -150,7 +158,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B if (mapperScansAttrs != null) { AnnotationAttributes[] annotations = mapperScansAttrs.getAnnotationArray("value"); for (int i = 0; i < annotations.length; i++) { - registerBeanDefinitions(annotations[i], registry, generateBaseBeanName(importingClassMetadata, i)); + registerBeanDefinitions(annotations[i], registry, generateBaseBeanName(importingClassMetadata, i), getDefaultBasePackage(importingClassMetadata)); } } } diff --git a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java index c46f04187b..6ef2286712 100644 --- a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java +++ b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java @@ -28,6 +28,7 @@ import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.annotation.mapper.ds1.Ds1Mapper; import org.mybatis.spring.mapper.AnnotatedMapper; +import org.mybatis.spring.mapper.AppConfigWithDefaultPackageScan; import org.mybatis.spring.mapper.MapperInterface; import org.mybatis.spring.mapper.MapperSubinterface; import org.mybatis.spring.mapper.child.MapperChildInterface; @@ -90,6 +91,19 @@ void assertNoMapperClass() { } } + @Test + void testDefaultMapperScan() { + applicationContext.register(AppConfigWithDefaultPackageScan.class); + + startContext(); + + // all interfaces with methods should be loaded + applicationContext.getBean("mapperInterface"); + applicationContext.getBean("mapperSubinterface"); + applicationContext.getBean("mapperChildInterface"); + applicationContext.getBean("annotatedMapper"); + } + @Test void testInterfaceScan() { applicationContext.register(AppConfigWithPackageScan.class); diff --git a/src/test/java/org/mybatis/spring/mapper/AppConfigWithDefaultPackageScan.java b/src/test/java/org/mybatis/spring/mapper/AppConfigWithDefaultPackageScan.java new file mode 100644 index 0000000000..dc3e95ec1d --- /dev/null +++ b/src/test/java/org/mybatis/spring/mapper/AppConfigWithDefaultPackageScan.java @@ -0,0 +1,10 @@ +package org.mybatis.spring.mapper; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan +public class AppConfigWithDefaultPackageScan { + +} From 8623026b5e024f4311eeb3f58a90230003f47674 Mon Sep 17 00:00:00 2001 From: shimoda Date: Fri, 13 Dec 2019 11:51:47 +0900 Subject: [PATCH 171/933] added more tests and fixed javadoc --- .../mybatis/spring/annotation/MapperScan.java | 6 ++-- .../spring/annotation/MapperScanTest.java | 28 +++++++++++++++++++ ...pConfigWithDefaultMapperScanAndRepeat.java | 10 +++++++ .../ds1/AppConfigWithDefaultMapperScans.java | 13 +++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScanAndRepeat.java create mode 100644 src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScans.java diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index 8be5d010a6..159a5fa89c 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -33,9 +33,9 @@ * {@link MapperScannerConfigurer} via {@link MapperScannerRegistrar}. * *

    Either {@link #basePackageClasses} or {@link #basePackages} (or its alias - * {@link #value}) may be specified to define specific packages to scan. If specific - * packages are not defined, scanning will occur from the package of the - * class that declares this annotation. + * {@link #value}) may be specified to define specific packages to scan. + * Since 2.0.4, If specific packages are not defined, scanning will occur from + * the package of the class that declares this annotation. * *

    * Configuration example: diff --git a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java index 6ef2286712..0b54054a0c 100644 --- a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java +++ b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java @@ -26,6 +26,8 @@ import org.junit.jupiter.api.Test; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.mapper.ds1.AppConfigWithDefaultMapperScanAndRepeat; +import org.mybatis.spring.annotation.mapper.ds1.AppConfigWithDefaultMapperScans; import org.mybatis.spring.annotation.mapper.ds1.Ds1Mapper; import org.mybatis.spring.mapper.AnnotatedMapper; import org.mybatis.spring.mapper.AppConfigWithDefaultPackageScan; @@ -289,6 +291,32 @@ void testScanWithMapperScans() { applicationContext.getBean("ds2Mapper"); } + @Test + void testScanWithDefaultMapperScanAndRepeat() { + applicationContext.register(AppConfigWithDefaultMapperScanAndRepeat.class); + + startContext(); + + SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + + applicationContext.getBean("ds1Mapper"); + applicationContext.getBean("ds2Mapper"); + } + + @Test + void testScanWithDefaultMapperScans() { + applicationContext.register(AppConfigWithDefaultMapperScans.class); + + startContext(); + + SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + + applicationContext.getBean("ds1Mapper"); + applicationContext.getBean("ds2Mapper"); + } + @Test void testLazyScanWithPropertySourcesPlaceholderConfigurer() { applicationContext.register(LazyConfigWithPropertySourcesPlaceholderConfigurer.class); diff --git a/src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScanAndRepeat.java b/src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScanAndRepeat.java new file mode 100644 index 0000000000..a6edbcad18 --- /dev/null +++ b/src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScanAndRepeat.java @@ -0,0 +1,10 @@ +package org.mybatis.spring.annotation.mapper.ds1; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan +@MapperScan("org.mybatis.spring.annotation.mapper.ds2") +public class AppConfigWithDefaultMapperScanAndRepeat { +} diff --git a/src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScans.java b/src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScans.java new file mode 100644 index 0000000000..af3e1364f7 --- /dev/null +++ b/src/test/java/org/mybatis/spring/annotation/mapper/ds1/AppConfigWithDefaultMapperScans.java @@ -0,0 +1,13 @@ +package org.mybatis.spring.annotation.mapper.ds1; + +import org.mybatis.spring.annotation.MapperScan; +import org.mybatis.spring.annotation.MapperScans; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScans({ + @MapperScan, + @MapperScan("org.mybatis.spring.annotation.mapper.ds2") +}) +public class AppConfigWithDefaultMapperScans { +} From 33e568af40d68d5cff9ba86fa283514df8e3f4e3 Mon Sep 17 00:00:00 2001 From: shimoda Date: Fri, 13 Dec 2019 12:18:05 +0900 Subject: [PATCH 172/933] added a note in the document --- src/site/xdoc/mappers.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/site/xdoc/mappers.xml b/src/site/xdoc/mappers.xml index 304b6fecab..62fe64b118 100644 --- a/src/site/xdoc/mappers.xml +++ b/src/site/xdoc/mappers.xml @@ -247,7 +247,11 @@ public class AppConfig { You can also provide an specific SqlSessionFactory or SqlSessionTemplate by using its properties sqlSessionFactory and sqlSessionTemplate.

    - + +

    + NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. +

    +

    MapperScannerConfigurer

    From be079d6a0ab115883d604d15a7afdf71ca645f13 Mon Sep 17 00:00:00 2001 From: Tatsuya Shimoda Date: Sat, 14 Dec 2019 03:17:28 +0900 Subject: [PATCH 173/933] added AnnotationAttributes as a param --- .../mybatis/spring/annotation/MapperScannerRegistrar.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index e77167de5f..e9b1546365 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -70,11 +70,11 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B AnnotationAttributes mapperScanAttrs = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName())); if (mapperScanAttrs != null) { - registerBeanDefinitions(mapperScanAttrs, registry, generateBaseBeanName(importingClassMetadata, 0), getDefaultBasePackage(importingClassMetadata)); + registerBeanDefinitions(importingClassMetadata, mapperScanAttrs, registry, generateBaseBeanName(importingClassMetadata, 0)); } } - void registerBeanDefinitions(AnnotationAttributes annoAttrs, BeanDefinitionRegistry registry, String beanName, String defaultBasePackage) { + void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes annoAttrs, BeanDefinitionRegistry registry, String beanName) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); builder.addPropertyValue("processPropertyPlaceHolders", true); @@ -120,7 +120,7 @@ void registerBeanDefinitions(AnnotationAttributes annoAttrs, BeanDefinitionRegis .collect(Collectors.toList())); if (basePackages.isEmpty()) { - basePackages.add(defaultBasePackage); + basePackages.add(getDefaultBasePackage(annoMeta)); } String lazyInitialization = annoAttrs.getString("lazyInitialization"); @@ -158,7 +158,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B if (mapperScansAttrs != null) { AnnotationAttributes[] annotations = mapperScansAttrs.getAnnotationArray("value"); for (int i = 0; i < annotations.length; i++) { - registerBeanDefinitions(annotations[i], registry, generateBaseBeanName(importingClassMetadata, i), getDefaultBasePackage(importingClassMetadata)); + registerBeanDefinitions(importingClassMetadata, annotations[i], registry, generateBaseBeanName(importingClassMetadata, i)); } } } From a9fce71a747ff8773d2aa452b6ba8912098f3642 Mon Sep 17 00:00:00 2001 From: Tatsuya Shimoda Date: Sat, 14 Dec 2019 03:39:11 +0900 Subject: [PATCH 174/933] added i18n docs --- src/site/es/xdoc/mappers.xml | 6 +++++- src/site/ja/xdoc/mappers.xml | 6 +++++- src/site/ko/xdoc/mappers.xml | 6 +++++- src/site/zh/xdoc/mappers.xml | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/site/es/xdoc/mappers.xml b/src/site/es/xdoc/mappers.xml index 0baebebce8..de81624425 100644 --- a/src/site/es/xdoc/mappers.xml +++ b/src/site/es/xdoc/mappers.xml @@ -234,7 +234,11 @@ public class AppConfig { Tambien puedes indicar una SqlSessionFactory o un SqlSessionTemplate específicos mediante las propiedades sqlSessionFactory y sqlSessionTemplate.

    - + +

    + NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. +

    +

    MapperScannerConfigurer

    diff --git a/src/site/ja/xdoc/mappers.xml b/src/site/ja/xdoc/mappers.xml index 1890b478df..d477515352 100644 --- a/src/site/ja/xdoc/mappers.xml +++ b/src/site/ja/xdoc/mappers.xml @@ -210,7 +210,11 @@ public class AppConfig { このアノテーションは前章で説明した <mybatis:scan/> と全く同じ要領で Mapper の検出を行います。 引数 markerInterface, annotationClass を使えば検出対象のマーカーインターフェイスとアノテーションを指定することもできますし、sqlSessionFactory, sqlSessionTemplateSqlSessionFactorySqlSessionTemplate を指定することができます。

    - + +

    + NOTE 2.0.4以降では、 basePackageClasses もしくは basePackages が指定されていない場合、このアノテーションが定義されているクラスのパッケージを基準にスキャンします。 +

    +

    MapperScannerConfigurer

    diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml index 3a2acb6b30..08abb2e8de 100644 --- a/src/site/ko/xdoc/mappers.xml +++ b/src/site/ko/xdoc/mappers.xml @@ -191,7 +191,11 @@ public class AppConfig { markerInterfaceannotationClass 프로퍼티를 사용해서 마커 인터페이스와 애노테이션 클래스를 명시하게 한다. sqlSessionFactorysqlSessionTemplate 프로퍼티를 사용해서 SqlSessionFactorySqlSessionTemplate을 제공할 수도 있다.

    - + +

    + NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. +

    +

    MapperScannerConfigurer

    MapperScannerConfigurer는 평범한 빈처럼 XML애플리케이션 컨텍스트에 포함된 BeanDefinitionRegistryPostProcessor 이다. diff --git a/src/site/zh/xdoc/mappers.xml b/src/site/zh/xdoc/mappers.xml index 34320c51b3..a426f640ce 100644 --- a/src/site/zh/xdoc/mappers.xml +++ b/src/site/zh/xdoc/mappers.xml @@ -195,6 +195,10 @@ public class AppConfig { 这个注解具有与之前见过的 <mybatis:scan/> 元素一样的工作方式。它也可以通过 markerInterfaceannotationClass 属性设置标记接口或注解类。通过配置 sqlSessionFactorysqlSessionTemplate 属性,你还能指定一个 SqlSessionFactorySqlSessionTemplate

    +

    + NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. +

    +

    MapperScannerConfigurer

    From bb33c660a1f7c1fb5b2adce1511d6666c5dc5a08 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2019 06:59:43 +0000 Subject: [PATCH 175/933] Bump mockito-core from 3.2.0 to 3.2.4 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.2.0 to 3.2.4. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.2.0...v3.2.4) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34a6f0dfdb..c26d4cfc65 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.mockito mockito-core - 3.2.0 + 3.2.4 test From 782cbd66f920dc0cd282287c31249788d900df91 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2020 06:57:51 +0000 Subject: [PATCH 176/933] Bump spring.version from 5.2.2.RELEASE to 5.2.3.RELEASE Bumps `spring.version` from 5.2.2.RELEASE to 5.2.3.RELEASE. Updates `spring-context` from 5.2.2.RELEASE to 5.2.3.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.2.RELEASE...v5.2.3.RELEASE) Updates `spring-jdbc` from 5.2.2.RELEASE to 5.2.3.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.2.RELEASE...v5.2.3.RELEASE) Updates `spring-test` from 5.2.2.RELEASE to 5.2.3.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.2.RELEASE...v5.2.3.RELEASE) Updates `spring-web` from 5.2.2.RELEASE to 5.2.3.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.2.RELEASE...v5.2.3.RELEASE) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c26d4cfc65..4c6f8824fb 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.3 - 5.2.2.RELEASE + 5.2.3.RELEASE 4.2.1.RELEASE org.mybatis.spring From 898005c6f5782f41e88efe3d8f6599b7833678d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=B7=E6=99=BA=E5=86=AC?= Date: Mon, 20 Jan 2020 11:20:12 +0800 Subject: [PATCH 177/933] Fix typo Fix typo --- src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index fb7463e168..0a374567f4 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -479,7 +479,7 @@ public void afterPropertiesSet() throws Exception { * Build a {@code SqlSessionFactory} instance. * * The default implementation uses the standard MyBatis {@code XMLConfigBuilder} API to build a - * {@code SqlSessionFactory} instance based on an Reader. Since 1.3.0, it can be specified a {@link Configuration} + * {@code SqlSessionFactory} instance based on a Reader. Since 1.3.0, it can be specified a {@link Configuration} * instance directly(without config file). * * @return SqlSessionFactory From b196c31d47d99f785da3c110728e2239803fc0e4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2020 06:57:08 +0000 Subject: [PATCH 178/933] Bump junit-jupiter-engine from 5.5.2 to 5.6.0 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.5.2 to 5.6.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.5.2...r5.6.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c6f8824fb..630835fcff 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.2.1.RELEASE org.mybatis.spring - 5.5.2 + 5.6.0 0.8.4 From 11c7c6b11b78a3fbdcf20cb1aca2ba365fbeaf00 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2020 06:57:25 +0000 Subject: [PATCH 179/933] Bump byteman-bmunit from 4.0.9 to 4.0.10 Bumps byteman-bmunit from 4.0.9 to 4.0.10. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c6f8824fb..17161c2387 100644 --- a/pom.xml +++ b/pom.xml @@ -171,7 +171,7 @@ org.jboss.byteman byteman-bmunit - 4.0.9 + 4.0.10 test From 9e2d93180ef3639c8ab99ae5179e80f3fd457b24 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2020 07:00:50 +0000 Subject: [PATCH 180/933] Bump assertj-core from 3.14.0 to 3.15.0 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.14.0 to 3.15.0. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.14.0...assertj-core-3.15.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa24050a8e..b071114702 100644 --- a/pom.xml +++ b/pom.xml @@ -233,7 +233,7 @@ org.assertj assertj-core - 3.14.0 + 3.15.0 test From 51f51b67bb31ac15b1a2f92178a6325eccebc827 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2020 07:17:32 +0000 Subject: [PATCH 181/933] Bump mybatis from 3.5.3 to 3.5.4 Bumps [mybatis](https://github.com/mybatis/mybatis-3) from 3.5.3 to 3.5.4. - [Release notes](https://github.com/mybatis/mybatis-3/releases) - [Commits](https://github.com/mybatis/mybatis-3/compare/mybatis-3.5.3...mybatis-3.5.4) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b071114702..a742c95789 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.3 + 3.5.4 5.2.3.RELEASE 4.2.1.RELEASE org.mybatis.spring From 04152591073807ce85d54ced0e6b848f02c15355 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2020 07:02:35 +0000 Subject: [PATCH 182/933] Bump mockito-core from 3.2.4 to 3.3.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.2.4 to 3.3.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.2.4...v3.3.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a742c95789..747811a515 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.mockito mockito-core - 3.2.4 + 3.3.0 test From ce914b885cba7d44faa6222094f451bb8a3af894 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2020 07:03:53 +0000 Subject: [PATCH 183/933] Bump spring.version from 5.2.3.RELEASE to 5.2.4.RELEASE Bumps `spring.version` from 5.2.3.RELEASE to 5.2.4.RELEASE. Updates `spring-context` from 5.2.3.RELEASE to 5.2.4.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.3.RELEASE...v5.2.4.RELEASE) Updates `spring-jdbc` from 5.2.3.RELEASE to 5.2.4.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.3.RELEASE...v5.2.4.RELEASE) Updates `spring-test` from 5.2.3.RELEASE to 5.2.4.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.3.RELEASE...v5.2.4.RELEASE) Updates `spring-web` from 5.2.3.RELEASE to 5.2.4.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.3.RELEASE...v5.2.4.RELEASE) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 747811a515..8b6945b27d 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.4 - 5.2.3.RELEASE + 5.2.4.RELEASE 4.2.1.RELEASE org.mybatis.spring From 058e9219e85819063d53d1fa0a1f0f0bc0fe7eb0 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 7 Mar 2020 01:37:53 +0900 Subject: [PATCH 184/933] Drop openjdk12 on Travis CI Fixes gh-431 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 76074e2dbb..e835448918 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: java jdk: - openjdk-ea - openjdk13 - - openjdk12 - openjdk11 - openjdk8 From f9b954dd1ee0f0ff1a26ccfd69cf784fb24b1e5a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 7 Mar 2020 01:38:17 +0900 Subject: [PATCH 185/933] Support openjdk14 on Travis CI Fixes gh-450 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e835448918..d587f513cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: java jdk: - openjdk-ea + - openjdk14 - openjdk13 - openjdk11 - openjdk8 From ec91145620faa9d4d1eef02c3c594f894a4e0bd0 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 7 Mar 2020 01:45:29 +0900 Subject: [PATCH 186/933] Update to spring-framework 5.1.14.RELEASE on Travis CI Fixes gh-449 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d587f513cc..77d622b6df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ jdk: script: - ./mvnw clean verify - - ./mvnw clean verify -Dspring.version=5.1.12.RELEASE -Dspring-batch.version=4.1.3.RELEASE + - ./mvnw clean verify -Dspring.version=5.1.14.RELEASE -Dspring-batch.version=4.1.3.RELEASE after_success: - chmod -R 777 ./travis/after_success.sh From 7b543476c8055e59b0628d8852af1900ef9c9ef5 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Mon, 9 Mar 2020 01:07:07 +0900 Subject: [PATCH 187/933] License header and format --- pom.xml | 2 +- .../mybatis/spring/SqlSessionFactoryBean.java | 2 +- .../mybatis/spring/annotation/MapperScan.java | 10 +++++----- .../annotation/MapperScannerRegistrar.java | 11 ++++++---- ...pConfigWithDefaultMapperScanAndRepeat.java | 15 ++++++++++++++ .../ds1/AppConfigWithDefaultMapperScans.java | 20 +++++++++++++++---- .../AppConfigWithDefaultPackageScan.java | 15 ++++++++++++++ .../org/mybatis/spring/scan/package-info.java | 2 +- .../org/mybatis/spring/type/package-info.java | 2 +- 9 files changed, 62 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 8b6945b27d..351441e89e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 0.8.4 From bd48f0a7759348d006566844f1fc109b2c0f12ac Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2020 06:56:52 +0000 Subject: [PATCH 203/933] Bump spring.version from 5.2.4.RELEASE to 5.2.5.RELEASE Bumps `spring.version` from 5.2.4.RELEASE to 5.2.5.RELEASE. Updates `spring-context` from 5.2.4.RELEASE to 5.2.5.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.4.RELEASE...v5.2.5.RELEASE) Updates `spring-jdbc` from 5.2.4.RELEASE to 5.2.5.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.4.RELEASE...v5.2.5.RELEASE) Updates `spring-test` from 5.2.4.RELEASE to 5.2.5.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.4.RELEASE...v5.2.5.RELEASE) Updates `spring-web` from 5.2.4.RELEASE to 5.2.5.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.4.RELEASE...v5.2.5.RELEASE) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e614644bc9..52ccd02e35 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.4 - 5.2.4.RELEASE + 5.2.5.RELEASE 4.2.1.RELEASE org.mybatis.spring From 9f5d65c686889096240e40f47c9f119066faed78 Mon Sep 17 00:00:00 2001 From: Kihwan Kim Date: Tue, 31 Mar 2020 13:56:38 +0900 Subject: [PATCH 204/933] correct a mistranslation. --- src/site/ko/xdoc/mappers.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml index 08abb2e8de..8dda92e451 100644 --- a/src/site/ko/xdoc/mappers.xml +++ b/src/site/ko/xdoc/mappers.xml @@ -29,7 +29,7 @@

    -

    데이터 접근 객체인 DAO를 만든것보다 직접 SqlSessionDaoSupportSqlSessionTemplate 를 사용하자. +

    SqlSessionDaoSupportSqlSessionTemplate 를 직접적으로 사용하는 데이터 접근 객체(DAO)를 생성하기 보다, 마이바티스 스프링 연동모듈은 다른 빈에 직접 주입할 수 있는 쓰레드에 안전한 매퍼를 생성할 수 있다.

    From 51dadd4962b41a6a60a625fe270116b5e16f02e3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2020 06:54:47 +0000 Subject: [PATCH 205/933] Bump spring-batch.version from 4.2.1.RELEASE to 4.2.2.RELEASE Bumps `spring-batch.version` from 4.2.1.RELEASE to 4.2.2.RELEASE. Updates `spring-batch-infrastructure` from 4.2.1.RELEASE to 4.2.2.RELEASE - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.2.1.RELEASE...4.2.2.RELEASE) Updates `spring-batch-core` from 4.2.1.RELEASE to 4.2.2.RELEASE - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.2.1.RELEASE...4.2.2.RELEASE) Updates `spring-batch-test` from 4.2.1.RELEASE to 4.2.2.RELEASE - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.2.1.RELEASE...4.2.2.RELEASE) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 52ccd02e35..6bfa1232e2 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.4 5.2.5.RELEASE - 4.2.1.RELEASE + 4.2.2.RELEASE org.mybatis.spring 5.6.1 From c421a611870177a9a90b896a2fcfbd763d8cec24 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2020 06:59:45 +0000 Subject: [PATCH 206/933] Bump spring.version from 5.2.5.RELEASE to 5.2.6.RELEASE Bumps `spring.version` from 5.2.5.RELEASE to 5.2.6.RELEASE. Updates `spring-context` from 5.2.5.RELEASE to 5.2.6.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.5.RELEASE...v5.2.6.RELEASE) Updates `spring-jdbc` from 5.2.5.RELEASE to 5.2.6.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.5.RELEASE...v5.2.6.RELEASE) Updates `spring-test` from 5.2.5.RELEASE to 5.2.6.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.5.RELEASE...v5.2.6.RELEASE) Updates `spring-web` from 5.2.5.RELEASE to 5.2.6.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.5.RELEASE...v5.2.6.RELEASE) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6bfa1232e2..6c994bf27e 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.4 - 5.2.5.RELEASE + 5.2.6.RELEASE 4.2.2.RELEASE org.mybatis.spring From 853678c591d18c16249ac545cdfca8f9ade79e1c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 6 May 2020 06:54:47 +0000 Subject: [PATCH 207/933] Bump assertj-core from 3.15.0 to 3.16.0 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.15.0 to 3.16.0. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.15.0...assertj-core-3.16.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c994bf27e..c6ba46fc11 100644 --- a/pom.xml +++ b/pom.xml @@ -233,7 +233,7 @@ org.assertj assertj-core - 3.15.0 + 3.16.0 test From a18fccd390a506a422d91c1356d70b98c1188555 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 11 May 2020 07:20:11 +0000 Subject: [PATCH 208/933] Bump assertj-core from 3.16.0 to 3.16.1 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.16.0 to 3.16.1. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.16.0...assertj-core-3.16.1) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6ba46fc11..680d671972 100644 --- a/pom.xml +++ b/pom.xml @@ -233,7 +233,7 @@ org.assertj assertj-core - 3.16.0 + 3.16.1 test From 9a52735f1c3d41b51bcab0c3ee538b5f630e1d72 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 17 May 2020 12:46:09 +0900 Subject: [PATCH 209/933] Prevent build error of maven-bundle-pluin on JDK 15 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 77d622b6df..2036f1ce50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ jdk: - openjdk11 - openjdk8 +jobs: + allow_failures: + - jdk: openjdk-ea + script: - ./mvnw clean verify - ./mvnw clean verify -Dspring.version=5.1.14.RELEASE -Dspring-batch.version=4.1.3.RELEASE From 5deee32a2d8113794797dd364fb7cc2a8afd0cb5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 17 May 2020 03:52:43 +0000 Subject: [PATCH 210/933] Bump junit-jupiter-engine from 5.6.1 to 5.6.2 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.6.1 to 5.6.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.6.1...r5.6.2) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 680d671972..4a03cff574 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.2.2.RELEASE org.mybatis.spring - 5.6.1 + 5.6.2 0.8.4 From a15f145a2a4ffe92a224c9efa7f557cc767a0b24 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 17 May 2020 13:34:49 +0900 Subject: [PATCH 211/933] Add comment for preventing fail maven-bundle-plugin on JDK 15 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2036f1ce50..a4e80eaa96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ jdk: jobs: allow_failures: + # Fail maven-bundle-plugin on JDK 15 (https://issues.apache.org/jira/browse/FELIX-6259,https://github.com/mybatis/parent/issues/160) - jdk: openjdk-ea script: From a01d1953604cca224727baea5557b952bbc2b122 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 5 Jun 2020 04:06:49 +0900 Subject: [PATCH 212/933] Update license year --- src/site/ko/xdoc/mappers.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml index 8dda92e451..a6152928c9 100644 --- a/src/site/ko/xdoc/mappers.xml +++ b/src/site/ko/xdoc/mappers.xml @@ -1,7 +1,7 @@ - 0.8.4 @@ -359,4 +357,12 @@ + + + sonatype-oss-snapshots + Sonatype OSS Snapshots Repository + https://oss.sonatype.org/content/repositories/snapshots + + + From bf3d14794e25a79a59cc45ec62f1f93d2f5b63ec Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 13 Jun 2020 18:42:51 +0900 Subject: [PATCH 222/933] Apply latest version of Spring 5.1.x and Spring Batch 4.1.x automatically on Travis CI --- .travis.yml | 2 +- travis/get_latest_version.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 travis/get_latest_version.sh diff --git a/.travis.yml b/.travis.yml index 4f9073985f..d8110f766a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ jdk: script: - ./mvnw clean verify - - ./mvnw clean verify -Dspring.version=5.1.15.RELEASE -Dspring-batch.version=4.1.4.RELEASE + - ./mvnw clean verify -Dspring.version=$(./travis/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./travis/get_latest_version.sh batch/spring-batch-core 4.1) after_success: - chmod -R 777 ./travis/after_success.sh diff --git a/travis/get_latest_version.sh b/travis/get_latest_version.sh new file mode 100755 index 0000000000..608eaa42a5 --- /dev/null +++ b/travis/get_latest_version.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Copyright 2010-2020 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +targetArtifact=$1 +targetMinorVersion=$2 +majorVersion=${targetMinorVersion%.*} +minorVersion=${targetMinorVersion#*.} +while read -r line; do + maintenanceVersion=${line#${targetMinorVersion}.} && maintenanceVersion=${maintenanceVersion%%.*} + maintenanceVersions="${maintenanceVersions}${maintenanceVersion}"$'\n' +done<${majorVersion}\.${minorVersion}\.[0-9]*") +END +echo "${targetMinorVersion}.$(echo "${maintenanceVersions}" | sort -n | tail -n 1).RELEASE" From 374a62eb5063a3dd5e6dcaeafdbe402366a65909 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 21 Jun 2020 14:05:05 +0900 Subject: [PATCH 223/933] Support scoped proxy on mapper scan feature Fixes gh-476 --- .../mybatis/spring/annotation/MapperScan.java | 18 +++- .../annotation/MapperScannerRegistrar.java | 10 ++- .../MapperScannerBeanDefinitionParser.java | 12 +-- .../spring/mapper/ClassPathMapperScanner.java | 65 ++++++++++++-- .../mapper/MapperScannerConfigurer.java | 21 +++++ .../mybatis/spring/config/mybatis-spring.xsd | 11 ++- .../spring/annotation/MapperScanTest.java | 50 ++++++++++- .../annotation/mapper/ds1/Ds1Mapper.java | 5 +- .../annotation/mapper/ds2/Ds2Mapper.java | 8 +- .../mybatis/spring/config/NamespaceTest.java | 58 +++++++++++-- .../spring/config/default-scope.properties | 17 ++++ .../mybatis/spring/config/default-scope.xml | 39 +++++++++ .../spring/mapper/AnnotatedMapper.java | 7 +- .../mapper/MapperScannerConfigurerTest.java | 87 ++++++++++++++++++- .../spring/mapper/ScopedProxyMapper.java | 28 ++++++ 15 files changed, 401 insertions(+), 35 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/config/default-scope.properties create mode 100644 src/test/java/org/mybatis/spring/config/default-scope.xml create mode 100644 src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index 2d8e7d1c3e..ebeed88007 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -25,13 +25,14 @@ import org.mybatis.spring.mapper.MapperFactoryBean; import org.mybatis.spring.mapper.MapperScannerConfigurer; +import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.context.annotation.Import; /** * Use this annotation to register MyBatis mapper interfaces when using Java Config. It performs when same work as * {@link MapperScannerConfigurer} via {@link MapperScannerRegistrar}. - * + * *

    * Either {@link #basePackageClasses} or {@link #basePackages} (or its alias {@link #value}) may be specified to define * specific packages to scan. Since 2.0.4, If specific packages are not defined, scanning will occur from the package of @@ -40,7 +41,7 @@ *

    * Configuration example: *

    - * + * *
      * @Configuration
      * @MapperScan("org.mybatis.spring.sample.mapper")
    @@ -165,10 +166,21 @@
        * 

    * Default is {@code false}. *

    - * + * * @return set {@code true} to enable lazy initialization * @since 2.0.2 */ String lazyInitialization() default ""; + /** + * Specifies the default scope of scanned mappers. + * + *

    + * Default is {@code ""} (equiv to singleton). + *

    + * + * @return the default scope + */ + String defaultScope() default AbstractBeanDefinition.SCOPE_DEFAULT; + } diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index aaf9ceb8d0..6c6d925246 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -25,6 +25,7 @@ import org.mybatis.spring.mapper.MapperFactoryBean; import org.mybatis.spring.mapper.MapperScannerConfigurer; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; @@ -53,7 +54,7 @@ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, Re /** * {@inheritDoc} - * + * * @deprecated Since 2.0.2, this method not used never. */ @Override @@ -130,6 +131,11 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a builder.addPropertyValue("lazyInitialization", lazyInitialization); } + String defaultScope = annoAttrs.getString("defaultScope"); + if (!AbstractBeanDefinition.SCOPE_DEFAULT.equals(defaultScope)) { + builder.addPropertyValue("defaultScope", defaultScope); + } + builder.addPropertyValue("basePackage", StringUtils.collectionToCommaDelimitedString(basePackages)); registry.registerBeanDefinition(beanName, builder.getBeanDefinition()); @@ -146,7 +152,7 @@ private static String getDefaultBasePackage(AnnotationMetadata importingClassMet /** * A {@link MapperScannerRegistrar} for {@link MapperScans}. - * + * * @since 2.0.0 */ static class RepeatingRegistrar extends MapperScannerRegistrar { diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index ad775e21c2..004afb67f9 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2019 the original author or authors. + * Copyright 2010-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ import java.lang.annotation.Annotation; -import org.mybatis.spring.mapper.MapperFactoryBean; import org.mybatis.spring.mapper.ClassPathMapperScanner; +import org.mybatis.spring.mapper.MapperFactoryBean; import org.mybatis.spring.mapper.MapperScannerConfigurer; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.support.AbstractBeanDefinition; @@ -33,7 +33,7 @@ /** * A {#code BeanDefinitionParser} that handles the element scan of the MyBatis. namespace - * + * * @author Lishu Luo * @author Eduardo Macarron * @@ -53,10 +53,11 @@ public class MapperScannerBeanDefinitionParser extends AbstractBeanDefinitionPar private static final String ATTRIBUTE_FACTORY_REF = "factory-ref"; private static final String ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS = "mapper-factory-bean-class"; private static final String ATTRIBUTE_LAZY_INITIALIZATION = "lazy-initialization"; + private static final String ATTRIBUTE_DEFAULT_SCOPE = "default-scope"; /** * {@inheritDoc} - * + * * @since 2.0.2 */ @Override @@ -100,6 +101,7 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa builder.addPropertyValue("sqlSessionTemplateBeanName", element.getAttribute(ATTRIBUTE_TEMPLATE_REF)); builder.addPropertyValue("sqlSessionFactoryBeanName", element.getAttribute(ATTRIBUTE_FACTORY_REF)); builder.addPropertyValue("lazyInitialization", element.getAttribute(ATTRIBUTE_LAZY_INITIALIZATION)); + builder.addPropertyValue("defaultScope", element.getAttribute(ATTRIBUTE_DEFAULT_SCOPE)); builder.addPropertyValue("basePackage", element.getAttribute(ATTRIBUTE_BASE_PACKAGE)); return builder.getBeanDefinition(); @@ -107,7 +109,7 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa /** * {@inheritDoc} - * + * * @since 2.0.2 */ @Override diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 05ba5a0bef..983b36ae20 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2019 the original author or authors. + * Copyright 2010-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,26 +15,30 @@ */ package org.mybatis.spring.mapper; +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.Optional; +import java.util.Set; + import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.logging.Logger; import org.mybatis.logging.LoggerFactory; import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.aop.scope.ScopedProxyFactoryBean; +import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.GenericBeanDefinition; +import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.util.StringUtils; -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Set; - /** * A {@link ClassPathBeanDefinitionScanner} that registers Mappers by {@code basePackage}, {@code annotationClass}, or * {@code markerInterface}. If an {@code annotationClass} and/or {@code markerInterface} is specified, only the @@ -45,7 +49,7 @@ * * @author Hunter Presnall * @author Eduardo Macarron - * + * * @see MapperFactoryBean * @since 1.2.0 */ @@ -71,6 +75,8 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { private Class mapperFactoryBeanClass = MapperFactoryBean.class; + private String defaultScope; + public ClassPathMapperScanner(BeanDefinitionRegistry registry) { super(registry, false); } @@ -136,6 +142,20 @@ public void setMapperFactoryBeanClass(Class mapperF this.mapperFactoryBeanClass = mapperFactoryBeanClass == null ? MapperFactoryBean.class : mapperFactoryBeanClass; } + /** + * Set the default scope of scanned mappers. + *

    + * Default is {@code null} (equiv to singleton). + *

    + * + * @param defaultScope + * the scope + * @since 2.0.6 + */ + public void setDefaultScope(String defaultScope) { + this.defaultScope = defaultScope; + } + /** * Configures parent scanner to search for the right interfaces. It can search for all interfaces or just for those * that extends a markerInterface or/and those annotated with the annotationClass @@ -191,9 +211,18 @@ public Set doScan(String... basePackages) { } private void processBeanDefinitions(Set beanDefinitions) { - GenericBeanDefinition definition; + AbstractBeanDefinition definition; + BeanDefinitionRegistry registry = getRegistry(); for (BeanDefinitionHolder holder : beanDefinitions) { - definition = (GenericBeanDefinition) holder.getBeanDefinition(); + definition = (AbstractBeanDefinition) holder.getBeanDefinition(); + boolean scopedProxy = false; + if (ScopedProxyFactoryBean.class.getName().equals(definition.getBeanClassName())) { + definition = (AbstractBeanDefinition) Optional + .ofNullable(((RootBeanDefinition) definition).getDecoratedDefinition()) + .map(BeanDefinitionHolder::getBeanDefinition).orElseThrow(() -> new IllegalStateException( + "The target bean definition of scoped proxy bean not found. Root bean definition[" + holder + "]")); + scopedProxy = true; + } String beanClassName = definition.getBeanClassName(); LOGGER.debug(() -> "Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + beanClassName + "' mapperInterface"); @@ -236,7 +265,25 @@ private void processBeanDefinitions(Set beanDefinitions) { LOGGER.debug(() -> "Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'."); definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); } + definition.setLazyInit(lazyInitialization); + + if (scopedProxy) { + continue; + } + + if (ConfigurableBeanFactory.SCOPE_SINGLETON.equals(definition.getScope()) && defaultScope != null) { + definition.setScope(defaultScope); + } + + if (!definition.isSingleton()) { + BeanDefinitionHolder proxyHolder = ScopedProxyUtils.createScopedProxy(holder, registry, true); + if (registry.containsBeanDefinition(proxyHolder.getBeanName())) { + registry.removeBeanDefinition(proxyHolder.getBeanName()); + } + registry.registerBeanDefinition(proxyHolder.getBeanName(), proxyHolder.getBeanDefinition()); + } + } } diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 1369856dad..578db89da0 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -119,6 +119,8 @@ public class MapperScannerConfigurer private BeanNameGenerator nameGenerator; + private String defaultScope; + /** * This property lets you set the base package for your mapper interface files. *

    @@ -311,6 +313,20 @@ public void setNameGenerator(BeanNameGenerator nameGenerator) { this.nameGenerator = nameGenerator; } + /** + * Sets the default scope of scanned mappers. + *

    + * Default is {@code null} (equiv to singleton). + *

    + * + * @param defaultScope + * the default scope + * @since 2.0.6 + */ + public void setDefaultScope(String defaultScope) { + this.defaultScope = defaultScope; + } + /** * {@inheritDoc} */ @@ -352,6 +368,9 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { if (StringUtils.hasText(lazyInitialization)) { scanner.setLazyInitialization(Boolean.valueOf(lazyInitialization)); } + if (StringUtils.hasText(defaultScope)) { + scanner.setDefaultScope(defaultScope); + } scanner.registerFilters(); scanner.scan( StringUtils.tokenizeToStringArray(this.basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS)); @@ -387,6 +406,7 @@ private void processPropertyPlaceHolders() { this.sqlSessionFactoryBeanName = updatePropertyValue("sqlSessionFactoryBeanName", values); this.sqlSessionTemplateBeanName = updatePropertyValue("sqlSessionTemplateBeanName", values); this.lazyInitialization = updatePropertyValue("lazyInitialization", values); + this.defaultScope = updatePropertyValue("defaultScope", values); } this.basePackage = Optional.ofNullable(this.basePackage).map(getEnvironment()::resolvePlaceholders).orElse(null); this.sqlSessionFactoryBeanName = Optional.ofNullable(this.sqlSessionFactoryBeanName) @@ -395,6 +415,7 @@ private void processPropertyPlaceHolders() { .map(getEnvironment()::resolvePlaceholders).orElse(null); this.lazyInitialization = Optional.ofNullable(this.lazyInitialization).map(getEnvironment()::resolvePlaceholders) .orElse(null); + this.defaultScope = Optional.ofNullable(this.defaultScope).map(getEnvironment()::resolvePlaceholders).orElse(null); } private Environment getEnvironment() { diff --git a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd index fcd5843065..a15e5f7cc7 100644 --- a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd +++ b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java b/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java index b823b19734..03aedce06b 100644 --- a/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java +++ b/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2019 the original author or authors. + * Copyright 2010-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,4 +22,9 @@ @Component public interface AnnotatedMapper { void method(); + + default String test() { + return Thread.currentThread().getName(); + } + } diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index 393cd4c1f5..05e453aa2e 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2019 the original author or authors. + * Copyright 2010-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import com.mockrunner.mock.jdbc.MockDataSource; + +import java.util.List; import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSessionFactory; import org.junit.jupiter.api.AfterEach; @@ -39,10 +45,9 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.context.support.SimpleThreadScope; import org.springframework.stereotype.Component; -import com.mockrunner.mock.jdbc.MockDataSource; - class MapperScannerConfigurerTest { private GenericApplicationContext applicationContext; @@ -57,6 +62,7 @@ void setupContext() { definition.setBeanClass(MapperScannerConfigurer.class); definition.getPropertyValues().add("basePackage", "org.mybatis.spring.mapper"); applicationContext.registerBeanDefinition("mapperScanner", definition); + applicationContext.getBeanFactory().registerScope("thread", new SimpleThreadScope()); setupSqlSessionFactory("sqlSessionFactory"); @@ -99,6 +105,12 @@ void testInterfaceScan() { applicationContext.getBean("mapperSubinterface"); applicationContext.getBean("mapperChildInterface"); applicationContext.getBean("annotatedMapper"); + applicationContext.getBean("scopedProxyMapper"); + applicationContext.getBean("scopedTarget.scopedProxyMapper"); + + assertThat(Stream.of(applicationContext.getBeanDefinitionNames()).filter(x -> x.startsWith("scopedTarget"))) + .hasSize(1); + } @Test @@ -164,6 +176,75 @@ void testMarkerInterfaceAndAnnotationScan() { assertBeanNotLoaded("mapperInterface"); } + @Test + void testScopedProxyMapperScan() { + applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add("annotationClass", Mapper.class); + + startContext(); + { + BeanDefinition definition = applicationContext.getBeanDefinition("scopedProxyMapper"); + assertThat(definition.getBeanClassName()).isEqualTo("org.springframework.aop.scope.ScopedProxyFactoryBean"); + assertThat(definition.getScope()).isEqualTo(""); + } + { + BeanDefinition definition = applicationContext.getBeanDefinition("scopedTarget.scopedProxyMapper"); + assertThat(definition.getBeanClassName()).isEqualTo("org.mybatis.spring.mapper.MapperFactoryBean"); + assertThat(definition.getScope()).isEqualTo("thread"); + } + { + ScopedProxyMapper mapper = applicationContext.getBean(ScopedProxyMapper.class); + assertThat(mapper.test()).isEqualTo("test"); + } + { + ScopedProxyMapper mapper = applicationContext.getBean("scopedTarget.scopedProxyMapper", ScopedProxyMapper.class); + assertThat(mapper.test()).isEqualTo("test"); + } + { + ScopedProxyMapper mapper = applicationContext.getBean("scopedProxyMapper", ScopedProxyMapper.class); + assertThat(mapper.test()).isEqualTo("test"); + } + + SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + } + + @Test + void testScopedProxyMapperScanByDefault() { + applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add("defaultScope", "thread"); + + startContext(); + + List scopedProxyTargetBeans = Stream.of(applicationContext.getBeanDefinitionNames()) + .filter(x -> x.startsWith("scopedTarget")).collect(Collectors.toList()); + assertThat(scopedProxyTargetBeans).hasSize(6).contains("scopedTarget.scopedProxyMapper", + "scopedTarget.annotatedMapper", "scopedTarget.annotatedMapperZeroMethods", "scopedTarget.mapperInterface", + "scopedTarget.mapperSubinterface", "scopedTarget.mapperChildInterface"); + + for (String scopedProxyTargetBean : scopedProxyTargetBeans) { + { + BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean); + assertThat(definition.getBeanClassName()).isEqualTo("org.mybatis.spring.mapper.MapperFactoryBean"); + assertThat(definition.getScope()).isEqualTo("thread"); + } + { + BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean.substring(13)); + assertThat(definition.getBeanClassName()).isEqualTo("org.springframework.aop.scope.ScopedProxyFactoryBean"); + assertThat(definition.getScope()).isEqualTo(""); + } + } + { + ScopedProxyMapper mapper = applicationContext.getBean(ScopedProxyMapper.class); + assertThat(mapper.test()).isEqualTo("test"); + } + { + AnnotatedMapper mapper = applicationContext.getBean(AnnotatedMapper.class); + assertThat(mapper.test()).isEqualTo("main"); + } + + SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); + } + @Test void testScanWithExplicitSqlSessionFactory() { setupSqlSessionFactory("sqlSessionFactory2"); diff --git a/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java b/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java new file mode 100644 index 0000000000..8330d4143f --- /dev/null +++ b/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java @@ -0,0 +1,28 @@ +/** + * Copyright 2010-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.spring.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; + +@Mapper +@Scope(scopeName = "thread", proxyMode = ScopedProxyMode.TARGET_CLASS) +public interface ScopedProxyMapper { + default String test() { + return "test"; + } +} From c1b267dd0898663b9fc3fb3d769707fda0c58292 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 21 Jun 2020 16:32:45 +0900 Subject: [PATCH 224/933] Update documentation for gh-484 Related with gh-476 --- src/site/es/xdoc/mappers.xml | 73 ++++++++++++++++++-------------- src/site/ja/xdoc/mappers.xml | 45 ++++++++++++-------- src/site/ko/xdoc/mappers.xml | 81 ++++++++++++++++++++---------------- src/site/xdoc/mappers.xml | 79 +++++++++++++++++++---------------- src/site/zh/xdoc/mappers.xml | 9 ++++ 5 files changed, 166 insertions(+), 121 deletions(-) diff --git a/src/site/es/xdoc/mappers.xml b/src/site/es/xdoc/mappers.xml index de81624425..26f6b45683 100644 --- a/src/site/es/xdoc/mappers.xml +++ b/src/site/es/xdoc/mappers.xml @@ -1,7 +1,7 @@ @@ -182,15 +191,15 @@ public interface GoodsMapper {

    Fíjate que no es necesario indicar una SqlSessionFactory o SqlSessionTemplate porque el <mybatis:scan/> - creará MapperFactoryBeans que pueden ser autowired. Pero si usas más de un DataSource + creará MapperFactoryBeans que pueden ser autowired. Pero si usas más de un DataSource el autowire puede que no te funcione. En este caso puedes usar las propiedades factory-ref or template-ref para indicar los beans correctos a utilizar.

    - +

    <mybatis:scan/> soporta el filtrado de mappers mediante una interfaz marcador o una anotación. La propiedad annotation especifica la anotación que se debe buscar. - La propiedad marker-interface especifica la interfaz a buscar. + La propiedad marker-interface especifica la interfaz a buscar. Si se indican ambas se añadirán todos los mappers que cumplan cualquier criterio. Por defecto ambas propiedades son null asi que todos los interfaces de los paquetes base serán cargados como mappers.

    @@ -206,31 +215,31 @@ public interface GoodsMapper {

    - NOTE <context:component-scan/> + NOTE <context:component-scan/> no puede encontrar y registrar mappers. Los mappers son interfaces y, para poderlos registrar en Spring, el scanner deben conocer cómo crear un MapperFactoryBean para cada interfaz encontrado.

    @MapperScan

    - +

    - Si usas la Java Configuration de Spring (@Configuration) posiblemente prefieras usar - @MapperScan en lugar de <mybatis:scan/>. + Si usas la Java Configuration de Spring (@Configuration) posiblemente prefieras usar + @MapperScan en lugar de <mybatis:scan/>.

    - +

    La anotación @MapperScan se usa de la siguiente forma:

    - + - +

    La anotación fucniona exactamente igual que <mybatis:scan/> que hemos visto en la sección anterior. - También te permite especificar un interfaz marcador o una anotación mediante sus propiedades - markerInterface y annotationClass. + También te permite especificar un interfaz marcador o una anotación mediante sus propiedades + markerInterface y annotationClass. Tambien puedes indicar una SqlSessionFactory o un SqlSessionTemplate específicos mediante las propiedades sqlSessionFactory y sqlSessionTemplate.

    @@ -240,9 +249,9 @@ public class AppConfig {

    MapperScannerConfigurer

    - +

    - MapperScannerConfigurer es un BeanDefinitionRegistryPostProcessor + MapperScannerConfigurer es un BeanDefinitionRegistryPostProcessor que se puede incluir como un bean normal en el fichero clásico XML de configuración de Spring. Para configurar un MapperScannerConfigurer añade lo siguiente al fichero de configuración de Spring:

    @@ -256,7 +265,7 @@ public class AppConfig { por ello se usa el atributo value en lugar del habitual ref:

    ]]> - +
    diff --git a/src/site/ja/xdoc/mappers.xml b/src/site/ja/xdoc/mappers.xml index d477515352..bf6f8dc134 100644 --- a/src/site/ja/xdoc/mappers.xml +++ b/src/site/ja/xdoc/mappers.xml @@ -24,7 +24,7 @@ MyBatis-Spring | Mapper をインジェクト(注入)する Hunter Presnall Eduardo Macarron - Iwao AVE! + Iwao AVE! @@ -37,7 +37,7 @@ ]]> - +

    アプリケーション側の処理では、注入された Mapper のメソッドを呼び出すだけです。

    @@ -61,9 +61,9 @@

    Mapper を Bean として登録する方法は、Spring の設定を XML ファイルを使って行う場合と Spring 3.0 以降で導入された Java Config (= @Configuration) を使う場合で異なります。

    - +

    XML で設定する場合

    - +

    XML ファイルを使って Spring を設定する場合、次のように MapperFactoryBean のエントリーを追加することで Mapper を Spring Bean として登録することができます。

    @@ -83,9 +83,9 @@ 指定対象のプロパティは、それぞれ sqlSessionFactorysqlSessionTemplate です。 両方が指定された場合、 SqlSessionFactory の指定は無視され、SqlSessionTemplate の登録時に指定した Session Factory が使われます。

    - +

    Java Config で設定する場合

    - + userMapper() throws Exception { @@ -98,9 +98,9 @@ public MapperFactoryBean userMapper() throws Exception {

    - 上で説明した方法では Mapper を個別に指定していましたが、MyBatis-Spring では特定のクラスパスに含まれる Mapper を自動検出させることもできます。 + 上で説明した方法では Mapper を個別に指定していましたが、MyBatis-Spring では特定のクラスパスに含まれる Mapper を自動検出させることもできます。

    - +

    これには3通りの方法があります。

    @@ -109,7 +109,7 @@ public MapperFactoryBean userMapper() throws Exception {
  • @MapperScan アノテーションを使う。
  • Spring の XML 設定ファイルに MapperScannerConfigurer のエントリーを追加する。
  • - +

    <mybatis:scan/> または @MapperScan を使う場合は MyBatis-Spring 1.2.0 以降が必要です。また @MapperScan を使う場合は Spring 3.1 以降が必要となります。

    @@ -139,12 +139,21 @@ public interface GoodsMapper { // ... }]]> +

    + 2.0.6以降では、開発者はMapper BeanのスコープをMapperの自動検出機能のオプション(default-scope) + とスコープを指定するアノテーション(@Scope@RefreshScope など)を使用して指定することができるようになります。 + このオプションを追加する動機は、Spring Cloudから提供されている refresh スコープをサポートすることです。 + このオプションのデフォルトは空(singletonスコープを指定するのと同等)です。 + default-scope オプションで指定した値は、スキャンしたMapperのBean定義に指定されているスコープが singleton の際に適用され、 + 最終的なMapperのスコープが singleton でない場合はScoped ProxyのBeanを作成します。 +

    +

    <mybatis:scan/>

    - +

    <mybatis:scan/> は、Spring の <context:component-scan/> が Bean を検索するのと良く似た方法で Mapper を検出します。

    - +

    XML 設定の例:

    - + @@ -192,20 +201,20 @@ public interface GoodsMapper {

    @MapperScan

    - +

    Java Config を使って Spring を設定しているのなら、<mybatis:scan/> よりも @MapperScan を使う方が気に入ると思います。

    - +

    @MapperScan アノテーションは次のように使用します。

    - + - +

    このアノテーションは前章で説明した <mybatis:scan/> と全く同じ要領で Mapper の検出を行います。 引数 markerInterface, annotationClass を使えば検出対象のマーカーインターフェイスとアノテーションを指定することもできますし、sqlSessionFactory, sqlSessionTemplateSqlSessionFactorySqlSessionTemplate を指定することができます。 @@ -216,7 +225,7 @@ public class AppConfig {

    MapperScannerConfigurer

    - +

    MapperScannerConfigurerBeanDefinitionRegistryPostProcessor として定義されているので、従来の XML による設定で通常の Bean として登録することができます。 MapperScannerConfigurer の登録は次のように行います。 @@ -229,7 +238,7 @@ public class AppConfig { 特定の sqlSessionFactory または sqlSessionTemplate を指定する場合は、 Bean を参照ではなく 名前で 指定する必要があるので、ref ではなく value を使います。

    ]]> - +

    NOTE MyBatis-Spring 1.0.2 までは有効なプロパティは sqlSessionFactoryBeansqlSessionTemplateBean のみでしたが、 MapperScannerConfigurerPropertyPlaceholderConfigurer よりも先に読み込まれるためエラーの原因となっていました。 この問題を回避するため、これらのプロパティの使用は非推奨となり、新たに追加された sqlSessionFactoryBeanNamesqlSessionTemplateBeanName を使うことが推奨されています。 diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml index a6152928c9..32296b7086 100644 --- a/src/site/ko/xdoc/mappers.xml +++ b/src/site/ko/xdoc/mappers.xml @@ -35,7 +35,7 @@ ]]> - +

    한번 주입하고나면 매퍼는 애플리케이션 로직에서 사용할수 있는 준비가 된다.

    -

    이 코드를 보면 SqlSession이나 마이바티스 객체가 보이지 않는다. - 게다가 세션을 생성하거나 열고 닫을필요도 없어보인다. +

    이 코드를 보면 SqlSession이나 마이바티스 객체가 보이지 않는다. + 게다가 세션을 생성하거나 열고 닫을필요도 없어보인다. 마이바티스 스프링 연동모듈이 알아서 처리할 것이다.

    매퍼를 등록하는 방법은 기존의 전통적인 XML설정법을 사용하거나 새로운 3.0 이후의 자바설정(일명 @Configuration)을 사용하느냐에 따라 다르다.

    - +

    XML설정 사용

    - +

    매퍼는 다음처럼 XML설정파일에 MapperFactoryBean을 두는 것으로 스프링에 등록된다.

    @@ -68,13 +68,13 @@ 매퍼 XML파일을 다른 클래스패스에 두는게 아니라면 마이바티스 설정파일에 매퍼를 지정할 필요가 없다. 좀더 세부적인 정보는 SqlSessionFactoryBeanconfigLocation 프로퍼티를 살펴보자.

    -

    MapperFactoryBeanSqlSessionFactorySqlSessionTemplate가 필요하다. - sqlSessionFactorysqlSessionTemplate 프로퍼티를 셋팅하면 된다. - 둘다 셋팅하면 SqlSessionFactory가 무시된다. +

    MapperFactoryBeanSqlSessionFactorySqlSessionTemplate가 필요하다. + sqlSessionFactorysqlSessionTemplate 프로퍼티를 셋팅하면 된다. + 둘다 셋팅하면 SqlSessionFactory가 무시된다. 세션 팩토리 셋은 SqlSessionTemplate이 필요하고 MapperFactoryBean는 팩토리를 사용할것이다.

    - +

    자바설정 사용

    - + userMapper() throws Exception { @@ -86,17 +86,17 @@ public MapperFactoryBean userMapper() throws Exception {
    -

    하나씩 매퍼를 모두 등록할 필요가 없다. +

    하나씩 매퍼를 모두 등록할 필요가 없다. 대신 클래스패스를 지정해서 마이바티스 스프링 연동모듈의 자동스캔기능을 사용할 수 있다.

    - +

    자동스캔을 사용하는데는 3가지 방법이 있다.

    • <mybatis:scan/> 엘리먼트 사용
    • @MapperScan 애노테이션 사용
    • 스프링 XML파일을 사용해서 MapperScannerConfigurer를 등록
    - -

    <mybatis:scan/>@MapperScan 모두 마이바티스 스프링 연동모듈 1.2.0에서 추가된 기능이다. + +

    <mybatis:scan/>@MapperScan 모두 마이바티스 스프링 연동모듈 1.2.0에서 추가된 기능이다. @MapperScan 은 스프링 버전이 3.1이상이어야 한다.

    @@ -127,10 +127,19 @@ public interface GoodsMapper { // ... }]]> +

    + Since 2.0.6, the develop become can specified scope of mapper using mapper scanning feature option(default-scope) + and scope annotation(@Scope, @RefreshScope, etc ...). + The motivation for adding this option is supporting the refresh scope provided by the Spring Cloud. + The default of this option is empty (= equiv to specify the singleton scope). + The default-scope apply to the mapper bean(MapperFactoryBean) when scope of scanned bean definition + is singleton(default scope) and create a scoped proxy bean for scanned mapper when final scope is not singleton. +

    +

    <mybatis:scan/>

    - +

    <mybatis:scan/> XML엘리먼트는 스프링에서 제공하는 <context:component-scan/> 엘리먼트와 매우 유사한 방법으로 매퍼를 검색할 것이다.

    - +

    샘플 XML설정을 아래에서 볼수 있다.

    - + ]]> -

    base-package 속성은 매퍼 인터페이스 파일이 있는 가장 상위 패키지를 지정하면 된다. - 세미콜론이나 콤마를 구분자로 사용해서 한개 이상의 패키지를 셋팅할 수 있다. +

    base-package 속성은 매퍼 인터페이스 파일이 있는 가장 상위 패키지를 지정하면 된다. + 세미콜론이나 콤마를 구분자로 사용해서 한개 이상의 패키지를 셋팅할 수 있다. 매퍼는 지정된 패키지에서 재귀적으로 하위 패키지를 모두 검색할 것이다.

    -

    <mybatis:scan/>이 자동으로 주입할 수 있는 MapperFactoryBean를 생성하기 때문에 +

    <mybatis:scan/>이 자동으로 주입할 수 있는 MapperFactoryBean를 생성하기 때문에 SqlSessionFactorySqlSessionTemplate 를 명시할 필요가 없다. 하지만 한개 이상의 DataSource를 사용한다면 자동주입이 생각한데로 동작하지 않을수도 있다. 이 경우 사용할 빈 이름을 지정하기 위해 factory-reftemplate-ref 속성을 사용할수 있다.

    <mybatis:scan/>은 마커(marker) 인터페이스나 애노테이션을 명시해서 생성되는 매퍼를 필터링할수도 있다. - annotation 프로퍼티는 검색할 애노테이션을 지정한다. + annotation 프로퍼티는 검색할 애노테이션을 지정한다. marker-interface 프로퍼티는 검색할 상위 인터페이스를 지정한다. 이 두개의 프로퍼티를 모두 지정하면, 매퍼는 두 조건을 모두 만족하는 인터페이스만을 추가한다. - 디폴트로 이 두가지 프로퍼티는 모두 null이다. + 디폴트로 이 두가지 프로퍼티는 모두 null이다. 그래서 base-package프로퍼티에 설정된 패키지 아래 모든 인터페이스가 매퍼로 로드될 것이다.

    발견된 매퍼는 자동검색된 컴포넌트를 위한 스프링의 디폴트 명명규칙 전략(see the Spring reference document(Core Technologies -Naming autodetected components-))을 사용해서 빈이름이 명명된다. 빈 이름을 정하는 애노테이션이 없다면 매퍼의 이름에서 첫글자를 소문자로 변환한 형태로 빈 이름을 사용할 것이다. - @Component 나 JSR-330의 @Named 애노테이션이 있다면 애노테이션에 정의한 이름을 그대로 사용할 것이다. - annotation 프로퍼티를 org.springframework.stereotype.Component, + @Component 나 JSR-330의 @Named 애노테이션이 있다면 애노테이션에 정의한 이름을 그대로 사용할 것이다. + annotation 프로퍼티를 org.springframework.stereotype.Component, javax.inject.Named(자바SE 1.6을 사용한다면) 또는 개발자가 스스로 작성한 애노테이션으로 셋팅할 수 있다. 그러면 애노테이션은 마커와 이름을 제공하는 역할로 동작할 것이다.

    - 중요 <context:component-scan/> 가 매퍼를 검색해서 등록을 하지 못할수도 있다. + 중요 <context:component-scan/> 가 매퍼를 검색해서 등록을 하지 못할수도 있다. 매퍼는 인터페이스고 스프링에 빈으로 등록하기 위해서는 각각의 인터페이스를 찾기 위해 스캐너가 MapperFactoryBean 를 생성하는 방법을 알아야만 한다.

    @MapperScan

    - -

    @Configuration 라고 불리는 스프링의 자바설정을 사용한다면 <mybatis:scan/>보다는 + +

    @Configuration 라고 불리는 스프링의 자바설정을 사용한다면 <mybatis:scan/>보다는 @MapperScan를 사용하길 선호할것이다.

    - +

    @MapperScan 애노테이션은 다음처럼 사용된다.

    - + - +

    애노테이션은 앞서 본 <mybatis:scan/> 에서 설명하는 것과 동일하게 동작한다. markerInterfaceannotationClass 프로퍼티를 사용해서 마커 인터페이스와 애노테이션 클래스를 명시하게 한다. - sqlSessionFactorysqlSessionTemplate 프로퍼티를 사용해서 + sqlSessionFactorysqlSessionTemplate 프로퍼티를 사용해서 SqlSessionFactorySqlSessionTemplate을 제공할 수도 있다.

    @@ -197,19 +206,19 @@ public class AppConfig {

    MapperScannerConfigurer

    - +

    MapperScannerConfigurer는 평범한 빈처럼 XML애플리케이션 컨텍스트에 포함된 BeanDefinitionRegistryPostProcessor 이다. MapperScannerConfigurer를 셋업하기 위해 다음의 스프링 설정을 추가하자.

    ]]> -

    sqlSessionFactorysqlSessionTemplate를 지정할 필요가 있다면 빈참조가 아닌 빈이름이 필요하다. +

    sqlSessionFactorysqlSessionTemplate를 지정할 필요가 있다면 빈참조가 아닌 빈이름이 필요하다. value 프로퍼티는 빈 이름을 지정하고 ref 는 빈 참조를 지정하기 때문에 value 프로퍼티를 사용하자.

    ]]> - -

    중요 sqlSessionFactoryBeansqlSessionTemplateBean 프로퍼티는 - 마이바티스 스프링 연동모듈 1.0.2 버전 이상에서만 사용이 가능하다. 하지만 MapperScannerConfigurer는 잦은 에러를 발생시키는 + +

    중요 sqlSessionFactoryBeansqlSessionTemplateBean 프로퍼티는 + 마이바티스 스프링 연동모듈 1.0.2 버전 이상에서만 사용이 가능하다. 하지만 MapperScannerConfigurer는 잦은 에러를 발생시키는 PropertyPlaceholderConfigurer보다 앞서 실행되기 때문에 이 프로퍼티들은 사용하지 말길 바란다(deprecated). 대신 새롭게 추가된 프로퍼티인 sqlSessionFactoryBeanNamesqlSessionTemplateBeanName 를 사용하도록 권한다.

    diff --git a/src/site/xdoc/mappers.xml b/src/site/xdoc/mappers.xml index 62fe64b118..6287690314 100644 --- a/src/site/xdoc/mappers.xml +++ b/src/site/xdoc/mappers.xml @@ -1,7 +1,7 @@ ]]> -

    먼저 insertInteractionMetadata가 호출될것이고 +

    먼저 insertInteractionMetadata가 호출될것이고 update구문은 jdbc드라이버에 의해(keyPropertykeyColumn) 생성된 아이디들을 리턴하기 위해 설정되었다. - InteractionMetadata 객체가 이 쿼리에 의해 업데이트되면 다음의 쿼리는 + InteractionMetadata 객체가 이 쿼리에 의해 업데이트되면 다음의 쿼리는 insertInteraction를 통해 상위객체인 Interaction를 작성하기 위해 사용될수 있다.

    -

    방금 언급한 내용에 관련하여 JDBC드라이버가 똑같이 동작하지 않을수 있다. - 이 글을 쓰는 시점에 H2 드라이버 1.3.168버전(org.h2.jdbc.JdbcStatement#getGeneratedKeys를 보라)만 배치모드에서 마지막 인덱스를 리턴한다. +

    방금 언급한 내용에 관련하여 JDBC드라이버가 똑같이 동작하지 않을수 있다. + 이 글을 쓰는 시점에 H2 드라이버 1.3.168버전(org.h2.jdbc.JdbcStatement#getGeneratedKeys를 보라)만 배치모드에서 마지막 인덱스를 리턴한다. 반면에 MySQL 드라이버는 기대한 것과 동일하게 동작하고 모든 아이디를 리턴한다.

    - \ No newline at end of file + diff --git a/src/site/ko/xdoc/boot.xml b/src/site/ko/xdoc/boot.xml index 8e5ce5fa2e..8684637274 100644 --- a/src/site/ko/xdoc/boot.xml +++ b/src/site/ko/xdoc/boot.xml @@ -1,7 +1,7 @@ - + @@ -57,7 +57,7 @@ --> - + diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml b/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml index 4d865af324..17b99f32b1 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml +++ b/src/test/java/org/mybatis/spring/submitted/autowire/spring.xml @@ -1,7 +1,7 @@ - + @@ -35,16 +35,16 @@ - - + + - + - + @@ -63,4 +63,4 @@ - \ No newline at end of file + diff --git a/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java b/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java index 2a1bf4aba5..65c844d1fe 100644 --- a/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java +++ b/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2019 the original author or authors. + * Copyright 2010-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ */ package org.mybatis.spring.type; +import java.lang.reflect.Proxy; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.logging.Logger; import org.mybatis.logging.LoggerFactory; import org.mybatis.spring.mapper.MapperFactoryBean; -import java.lang.reflect.Proxy; -import java.util.concurrent.atomic.AtomicInteger; - public class DummyMapperFactoryBean extends MapperFactoryBean { public DummyMapperFactoryBean() { From 526466cdd0bb34c63103d235618f3665156a594d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2020 06:53:20 +0000 Subject: [PATCH 226/933] Bump jakarta.servlet-api from 4.0.3 to 4.0.4 Bumps [jakarta.servlet-api](https://github.com/eclipse-ee4j/servlet-api) from 4.0.3 to 4.0.4. - [Release notes](https://github.com/eclipse-ee4j/servlet-api/releases) - [Commits](https://github.com/eclipse-ee4j/servlet-api/commits) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 324a223af5..808e16da8e 100644 --- a/pom.xml +++ b/pom.xml @@ -301,7 +301,7 @@ jakarta.servlet jakarta.servlet-api - 4.0.3 + 4.0.4 test From a3fa25f0364bd86853b49021cc77130d43f64885 Mon Sep 17 00:00:00 2001 From: nieqiuqiu Date: Tue, 23 Jun 2020 17:18:51 +0800 Subject: [PATCH 227/933] Change the method name to getPropertyValue --- .../spring/mapper/MapperScannerConfigurer.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 578db89da0..63c52c2198 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -402,11 +402,11 @@ private void processPropertyPlaceHolders() { PropertyValues values = mapperScannerBean.getPropertyValues(); - this.basePackage = updatePropertyValue("basePackage", values); - this.sqlSessionFactoryBeanName = updatePropertyValue("sqlSessionFactoryBeanName", values); - this.sqlSessionTemplateBeanName = updatePropertyValue("sqlSessionTemplateBeanName", values); - this.lazyInitialization = updatePropertyValue("lazyInitialization", values); - this.defaultScope = updatePropertyValue("defaultScope", values); + this.basePackage = getPropertyValue("basePackage", values); + this.sqlSessionFactoryBeanName = getPropertyValue("sqlSessionFactoryBeanName", values); + this.sqlSessionTemplateBeanName = getPropertyValue("sqlSessionTemplateBeanName", values); + this.lazyInitialization = getPropertyValue("lazyInitialization", values); + this.defaultScope = getPropertyValue("defaultScope", values); } this.basePackage = Optional.ofNullable(this.basePackage).map(getEnvironment()::resolvePlaceholders).orElse(null); this.sqlSessionFactoryBeanName = Optional.ofNullable(this.sqlSessionFactoryBeanName) @@ -422,7 +422,7 @@ private Environment getEnvironment() { return this.applicationContext.getEnvironment(); } - private String updatePropertyValue(String propertyName, PropertyValues values) { + private String getPropertyValue(String propertyName, PropertyValues values) { PropertyValue property = values.getPropertyValue(propertyName); if (property == null) { From 322a051d9050073c667bc76f61218637c3f91bf7 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 25 Jun 2020 00:31:11 +0900 Subject: [PATCH 228/933] Change document source format to markdown from xdoc --- pom.xml | 8 + src/site/es/markdown/README.md | 18 ++ src/site/es/markdown/batch.md | 351 ++++++++++++++++++++ src/site/es/markdown/boot.md | 4 + src/site/es/markdown/factorybean.md | 100 ++++++ src/site/es/markdown/getting-started.md | 99 ++++++ src/site/es/markdown/index.md | 55 ++++ src/site/es/markdown/mappers.md | 185 +++++++++++ src/site/es/markdown/sample.md | 63 ++++ src/site/es/markdown/sqlsession.md | 130 ++++++++ src/site/es/markdown/transactions.md | 141 ++++++++ src/site/es/markdown/using-api.md | 31 ++ src/site/es/xdoc/batch.xml | 409 ------------------------ src/site/es/xdoc/boot.xml | 36 --- src/site/es/xdoc/factorybean.xml | 161 ---------- src/site/es/xdoc/getting-started.xml.vm | 158 --------- src/site/es/xdoc/index.xml | 160 --------- src/site/es/xdoc/mappers.xml | 272 ---------------- src/site/es/xdoc/sample.xml | 177 ---------- src/site/es/xdoc/sqlsession.xml | 168 ---------- src/site/es/xdoc/transactions.xml | 163 ---------- src/site/es/xdoc/using-api.xml | 90 ------ src/site/ja/markdown/README.md | 18 ++ src/site/ja/markdown/batch.md | 344 ++++++++++++++++++++ src/site/ja/markdown/boot.md | 4 + src/site/ja/markdown/factorybean.md | 99 ++++++ src/site/ja/markdown/getting-started.md | 100 ++++++ src/site/ja/markdown/index.md | 52 +++ src/site/ja/markdown/mappers.md | 188 +++++++++++ src/site/ja/markdown/sample.md | 63 ++++ src/site/ja/markdown/sqlsession.md | 124 +++++++ src/site/ja/markdown/transactions.md | 137 ++++++++ src/site/ja/markdown/using-api.md | 32 ++ src/site/ja/xdoc/batch.xml | 374 ---------------------- src/site/ja/xdoc/boot.xml | 35 -- src/site/ja/xdoc/factorybean.xml | 152 --------- src/site/ja/xdoc/getting-started.xml.vm | 140 -------- src/site/ja/xdoc/index.xml | 148 --------- src/site/ja/xdoc/mappers.xml | 249 --------------- src/site/ja/xdoc/sample.xml | 177 ---------- src/site/ja/xdoc/sqlsession.xml | 156 --------- src/site/ja/xdoc/transactions.xml | 155 --------- src/site/ja/xdoc/using-api.xml | 88 ----- src/site/ko/markdown/README.md | 18 ++ src/site/ko/markdown/batch.md | 353 ++++++++++++++++++++ src/site/ko/markdown/boot.md | 4 + src/site/ko/markdown/factorybean.md | 97 ++++++ src/site/ko/markdown/getting-started.md | 98 ++++++ src/site/ko/markdown/index.md | 54 ++++ src/site/ko/markdown/mappers.md | 184 +++++++++++ src/site/ko/markdown/sample.md | 62 ++++ src/site/ko/markdown/sqlsession.md | 124 +++++++ src/site/ko/markdown/transactions.md | 134 ++++++++ src/site/ko/markdown/using-api.md | 30 ++ src/site/ko/xdoc/batch.xml | 373 --------------------- src/site/ko/xdoc/boot.xml | 36 --- src/site/ko/xdoc/factorybean.xml | 132 -------- src/site/ko/xdoc/getting-started.xml.vm | 118 ------- src/site/ko/xdoc/index.xml | 150 --------- src/site/ko/xdoc/mappers.xml | 227 ------------- src/site/ko/xdoc/sample.xml | 168 ---------- src/site/ko/xdoc/sqlsession.xml | 129 -------- src/site/ko/xdoc/transactions.xml | 134 -------- src/site/ko/xdoc/using-api.xml | 74 ----- src/site/markdown/README.md | 18 ++ src/site/markdown/batch.md | 359 +++++++++++++++++++++ src/site/markdown/boot.md | 4 + src/site/markdown/factorybean.md | 100 ++++++ src/site/markdown/getting-started.md | 100 ++++++ src/site/markdown/index.md | 54 ++++ src/site/markdown/mappers.md | 182 +++++++++++ src/site/markdown/sample.md | 64 ++++ src/site/markdown/sqlsession.md | 124 +++++++ src/site/markdown/transactions.md | 135 ++++++++ src/site/markdown/using-api.md | 30 ++ src/site/xdoc/batch.xml | 401 ----------------------- src/site/xdoc/boot.xml | 36 --- src/site/xdoc/factorybean.xml | 224 ------------- src/site/xdoc/getting-started.xml.vm | 171 ---------- src/site/xdoc/index.xml | 169 ---------- src/site/xdoc/mappers.xml | 295 ----------------- src/site/xdoc/sample.xml | 177 ---------- src/site/xdoc/sqlsession.xml | 187 ----------- src/site/xdoc/transactions.xml | 181 ----------- src/site/xdoc/using-api.xml | 90 ------ src/site/zh/markdown/README.md | 18 ++ src/site/zh/markdown/batch.md | 343 ++++++++++++++++++++ src/site/zh/markdown/boot.md | 4 + src/site/zh/markdown/factorybean.md | 94 ++++++ src/site/zh/markdown/getting-started.md | 97 ++++++ src/site/zh/markdown/index.md | 51 +++ src/site/zh/markdown/mappers.md | 183 +++++++++++ src/site/zh/markdown/sample.md | 62 ++++ src/site/zh/markdown/sqlsession.md | 122 +++++++ src/site/zh/markdown/transactions.md | 130 ++++++++ src/site/zh/markdown/using-api.md | 30 ++ src/site/zh/xdoc/batch.xml | 376 ---------------------- src/site/zh/xdoc/boot.xml | 36 --- src/site/zh/xdoc/factorybean.xml | 140 -------- src/site/zh/xdoc/getting-started.xml.vm | 133 -------- src/site/zh/xdoc/index.xml | 142 -------- src/site/zh/xdoc/mappers.xml | 232 -------------- src/site/zh/xdoc/sample.xml | 164 ---------- src/site/zh/xdoc/sqlsession.xml | 143 --------- src/site/zh/xdoc/transactions.xml | 142 -------- src/site/zh/xdoc/using-api.xml | 83 ----- 106 files changed, 5808 insertions(+), 8531 deletions(-) create mode 100644 src/site/es/markdown/README.md create mode 100644 src/site/es/markdown/batch.md create mode 100644 src/site/es/markdown/boot.md create mode 100644 src/site/es/markdown/factorybean.md create mode 100644 src/site/es/markdown/getting-started.md create mode 100644 src/site/es/markdown/index.md create mode 100644 src/site/es/markdown/mappers.md create mode 100644 src/site/es/markdown/sample.md create mode 100644 src/site/es/markdown/sqlsession.md create mode 100644 src/site/es/markdown/transactions.md create mode 100644 src/site/es/markdown/using-api.md delete mode 100644 src/site/es/xdoc/batch.xml delete mode 100644 src/site/es/xdoc/boot.xml delete mode 100644 src/site/es/xdoc/factorybean.xml delete mode 100644 src/site/es/xdoc/getting-started.xml.vm delete mode 100644 src/site/es/xdoc/index.xml delete mode 100644 src/site/es/xdoc/mappers.xml delete mode 100644 src/site/es/xdoc/sample.xml delete mode 100644 src/site/es/xdoc/sqlsession.xml delete mode 100644 src/site/es/xdoc/transactions.xml delete mode 100644 src/site/es/xdoc/using-api.xml create mode 100644 src/site/ja/markdown/README.md create mode 100644 src/site/ja/markdown/batch.md create mode 100644 src/site/ja/markdown/boot.md create mode 100644 src/site/ja/markdown/factorybean.md create mode 100644 src/site/ja/markdown/getting-started.md create mode 100644 src/site/ja/markdown/index.md create mode 100644 src/site/ja/markdown/mappers.md create mode 100644 src/site/ja/markdown/sample.md create mode 100644 src/site/ja/markdown/sqlsession.md create mode 100644 src/site/ja/markdown/transactions.md create mode 100644 src/site/ja/markdown/using-api.md delete mode 100644 src/site/ja/xdoc/batch.xml delete mode 100644 src/site/ja/xdoc/boot.xml delete mode 100644 src/site/ja/xdoc/factorybean.xml delete mode 100644 src/site/ja/xdoc/getting-started.xml.vm delete mode 100644 src/site/ja/xdoc/index.xml delete mode 100644 src/site/ja/xdoc/mappers.xml delete mode 100644 src/site/ja/xdoc/sample.xml delete mode 100644 src/site/ja/xdoc/sqlsession.xml delete mode 100644 src/site/ja/xdoc/transactions.xml delete mode 100644 src/site/ja/xdoc/using-api.xml create mode 100644 src/site/ko/markdown/README.md create mode 100644 src/site/ko/markdown/batch.md create mode 100644 src/site/ko/markdown/boot.md create mode 100644 src/site/ko/markdown/factorybean.md create mode 100644 src/site/ko/markdown/getting-started.md create mode 100644 src/site/ko/markdown/index.md create mode 100644 src/site/ko/markdown/mappers.md create mode 100644 src/site/ko/markdown/sample.md create mode 100644 src/site/ko/markdown/sqlsession.md create mode 100644 src/site/ko/markdown/transactions.md create mode 100644 src/site/ko/markdown/using-api.md delete mode 100644 src/site/ko/xdoc/batch.xml delete mode 100644 src/site/ko/xdoc/boot.xml delete mode 100644 src/site/ko/xdoc/factorybean.xml delete mode 100644 src/site/ko/xdoc/getting-started.xml.vm delete mode 100644 src/site/ko/xdoc/index.xml delete mode 100644 src/site/ko/xdoc/mappers.xml delete mode 100644 src/site/ko/xdoc/sample.xml delete mode 100644 src/site/ko/xdoc/sqlsession.xml delete mode 100644 src/site/ko/xdoc/transactions.xml delete mode 100644 src/site/ko/xdoc/using-api.xml create mode 100644 src/site/markdown/README.md create mode 100644 src/site/markdown/batch.md create mode 100644 src/site/markdown/boot.md create mode 100644 src/site/markdown/factorybean.md create mode 100644 src/site/markdown/getting-started.md create mode 100644 src/site/markdown/index.md create mode 100644 src/site/markdown/mappers.md create mode 100644 src/site/markdown/sample.md create mode 100644 src/site/markdown/sqlsession.md create mode 100644 src/site/markdown/transactions.md create mode 100644 src/site/markdown/using-api.md delete mode 100644 src/site/xdoc/batch.xml delete mode 100644 src/site/xdoc/boot.xml delete mode 100644 src/site/xdoc/factorybean.xml delete mode 100644 src/site/xdoc/getting-started.xml.vm delete mode 100644 src/site/xdoc/index.xml delete mode 100644 src/site/xdoc/mappers.xml delete mode 100644 src/site/xdoc/sample.xml delete mode 100644 src/site/xdoc/sqlsession.xml delete mode 100644 src/site/xdoc/transactions.xml delete mode 100644 src/site/xdoc/using-api.xml create mode 100644 src/site/zh/markdown/README.md create mode 100644 src/site/zh/markdown/batch.md create mode 100644 src/site/zh/markdown/boot.md create mode 100644 src/site/zh/markdown/factorybean.md create mode 100644 src/site/zh/markdown/getting-started.md create mode 100644 src/site/zh/markdown/index.md create mode 100644 src/site/zh/markdown/mappers.md create mode 100644 src/site/zh/markdown/sample.md create mode 100644 src/site/zh/markdown/sqlsession.md create mode 100644 src/site/zh/markdown/transactions.md create mode 100644 src/site/zh/markdown/using-api.md delete mode 100644 src/site/zh/xdoc/batch.xml delete mode 100644 src/site/zh/xdoc/boot.xml delete mode 100644 src/site/zh/xdoc/factorybean.xml delete mode 100644 src/site/zh/xdoc/getting-started.xml.vm delete mode 100644 src/site/zh/xdoc/index.xml delete mode 100644 src/site/zh/xdoc/mappers.xml delete mode 100644 src/site/zh/xdoc/sample.xml delete mode 100644 src/site/zh/xdoc/sqlsession.xml delete mode 100644 src/site/zh/xdoc/transactions.xml delete mode 100644 src/site/zh/xdoc/using-api.xml diff --git a/pom.xml b/pom.xml index 324a223af5..fa2f1b36f6 100644 --- a/pom.xml +++ b/pom.xml @@ -330,6 +330,8 @@ maven-site-plugin en,es,zh_CN,ja,ko + + ${project.build.directory}/site-src @@ -346,6 +348,12 @@ ${project.basedir}/src/main/resources + + + ${project.basedir}/src/site + ${project.build.directory}/site-src + true + diff --git a/src/site/es/markdown/README.md b/src/site/es/markdown/README.md new file mode 100644 index 0000000000..a3abaf2e40 --- /dev/null +++ b/src/site/es/markdown/README.md @@ -0,0 +1,18 @@ +# Tabla de contenido + +Esta página es para representar el índice en GitHub. + +> **NOTE:** +> +> Dado que el destino del enlace se especifica asumiendo que se convierte a html con maven-site-plugin, hay un ancla que se rompe en el renderizado en GitHub. + +* [Introducción](./index.md) +* [Primeros pasos](./getting-started.md) +* [SqlSessionFactoryBean](./factorybean.md) +* [Transactions](./transactions.md) +* [Uso de SqlSession](./sqlsession.md) +* [Inyección de Mappers](./mappers.md) +* [Spring Boot](./boot.md) +* [Uso del API de MyBatis](./using-api.md) +* [Spring Batch](./batch.md) +* [Código de ejemplo](./sample.md) diff --git a/src/site/es/markdown/batch.md b/src/site/es/markdown/batch.md new file mode 100644 index 0000000000..1578477f98 --- /dev/null +++ b/src/site/es/markdown/batch.md @@ -0,0 +1,351 @@ + +# Spring Batch + +Desde la versión 1.1.0 MyBatis-Spring proporciona dos beans para construir aplicaciones Spring Batch: `MyBatisPagingItemReader` y `MyBatisCursorItemReader` y `MyBatisBatchItemWriter`. +Also, As of version 2.0.0 provides three builder classes for supporting the Java Configuration: the `MyBatisPagingItemReaderBuilder`, the `MyBatisCursorItemReaderBuilder` and the `MyBatisBatchItemWriterBuilder`. + +NOTA +Esta sección se refiere a [Spring Batch](http://static.springsource.org/spring-batch/) y no a sesiones batch de MyBatis. Para obtener información sobre las sesiones batch ve a la sección [Usnado un SqlSession](sqlsession.html). + +## MyBatisPagingItemReader + +Este bean es un `ItemReader` que lee registros de una base de datos usando paginación. + +Ejecuta la sentencia especificada mediante la propiedad `setQueryId` para obtener los datos. La sentencia se ejecuta usando peticiones paginadas del tamaño indicando en la propiedad `setPageSize`. +Al llamar al método `read()` éste devuelve el objeto que corresponde a la posición actual y solicita más páginas si es necesario. + +El reader recibe algunos parametros estándar y la SQL deberá hacer uso de algunos de ellos para construir un resultset del tamaño requerido. Los parametros son: + +* `_page`: el número de página a leer (comenzando en 0) +* `_pagesize`: el tamaño de la página, es decir, el número de filas a devolver +* `_skiprows`: el producto de `_page` por `_pagesize` + +Se pueden mapear en un statement de tipo select de la siguiente forma: + +```xml + +``` + +A continuación se muestra un ejemplo de configuración: + +```xml + + + + +``` +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisPagingItemReader reader() { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +**Veamos un ejemplo más complejo:** + +```xml + +``` +```xml + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @StepScope + @Bean + public MyBatisPagingItemReader dateBasedCriteriaReader( + @Value("#{@datesParameters}") Map datesParameters) throws Exception { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(batchReadingSessionFactory()) + .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") + .parameterValues(datesParameters) + .pageSize(200) + .build(); + } + + @StepScope + @Bean + public Map datesParameters( + @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, + @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { + Map map = new HashMap<>(); + map.put("yesterday", yesterday); + map.put("today", today); + map.put("first_day_of_the_month", firstDayOfTheMonth); + map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); + return map; + } +} +``` + +El ejemplo anterior hace uso de tres cosas distintas: + +* `sqlSessionFactory`: Puedes tu propio sessionFactory, podría ser útil si quires leer de varias bases de datos. +* `queryId`: Si el código accede a varias tablas, y tienes distintas sentencias de consulta, puede ser interesante usar ficheros de mapeo distintos con namespaces distintos. + En este caso, al referirte a la query, no olvides incluir el namespace correspondiente. +* `parameterValues`: Puedes pasar parametros adicionales en este mapa, el ejemplo de arriba usa un mapa que se construye usando una expresion SpEL y obteniendo valores del jobExecutionContext. + Las claves del mapa puede usarse en el fichero mapper de MyBatis (por ejemplo: *yesterday* se puede usar como `#{yesterday,jdbcType=TIMESTAMP}`). + Observa que el mapa y el reader se consutruyen en un solo `step` para que sea posible usar la expresión SpEL con el `jobExecutionContext`. + Adicionalmente si los type handlers de MyBatis están configurados correctamente puedes pasar instancias personalizadas como los parametros del ejemplo que son fechas JodaTime. +* `pageSize`: Si le flujo batch está configurado con un tamaño de bloque (chunk size), es importante pasar esta información al reader, y eso se hace mediante esta propiedad. + +## MyBatisCursorItemReader + +Este bean es un `ItemReader` que lee registros de la base de datos usando un cursor. + +NOTA +Para usar este bean necesitas al menos MyBatis 3.4.0 o superior. + +Ejecuta la sentencia especificada mediante la propiedad `setQueryId` para obtener los datos usando el método `selectCursor()`. +Al llamar al método `read()` se devolverá el siguiente elemento del cursor hasta que no quede ninguno por devolver. + +El reader usa una conexión separada para que la sentencia no participe en ninguna transacción creada como parte del proceso del step. + +Cuando se usar un cursor puedes usar una sentencia convencional: + +```xml + +``` + +A continuación se muestra un ejemplo de configuración: + +```xml + + + + +``` +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisCursorItemReader reader() { + return new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +## MyBatisBatchItemWriter + +Es un `ItemWriter` que usa las capacidades de batch de `SqlSessionTemplate` para ejecutar sentencias batch para todos los elementos (items) proporcionados. +El `SqlSessionFactory` debe configurarse con un executor de tipo `BATCH`. + +Ejecuta la sentencia indicada en la propiedad `statementId` cuando se invoca a `write()`. Se supone que `write()` se invoca dentro de una transacción. + +A continuación se muestra un ejemplo de configuración: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") + .build(); + } +} +``` + +**Converting a item that read using ItemReader to an any parameter object:** + +By default behavior, the `MyBatisBatchItemWriter` passes a item that read using `ItemReader` (or convert by `ItemProcessor`) to the MyBatis(`SqlSession#update()`) as the parameter object. +If you want to customize a parameter object that passes to the MyBatis, you can realize to use the `itemToParameterConverter` option. For example using `itemToParameterConverter` option, you can passes any objects other than the item object to the MyBatis. +Follows below a sample: + +At first, you create a custom converter class (or factory method). The following sample uses a factory method. + +```java +public class ItemToParameterMapConverters { + public static Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; + } +} +``` + +At next, you write a sql mapping. + +```xml + +``` + +At last, you configure the `MyBatisBatchItemWriter`. + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() throws Exception { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); + } +} +``` + +```xml + + + + + + + + + + +``` + +**Escribiendo en distintas tablas usando composite writers (con algunos condicionantes):** + +Esta técnica sólo puede usarse con MyBatis 3.2+, por que había un [error](http://code.google.com/p/mybatis/issues/detail?id=741) en las versiones anteriores que hacían que el writer funcionara de forma incorrecta. + +Si el batch necesita escribir datos complejos, como registros con asociaciones, o en distintas bases de datos, entonces es necesario sortear el problema de que los insert statements solo pueden escribir en una tabla. +Para conseguir esto debes preparar un Item para que sea escrito por el writer. Sin embargo, dependiendo de las circunstancias puede ser interesante usar la siguiente técnica. +El truco siguiente funciona con items con asociaciones simples o con tablas no relacionadas. + +Elabora el `item` de forma que *contenta* todos los resgistros distintos. Supon que para cada `item` hay una *Interaction* que tiene una asociación *InteractionMetadata* y dos filas no asociadas *VisitorInteraction* and *CustomerInteraction*. +El objeto contenedor será de la siguiente forma: + +```java +public class InteractionRecordToWriteInMultipleTables { + private final VisitorInteraction visitorInteraction; + private final CustomerInteraction customerInteraction; + private final Interaction interaction; + // ... +} +``` +```java +public class Interaction { + private final InteractionMetadata interactionMetadata; +} +``` + +Entonces en la configuración de spring habrá un `CompositeItemWriter` que usará writers delegados configurados especificamente para cada tipo de registro. +Fijate que el *InteractionMetadata* es una asociacióin en el ejemplo por lo que debe ser escrita antes para que la Interaction pueda recibir la clave generada. + +```xml + + + + + + + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public CompositeItemWriter interactionsItemWriter() { + CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); + List> writers = new ArrayList<>(4); + writers.add(visitorInteractionsWriter()); + writers.add(customerInteractionsWriter()); + writers.add(interactionMetadataWriter()); + writers.add(interactionWriter()); + compositeItemWriter.setDelegates(writers); + return compositeItemWriter; + } +} +``` + +Cada writer delegados se configura como sea necesario, por ejemplo para *Interaction* y *InteractionMetadata*: + +```xml + +``` +```xml + +``` + +Al igual que con el reader el `statementId` puede hacer referencia al statement con un namespace como prefijo. + +Ahora es debe elaborarse el fichero de mapeo para cada tipo de registro, de la siguiente forma: + +```xml + + + +``` +```xml + + + +``` + +Lo que sucede es que primeramente se llamará a `insertInteractionMetadata`, y la sentencia de update está configurada para devolver las claves autogeneradas (`keyProperty` y `keyColumn`). +Una vez que el `InteractionMetadata` se ha almacenado por esta sentencia se puede ejecutar la siguiente para escribir el objeto padre `Interaction` mediante `insertInteraction`. + +***Sin embargo, ten en cuenta que los drivers JDBC se comportan distinto en este aspecto. A la fecha en la que se escribe esto +el driver H2 1.3.168 solo devuelve el último ID incluso en modo BATCH (see `org.h2.jdbc.JdbcStatement#getGeneratedKeys`), +mientras que el driver JDBC de MySQL se comporta como es de esperar y devuelve todos los IDs.*** diff --git a/src/site/es/markdown/boot.md b/src/site/es/markdown/boot.md new file mode 100644 index 0000000000..cda8eb3a3d --- /dev/null +++ b/src/site/es/markdown/boot.md @@ -0,0 +1,4 @@ + +# Using Spring Boot + +Please see the [MyBatis Spring-boot-starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure) sub project docs for details. diff --git a/src/site/es/markdown/factorybean.md b/src/site/es/markdown/factorybean.md new file mode 100644 index 0000000000..598f28aef3 --- /dev/null +++ b/src/site/es/markdown/factorybean.md @@ -0,0 +1,100 @@ + +# SqlSessionFactoryBean + +En MyBatis una `SqlSessionFactory` se crea mediante la clase `SqlSessionFactoryBuilder`. En MyBatis-Spring se usa la clase `SqlSessionFactoryBean` en su lugar. + +## Configuración + +Para crear un factory bean, pon lo siguiente en el fichero XML de configuración de Spring: + +```xml + + + +``` + +La clase `SqlSessionFactoryBean` implementa el interfaz `FactoryBean` (see [the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-extension-factorybean)). +Lo cual significa que el bean que crea Spring en última instancia **no** es un `SqlSessionFactoryBean` en si mismo, sino el objeto que la factoria devuelve como resultado de la llamada al método `getObject()`. +En este caso, Spring creará un bean `SqlSessionFactory` durante el arranque de la aplicación y lo guardará bajo el nombre `sqlSessionFactory`. En Java, el código equivalente sería: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +Normalmente no necesitarás utilizar directamente un `SqlSessionFactoryBean` o su correspondiente `SqlSessionFactory` directly. +En su lugar, la factoría se utilizará para ser inyectada en `MapperFactoryBean`s o DAOs que extiendan de `SqlSessionDaoSupport`. + +## Properties + +La clase `SqlSessionFactory` solo tiene una propiedad obligatoria, un `DataSource`. +Puede ser cualquier `DataSource` y se puede configurar como cualquier otra conexión a base de daots de Spring. + +Una propiedad muy común es la `configLocation` que se utiliza para indicar la localización del fichero de configuración XML de MyBatis. +Normalmente solo es necesario dicho fichero si se requiere cambiar los valores por defecto de las secciones `` o ``. + +Es importante saber que este fichero de configuración **no** tiene por qué ser un fichero de configuración de MyBatis completo. +Concretamente, los environments, dataSources y transactionManagers serán **ignorados**. +`SqlSessionFactoryBean` crea su propio `Environment` de MyBatis con los valores configurados tal y como se requieren. + +Otro motivo para necesitar un fichero de configuración es que los ficheros de mapeo XML no estén en el mismo lugar del classpath que los mapper interfaces. +En este caso hay dos opciones. La primera es especificar manualmente el classpath de los ficheros XML usando la sección `` del fichero de configuración de MyBatis. +La segunda opción es usar la propiedad `mapperLocations` del factory bean. + +La propiedad `mapperLocations` recibe una lista de localizaciones de recursos. Se utiliza para indicar la ubicación de los ficheros de mapeo XML de MyBatis. +El valor puede contener un patron tipo Ant para cargar todos los ficheros de un directorio o buscar de forma recursiva en todos los paths desde una localización base. Por ejemplo: + +```xml + + + + +``` + +Esto cargaría todos los ficheros de mapeo XML en el paquete sample.config.mappers y sus subpaquetes. + +Otra propiedad que puede ser necesaria en un entorno con transacciones gestionadas por contenedor es la `transactionFactoryClass`. Lee la sección de transacciones para obtener más detalles. + +En caso de usar la característica multi-db necesitarás informar la propiedad `databaseIdProvider` de la siguiente forma: + +```xml + + + + sqlserver + db2 + oracle + mysql + + + +``` +```xml + + + + + +``` + +NOTE +Since 1.3.0, `configuration` property has been added. It can be specified a `Configuration` instance directly without MyBatis XML configuration file. +For example: + +```xml + + + + + + + + +``` diff --git a/src/site/es/markdown/getting-started.md b/src/site/es/markdown/getting-started.md new file mode 100644 index 0000000000..fdaedcaa30 --- /dev/null +++ b/src/site/es/markdown/getting-started.md @@ -0,0 +1,99 @@ + +# Primeros pasos + +Este capítulo te mostrará en pocos pasos cómo instalar y configurar MyBatis-Spring y cómo construir +una pequeña aplicación transaccional. + +## Instalación + +Para usar el módulo MyBatis-Spring, debes incluir el fichero `mybatis-spring-${project.version}.jar` y sus dependencias en el classpath. + +Si usas Maven simplemente añade la siguiente dependencia a tu pom.xml: + +```xml + + org.mybatis + mybatis-spring + ${project.version} + +``` + +## Configuración rápida + +Para usar MyBatis con Spring necesitas definir al menos dos cosas en tu contexto Spring: una `SqlSessionFactory` y al menos un mapper interface. + +En MyBatis-Spring se usa un `SqlSessionFactoryBean` para crear una `SqlSessionFactory`. Para configurar la factory bean pon lo siguiente en tu fichero de configuración de Spring: + +```xml + + + +``` + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +Observa que la `SqlSessionFactory` requiere un `DataSource`. Éste puede ser cualquier `DataSource` y debe configurarse como cualquier otra conexión a base de datos de Spring. + +Asumamos que tienes un mapper interface definido de la siguiente forma: + +```java +public interface UserMapper { + @Select("SELECT * FROM users WHERE id = #{userId}") + User getUser(@Param("userId") String userId); +} +``` + +Este interface se añade a Spring usando un `MapperFactoryBean` de la siguiente forma: + +```xml + + + + +``` + +Observa que la clase del mapper indicada **debe** ser un interface, no una implementación. En este ejemplo se usan anotaciones para especificar la SQL, pero también es posible usar un fichero de mapeo XML. + +Una vez configurado, puedes inyectar mappers directamente en tus beans de servicio/negocio de la misma forma que inyectarías cualquier otro bean en Spring. +La clase `MapperFactoryBean` se encargará de obtener una `SqlSession` y de cerrarla. Si hay una transación Spring en curso, la sesión se comitará o se hará rollback cuando la transacción finalice. +Finalmente, cualquier excepción será traducida a una excepión `DataAccessException`s de Spring. + +If you use the Java Configuration: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public UserMapper userMapper() throws Exception { + SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); + return sqlSessionTemplate.getMapper(UserMapper.class); + } +} +``` + +Invocar a MyBatis es sólo una línea de código: + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` diff --git a/src/site/es/markdown/index.md b/src/site/es/markdown/index.md new file mode 100644 index 0000000000..ed37f9ad8c --- /dev/null +++ b/src/site/es/markdown/index.md @@ -0,0 +1,55 @@ + +# Introduction + +## ¿Qué es MyBatis-Spring? + +MyBatis-Spring permite integrar MyBatis con Spring. Esta librería permite que MyBatis participe en trasacciones Spring, +se encarga de constuir mappers y `SqlSession`s e inyectarlos en otros beans, traduce excepciones de MyBatis en excepcines `DataAccessException`s de Spring y finalmente, permite construir aplicaciones libres de dependencias de MyBatis, Spring y MyBatis-Spring. + +## Motivación + +Spring version 2 sólo soporta iBATIS version 2. See hizo un intento de incluir el soporte de MyBatis 3 en Spring 3 (ver el [issue Jira](https://jira.springsource.org/browse/SPR-5991)). +Pero desafortunadamente, el desarrollo de Spring 3 finalizó antes de que MyBatis 3 fuera liberado oficialmente. +Dado que el equipo de Spring no quería liberar una versión basada en un producto no terminado el soporte de oficial tenía que esperar. +Dado el interés de la comunidad en el soporte de MyBatis, la comunidad de MyBatis decidió que era el momento de unificar a los colaboradores interesados y proporcionar la integración con Spring como un sub-projecto de MyBatis en su lugar. + +## Requisitos + +Antes de comenzar con MyBatis-Spring, es muy importante que estés familiarizado con la terminología tanto de MyBatis como de Spring. +Este documento no pretende proporcionar información de configuración básica de MyBatis o Spring. + +MyBatis-Spring requires following versions: + +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +| --- | --- | --- | --- | --- | +| **2.0** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | + +## Agradecimientos + +Queremos agradecer a la todos los que han hecho de este proyecto una realidad (en orden alfabético): +Eduardo Macarron, Hunter Presnall y Putthiphong Boonphong por la codificación, pruebas y documentación; +a Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan y Tomas Pinos por sus contribuciones; +y a Simone Tripodi por encontrarlos a todos y traerlos al proyecto MyBatis ;) Sin ellos este proyecto no existiría. + +## Colabora en mejorar esta documentación... + +Si ves que hay alguna carencia en esta documentación, o que falta alguna característica por documentar, te animamos a que lo investigues y la documentes tu mismo! + +Las fuentes de este manual están disponibles en formato xdoc en el [Git del proyecto](https://github.com/mybatis/mybatis-3/tree/master/src/site). Haz un fork, cambialas y envía un pull request. + +Eres el mejor candidato para documentar porque los lectores de esta documentación son gente como tú! + +## Translations + +Users can read about MyBatis-Spring in the following translations: + + + +Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your mother tongue documentation! diff --git a/src/site/es/markdown/mappers.md b/src/site/es/markdown/mappers.md new file mode 100644 index 0000000000..51dd4293d8 --- /dev/null +++ b/src/site/es/markdown/mappers.md @@ -0,0 +1,185 @@ + +# Inyectar mappers + +En lugar de codificar DAOs (data access objects) manualmente usando la clase `SqlSessionDaoSupport` o `SqlSessionTemplate`, Mybatis-Spring puede crear un mapper thread-safe que puedes inyectar directamente en otros beans. + +```xml + + + +``` + + Una vez inyectado, el mapper está listo para se usado en la lógica de aplicación: + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` + +Observa que no se usa la `SqlSession` ni ninguna otra referencia a MyBatis en este código. No es necesario ni siquiera crear o cerrar la sesión, MyBatis-Spring se encarga de ello. + + +## Registrar un mapper + +La forma de registrar un mapper varía según si quieres usar la configuración XML clásica o la nueva Java Config de Spring 3.0+ (También conocida como `@Configuration`). + +### Con confiugración XML + +Un mapper se registra en Spring incluyendo un `MapperFactoryBean` en tu fichero de configuración XML, de la siguiente forma: + +```xml + + + + +``` + +Si el mapper UserMapper tiene un fichero XML de mapeo asociado el `MapperFactoryBean` lo cargará automáticamente. +Por lo tanto no es necesario especificar dicho mapper en el fichero de configuración de MyBatis a no ser que los ficheros XML estén en una lugar distinto del classpath. +Ver la sección de `SqlSessionFactoryBean` y la propiedad [`configLocation`](factorybean.html) para más información. + +El `MapperFactoryBean` requiere o un `SqlSessionFactory` o un `SqlSessionTemplate`. +Ambos se pueden informar usando sendas propiedades `sqlSessionFactory` y `sqlSessionTemplate`. +Si ambas propiedades han sdo informadas la `SqlSessionFactory` se ignora. +Dado que un `SqlSessionTemplate` debe tener un session factory dicho factory se usará por el `MapperFactoryBean`. + +### Con Java Config + +```java +@Configuration +public class MyBatisConfig { + @Bean + public MapperFactoryBean userMapper() throws Exception { + MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); + factoryBean.setSqlSessionFactory(sqlSessionFactory()); + return factoryBean; + } +} +``` + + +## Escanear mappers + +No es necesario registrar los mappers uno por uno en el fichero XML de Spring. En lugar de esto, puede dejar que MyBatis-Spring los busque en tu classpath. + +Hay tres formas distintas de hacerlo: + +* Usando el elemneto ``. +* Usando la anotación `@MapperScan` +* Usando un fichero clásico XML de configuración de Spring y añadiendo el bean `MapperScannerConfigurer` + +Tango `` como `@MapperScan` son características añadidas en MyBatis-Spring 1.2.0. `@MapperScan` requiere Spring 3.1+. + +Since 2.0.2, mapper scanning feature support a option (`lazy-initialization`) that control lazy initialization enabled/disabled of mapper bean. +The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. +The default of this option is `false` (= not use lazy initialization). +If developer want to use lazy initialization for mapper bean, it should be set to the `true` expressly. + +IMPORTANT +If use the lazy initialization feature, the developer need to understand following limitations. +If any of following conditions are matches, usually the lazy initialization feature cannot use on your application. + +* When refers to the statement of **other mapper** using ``(`@One`) and ``(`@Many`) +* When includes to the fragment of **other mapper** using `` +* When refers to the cache of **other mapper** using ``(`@CacheNamespaceRef`) +* When refers to the result mapping of **other mapper** using `]]> - -

    A continuación se muestra un ejemplo de configuración:

    - - - - -
    ]]> - - reader() { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -

    Veamos un ejemplo más complejo:

    - - - - - - - - -]]> - - dateBasedCriteriaReader( - @Value("#{@datesParameters}") Map datesParameters) throws Exception { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(batchReadingSessionFactory()) - .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") - .parameterValues(datesParameters) - .pageSize(200) - .build(); -} - -@StepScope -@Bean -public Map datesParameters( - @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, - @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { - Map map = new HashMap<>(); - map.put("yesterday", yesterday); - map.put("today", today); - map.put("first_day_of_the_month", firstDayOfTheMonth); - map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); - return map; -}]]> - -

    - El ejemplo anterior hace uso de tres cosas distintas: -

    - -
      -
    • sqlSessionFactory: Puedes tu propio sessionFactory, podría ser útil si quires leer de - varias bases de datos.
    • -
    • queryId: Si el código accede a varias tablas, y tienes distintas sentencias de consulta, - puede ser interesante usar ficheros de mapeo distintos con namespaces distintos. - En este caso, al referirte a la query, no olvides incluir el namespace correspondiente.
    • -
    • parameterValues: Puedes pasar parametros adicionales en este mapa, el ejemplo de arriba - usa un mapa que se construye usando una expresion SpEL y obteniendo valores del jobExecutionContext. - Las claves del mapa puede usarse en el fichero mapper de MyBatis (por ejemplo: - yesterday se puede usar como #{yesterday,jdbcType=TIMESTAMP}). - Observa que el mapa y el reader se consutruyen en un solo step para que sea posible usar la expresión - SpEL con el jobExecutionContext. Adicionalmente si los type handlers de MyBatis - están configurados correctamente puedes pasar instancias personalizadas como los parametros del ejemplo que son - fechas JodaTime.
    • -
    • pageSize: Si le flujo batch está configurado con un tamaño de bloque (chunk size), - es importante pasar esta información al reader, y eso se hace mediante esta propiedad.
    • -
    - -
    - - -

    - Este bean es un ItemReader que lee registros de la base de datos usando un cursor. -

    - -

    - NOTA Para usar este bean necesitas al menos MyBatis 3.4.0 o superior. -

    - -

    - Ejecuta la sentencia especificada mediante la propiedad setQueryId para obtener los datos - usando el método selectCursor(). - Al llamar al método read() se devolverá el siguiente elemento del cursor - hasta que no quede ninguno por devolver. -

    - -

    - El reader usa una conexión separada para que la sentencia no participe en ninguna transacción creada como parte - del proceso del step. -

    - -

    Cuando se usar un cursor puedes usar una sentencia convencional:

    - - SELECT id, name, job FROM employees ORDER BY id ASC -]]> - -

    A continuación se muestra un ejemplo de configuración:

    - - - - -]]> - - reader() { - return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -
    - - - -

    - Es un ItemWriter que usa las capacidades de batch de SqlSessionTemplate para - ejecutar sentencias batch para todos los elementos (items) proporcionados. - El SqlSessionFactory debe configurarse con un executor de tipo BATCH. -

    - -

    - Ejecuta la sentencia indicada en la propiedad statementId cuando se invoca a write(). - Se supone que write() se invoca dentro de una transacción.
    -

    - -

    A continuación se muestra un ejemplo de configuración:

    - - - - -]]> - - writer() { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") - .build(); -}]]> - - -

    Converting a item that read using ItemReader to an any parameter object:

    - -

    - By default behavior, the MyBatisBatchItemWriter passes a item that read using ItemReader - (or convert by ItemProcessor) to the MyBatis(SqlSession#update()) as the parameter object. - If you want to customize a parameter object that passes to the MyBatis, you can realize to use the itemToParameterConverter option. - For example using itemToParameterConverter option, you can passes any objects other than the item object to the MyBatis. - Follows below a sample: -

    - -

    - At first, you create a custom converter class (or factory method). The following sample uses a factory method. -

    - - Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { - return item -> { - Map parameter = new HashMap<>(); - parameter.put("item", item); - parameter.put("operationBy", operationBy); - parameter.put("operationAt", operationAt); - return parameter; - }; -}]]> - -

    - At next, you write a sql mapping. -

    - - - insert into persons (first_name, last_name, operation_by, operation_at) - values(#{item.firstName}, #{item.lastName}, #{operationBy}, #{operationAt}) -]]> - -

    - At last, you configure the MyBatisBatchItemWriter. -

    - - writer() throws Exception { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") - .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) - .build(); -}]]> - - - - - - - - - - - - -]]> - -

    Escribiendo en distintas tablas usando composite writers (con algunos condicionantes):

    - -

    Esta técnica sólo puede usarse con MyBatis 3.2+, por que había un - error - en las versiones anteriores que hacían que el writer funcionara de forma incorrecta. -

    - -

    Si el batch necesita escribir datos complejos, como registros con asociaciones, o en distintas bases de datos, - entonces es necesario sortear el problema de que los insert statements solo pueden escribir en una tabla. - Para conseguir esto debes preparar un Item para que sea escrito por el writer. Sin embargo, - dependiendo de las circunstancias puede ser interesante usar la siguiente técnica. - El truco siguiente funciona con items con asociaciones simples o con tablas no relacionadas. -

    - -

    - Elabora el item de forma que contenta todos los resgistros distintos. - Supon que para cada item hay una Interaction que tiene una asociación - InteractionMetadata y dos filas no asociadas VisitorInteraction and - CustomerInteraction. El objeto contenedor será de la siguiente forma: -

    - - - -

    - Entonces en la configuración de spring habrá un CompositeItemWriter que usará writers - delegados configurados especificamente para cada tipo de registro. Fijate que el InteractionMetadata - es una asociacióin en el ejemplo por lo que debe ser escrita antes para que la Interaction pueda recibir la clave - generada. -

    - - - - - - - - - - - - -]]> - - interactionsItemWriter() { - CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); - List> writers = new ArrayList<>(4); - writers.add(visitorInteractionsWriter()); - writers.add(customerInteractionsWriter()); - writers.add(interactionMetadataWriter()); - writers.add(interactionWriter()); - compositeItemWriter.setDelegates(writers); - return compositeItemWriter; -}]]> - -

    Cada writer delegados se configura como sea necesario, por ejemplo para Interaction y - InteractionMetadata: -

    - - -]]> - -

    Al igual que con el reader el statementId puede hacer referencia al statement con un namespace como prefijo.

    - -

    Ahora es debe elaborarse el fichero de mapeo para cada tipo de registro, de la siguiente forma:

    - - - - - - -]]> - -

    - Lo que sucede es que primeramente se llamará a insertInteractionMetadata, y la sentencia de update - está configurada para devolver las claves autogeneradas (keyProperty y keyColumn). - Una vez que el InteractionMetadata se ha almacenado por esta sentencia se puede ejecutar la siguiente para - escribir el objeto padre Interaction mediante insertInteraction. -

    - -

    - Sin embargo, ten en cuenta que los drivers JDBC se comportan distinto en este aspecto. A la fecha en la que se escribe esto - el driver H2 1.3.168 solo devuelve el último ID incluso en modo BATCH (see org.h2.jdbc.JdbcStatement#getGeneratedKeys), - mientras que el driver JDBC de MySQL se comporta como es de esperar y devuelve todos los IDs. -

    -
    - - - diff --git a/src/site/es/xdoc/boot.xml b/src/site/es/xdoc/boot.xml deleted file mode 100644 index fd430114c4..0000000000 --- a/src/site/es/xdoc/boot.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - MyBatis-Spring | Spring Boot - Eduardo Macarron - - - -
    -

    - Please see the MyBatis Spring-boot-starter - subproject docs for details. -

    -
    - -
    diff --git a/src/site/es/xdoc/factorybean.xml b/src/site/es/xdoc/factorybean.xml deleted file mode 100644 index a3000ac76b..0000000000 --- a/src/site/es/xdoc/factorybean.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - MyBatis-Spring | SqlSessionFactoryBean - Hunter Presnall - Eduardo Macarron - - - -
    -

    - En MyBatis una SqlSessionFactory se crea mediante la clase - SqlSessionFactoryBuilder. En MyBatis-Spring se usa la clase - SqlSessionFactoryBean en su lugar. -

    - - -

    - Para crear un factory bean, pon lo siguiente en el fichero XML de configuración de Spring: -

    - - -]]> -

    - La clase SqlSessionFactoryBean implementa el interfaz FactoryBean - (see the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-)). - Lo cual significa que el bean que crea Spring - en última instancia no es un SqlSessionFactoryBean en si mismo, sino el - objeto que la factoria devuelve como resultado de la llamada al método - getObject(). En este caso, Spring creará un bean - SqlSessionFactory durante el arranque de la aplicación y lo guardará bajo el nombre - sqlSessionFactory. En Java, el código equivalente sería: -

    - - - -

    - Normalmente no necesitarás utilizar directamente un SqlSessionFactoryBean - o su correspondiente SqlSessionFactory directly. - En su lugar, la factoría se utilizará para ser inyectada en MapperFactoryBeans o - DAOs que extiendan de SqlSessionDaoSupport. -

    -
    - - - -

    - La clase SqlSessionFactory solo tiene una propiedad obligatoria, un DataSource. - Puede ser cualquier DataSource y se puede configurar como cualquier otra conexión a base de daots de Spring. -

    - -

    - Una propiedad muy común es la configLocation que se utiliza para indicar la localización del fichero de configuración - XML de MyBatis. Normalmente solo es necesario dicho fichero si se requiere cambiar los valores por defecto de las secciones - <settings> o <typeAliases>. -

    - -

    - Es importante saber que este fichero de configuración no tiene por qué ser un fichero de configuración de MyBatis completo. - Concretamente, los environments, dataSources y transactionManagers serán ignorados. - SqlSessionFactoryBean crea su propio Environment de MyBatis con los valores configurados tal y como se requieren. -

    - -

    - Otro motivo para necesitar un fichero de configuración es que los ficheros de mapeo XML no estén en el mismo lugar del classpath - que los mapper interfaces. En este caso hay dos opciones. La primera es especificar manualmente el classpath de los ficheros XML - usando la sección <mappers> del fichero de configuración de MyBatis. La segunda opción es usar la propiedad - mapperLocations del factory bean. -

    - -

    - La propiedad mapperLocations recibe una lista de localizaciones de recursos. Se utiliza para indicar la ubicación de los - ficheros de mapeo XML de MyBatis. El valor puede contener un patron tipo Ant para cargar todos los ficheros de un directorio o - buscar de forma recursiva en todos los paths desde una localización base. Por ejemplo: -

    - - - - -]]> - -

    - Esto cargaría todos los ficheros de mapeo XML en el paquete sample.config.mappers y sus subpaquetes. -

    - -

    - Otra propiedad que puede ser necesaria en un entorno con transacciones gestionadas por contenedor es la - transactionFactoryClass. Lee la sección de transacciones para obtener más detalles. -

    - -

    - En caso de usar la característica multi-db necesitarás informar la propiedad databaseIdProvider - de la siguiente forma: -

    - - - - - sqlserver - db2 - oracle - mysql - - - - - - - - -]]> - -

    - NOTE - Since 1.3.0, configuration property has been added. - It can be specified a Configuration instance directly without MyBatis XML configuration file. - For example: -

    - - - - - - - - -]]> - -
    -
    - -
    diff --git a/src/site/es/xdoc/getting-started.xml.vm b/src/site/es/xdoc/getting-started.xml.vm deleted file mode 100644 index 5b4f2c5dad..0000000000 --- a/src/site/es/xdoc/getting-started.xml.vm +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - MyBatis-Spring | Primeros pasos - Hunter Presnall - Eduardo Macarron - - - -
    -

    - Este capítulo te mostrará en pocos pasos cómo instalar y configurar MyBatis-Spring y cómo construir - una pequeña aplicación transaccional. -

    - - -

    - Para usar el módulo MyBatis-Spring, debes incluir el fichero - mybatis-spring-${project.version}.jar - y sus dependencias en el classpath. -

    -

    - Si usas Maven simplemente añade la siguiente dependencia a tu pom.xml: -

    - - org.mybatis - mybatis-spring - ${project.version} -]]> -
    - - -

    - Para usar MyBatis con Spring necesitas definir al menos dos cosas en tu contexto Spring: una - SqlSessionFactory y al menos un mapper interface. -

    - -

    - En MyBatis-Spring se usa un - SqlSessionFactoryBean - para crear una - SqlSessionFactory - . Para configurar la factory bean pon lo siguiente en tu - fichero de configuración de Spring: -

    - - - -]]> - - - -

    - Observa que la SqlSessionFactory - requiere un - DataSource - . Éste puede ser cualquier - DataSource - y debe configurarse como cualquier otra conexión a base de datos - de Spring. -

    - -

    - Asumamos que tienes un mapper interface definido de la siguiente forma: -

    - - -

    - Este interface se añade a Spring usando un - MapperFactoryBean - de la siguiente forma: -

    - - - -]]> - -

    - Observa que la clase del mapper indicada - debe - ser un interface, no una implementación. En este ejemplo se usan - anotaciones para especificar la SQL, pero también es posible - usar un fichero de mapeo XML. -

    - -

    - Una vez configurado, puedes inyectar mappers directamente en tus - beans de servicio/negocio de la misma forma que inyectarías cualquier - otro bean en Spring. - La clase MapperFactoryBean se encargará de obtener - una SqlSession y de cerrarla. Si hay una transación Spring - en curso, la sesión se comitará o se hará rollback cuando la transacción - finalice. Finalmente, cualquier excepción será traducida a una excepión - DataAccessExceptions de Spring. -

    - -

    - If you use the Java Configuration: -

    - - - -

    - Invocar a MyBatis es sólo una línea de código: -

    - -
    -
    - -
    diff --git a/src/site/es/xdoc/index.xml b/src/site/es/xdoc/index.xml deleted file mode 100644 index 1e7aa83162..0000000000 --- a/src/site/es/xdoc/index.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - MyBatis-Spring | Introducción - Hunter Presnall - Eduardo Macarron - - - -
    - -

    - MyBatis-Spring permite integrar MyBatis con Spring. - Esta librería permite que MyBatis participe en trasacciones Spring, se encarga de constuir - mappers y SqlSessions e inyectarlos en otros beans, traduce excepciones - de MyBatis en excepcines DataAccessExceptions de Spring y finalmente, - permite construir aplicaciones libres de dependencias de MyBatis, Spring y MyBatis-Spring. -

    -
    - - -

    - Spring version 2 sólo soporta iBATIS version 2. See hizo un intento de incluir el soporte - de MyBatis 3 en Spring 3 (ver el issue Jira). - Pero desafortunadamente, el desarrollo de Spring 3 finalizó antes de que MyBatis 3 fuera liberado oficialmente. - Dado que el equipo de Spring no quería liberar una versión basada en un producto no terminado el soporte de - oficial tenía que esperar. Dado el interés de la comunidad en el soporte de MyBatis, - la comunidad de MyBatis decidió que era el momento de unificar a los colaboradores interesados - y proporcionar la integración con Spring como un sub-projecto de MyBatis en su lugar. -

    -
    - - -

    - Antes de comenzar con MyBatis-Spring, es muy importante que estés familiarizado con la terminología tanto de - MyBatis como de Spring. Este documento no pretende proporcionar información de configuración básica de - MyBatis o Spring. -

    -

    - MyBatis-Spring requires following versions: -

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - MyBatis-Spring - - MyBatis - - Spring Framework - - Spring Batch - - Java -
    - 2.0 - - 3.5+ - - 5.0+ - - 4.0+ - - Java 8+ -
    - 1.3 - - 3.4+ - - 3.2.2+ - - 2.1+ - - Java 6+ -
    -
    - - -

    - Queremos agradecer a la todos los que han hecho de este proyecto una realidad (en orden alfabético): - Eduardo Macarron, Hunter Presnall y Putthiphong Boonphong por la codificación, pruebas y documentación; - a Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan y Tomas Pinos - por sus contribuciones; y a Simone Tripodi por encontrarlos a todos y traerlos al proyecto MyBatis ;) - Sin ellos este proyecto no existiría. -

    -
    - - -

    - Si ves que hay alguna carencia en esta documentación, o que falta alguna característica por documentar, - te animamos a que lo investigues y la documentes tu mismo! -

    -

    - Las fuentes de este manual están disponibles en formato xdoc en el - Git del proyecto. - Haz un fork, cambialas y envía un pull request. -

    -

    - Eres el mejor candidato para documentar porque los lectores de esta documentación son gente como tú! -

    -
    - -

    Users can read about MyBatis-Spring in the following translations:

    - -

    Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your - mother tongue documentation!

    -
    -
    - - - diff --git a/src/site/es/xdoc/mappers.xml b/src/site/es/xdoc/mappers.xml deleted file mode 100644 index 26f6b45683..0000000000 --- a/src/site/es/xdoc/mappers.xml +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - MyBatis-Spring | Inyectar mappers - Hunter Presnall - Eduardo Macarron - - - -
    -

    - En lugar de codificar DAOs (data access objects) manualmente usando la clase - SqlSessionDaoSupport o SqlSessionTemplate, Mybatis-Spring - puede crear un mapper thread-safe que puedes inyectar directamente en otros beans. -

    - - - -]]> - -

    - Una vez inyectado, el mapper está listo para se usado en la lógica de aplicación: -

    - -

    - Observa que no se usa la SqlSession ni ninguna otra referencia a MyBatis en este código. - No es necesario ni siquiera crear o cerrar la sesión, MyBatis-Spring se encarga de ello. -

    - - - -

    - La forma de registrar un mapper varía según si quieres usar la configuración XML clásica o la nueva Java Config de Spring 3.0+ - (También conocida como @Configuration).

    - -

    Con confiugración XML

    - -

    - Un mapper se registra en Spring incluyendo un MapperFactoryBean en tu fichero de configuración XML, de la siguiente forma: -

    - - - -]]> - -

    - Si el mapper UserMapper tiene un fichero XML de mapeo asociado el MapperFactoryBean - lo cargará automáticamente. Por lo tanto no es necesario especificar dicho mapper en el fichero - de configuración de MyBatis a no ser que los ficheros XML estén en una lugar distinto del classpath. - Ver la sección de SqlSessionFactoryBean y la propiedad - configLocation - para más información. -

    - -

    - El MapperFactoryBean requiere o un - SqlSessionFactory o un SqlSessionTemplate. - Ambos se pueden informar usando sendas propiedades sqlSessionFactory y - sqlSessionTemplate. - Si ambas propiedades han sdo informadas la SqlSessionFactory se ignora. - Dado que un SqlSessionTemplate debe tener un session factory - dicho factory se usará por el MapperFactoryBean. -

    - -

    Con Java Config

    - - userMapper() throws Exception { - MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); - factoryBean.setSqlSessionFactory(sqlSessionFactory()); - return factoryBean; -}]]> - -
    - - -

    - No es necesario registrar los mappers uno por uno en el fichero XML de Spring. - En lugar de esto, puede dejar que MyBatis-Spring los busque en tu classpath. -

    - -

    - Hay tres formas distintas de hacerlo: -

    -
      -
    • Usando el elemneto <mybatis:scan/>.
    • -
    • Usando la anotación @MapperScan
    • -
    • Usando un fichero clásico XML de configuración de Spring y añadiendo el bean MapperScannerConfigurer
    • -
    - -

    Tango <mybatis:scan/> como @MapperScan son características añadidas en MyBatis-Spring 1.2.0. - @MapperScan requiere Spring 3.1+.

    - -

    - Since 2.0.2, mapper scanning feature support a option (lazy-initialization) - that control lazy initialization enabled/disabled of mapper bean. - The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. - The default of this option is false (= not use lazy initialization). - If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. -

    -

    - IMPORTANT If use the lazy initialization feature, - the developer need to understand following limitations. If any of following conditions are matches, - usually the lazy initialization feature cannot use on your application. -

    -
      -
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • -
    • When includes to the fragment of other mapper using ]]>
    • -
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • -
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • -
    - -

    - NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: -

    - - - -

    - Since 2.0.6, the develop become can specified scope of mapper using mapper scanning feature option(default-scope) - and scope annotation(@Scope, @RefreshScope, etc ...). - The motivation for adding this option is supporting the refresh scope provided by the Spring Cloud. - The default of this option is empty (= equiv to specify the singleton scope). - The default-scope apply to the mapper bean(MapperFactoryBean) when scope of scanned bean definition - is singleton(default scope) and create a scoped proxy bean for scanned mapper when final scope is not singleton. -

    - -

    <mybatis:scan/>

    - -

    - El elemento XML <mybatis:scan/> busca mappers de una forma muy similar a cómo - <context:component-scan/> busca beans. -

    - -

    A continuación se muestra un fichero XML de configuración:

    - - - - - - - -]]> - -

    - La propiedad basePackage te permite indicar el paquete base donde residen tus mappers. - Puedes indicar más de un paquete usando un punto y coma o una coma como separador. Los mappers serán buscados - de forma recursiva comenzando en el/los paquetes especificados. -

    - -

    - Fíjate que no es necesario indicar una SqlSessionFactory o - SqlSessionTemplate porque el <mybatis:scan/> - creará MapperFactoryBeans que pueden ser autowired. Pero si usas más de un DataSource - el autowire puede que no te funcione. En este caso puedes usar las propiedades factory-ref or - template-ref para indicar los beans correctos a utilizar. -

    - -

    - <mybatis:scan/> soporta el filtrado de mappers mediante una interfaz marcador o una anotación. - La propiedad annotation especifica la anotación que se debe buscar. - La propiedad marker-interface especifica la interfaz a buscar. - Si se indican ambas se añadirán todos los mappers que cumplan cualquier criterio. - Por defecto ambas propiedades son null asi que todos los interfaces de los paquetes base serán cargados como mappers. -

    - -

    - Los mappers descubiertos serán nombrados usando la estratégia de nombres por defecto de Spring para los componentes - autodetectados (see the Spring reference document(Core Technologies -Naming autodetected components-)). - Es decir, si no se encuentra ninguna anotación, se usará el nombre no cualificado sin capitalizar del mapper. - Pero si se encuentra una anotación @Component o JSR-330 @Named se obtendrá el nombre de dicha anotación. - Fíjate que puedes usar como valor de la annotation el valor org.springframework.stereotype.Component, - javax.inject.Named (if you have JSE 6) o una anotación propia - (que debe ser a su vez anotada) de forma que la anotación hará las veces de localizador y de proveedor de nombre. -

    - -

    - NOTE <context:component-scan/> - no puede encontrar y registrar mappers. Los mappers son interfaces y, para poderlos registrar en Spring, - el scanner deben conocer cómo crear un MapperFactoryBean para cada interfaz encontrado. -

    - -

    @MapperScan

    - -

    - Si usas la Java Configuration de Spring (@Configuration) posiblemente prefieras usar - @MapperScan en lugar de <mybatis:scan/>. -

    - -

    La anotación @MapperScan se usa de la siguiente forma:

    - - - -

    - La anotación fucniona exactamente igual que <mybatis:scan/> que hemos visto en la sección anterior. - También te permite especificar un interfaz marcador o una anotación mediante sus propiedades - markerInterface y annotationClass. - Tambien puedes indicar una SqlSessionFactory o un SqlSessionTemplate específicos - mediante las propiedades sqlSessionFactory y sqlSessionTemplate. -

    - -

    - NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. -

    - -

    MapperScannerConfigurer

    - -

    - MapperScannerConfigurer es un BeanDefinitionRegistryPostProcessor - que se puede incluir como un bean normal en el fichero clásico XML de configuración de Spring. - Para configurar un MapperScannerConfigurer añade lo siguiente al fichero de configuración de Spring: -

    - - -]]> - -

    - Si quieres indicar un sqlSessionFactory o un sqlSessionTemplate - observa que se requeiren los nombres de los beans y no sus referencias - por ello se usa el atributo value en lugar del habitual ref: -

    - ]]> - -
    -
    - -
    diff --git a/src/site/es/xdoc/sample.xml b/src/site/es/xdoc/sample.xml deleted file mode 100644 index cd0620f742..0000000000 --- a/src/site/es/xdoc/sample.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - MyBatis-Spring | Sample Code - Eduardo Macarron - - - -
    - -

    - NOTE - See JPetstore 6 demo to know about how to use Spring with a full web application server. -

    - -

    - You can check out sample code from the MyBatis-Spring repo: -

    -

    - Any of the samples can be run with JUnit 5. -

    -

    - The sample code shows a typical design where a transactional service gets domain objects from a data access layer. -

    -

    - FooService.java acts as the service: -

    - -

    - It is a transactional bean, so when the method is called, the transaction is started - and the transaction is committed when the method ends without throwing an uncaught exception. - Notice that transactional behaviour is configured with the - @Transactional - attribute. This is not required; any other way provided by Spring can be used to demarcate - your transactions. -

    -

    - This service calls a data access layer built with MyBatis. This layer - consists on a just an interface UserMapper.java - that will be used with a dynamic proxy built by MyBatis at - runtime and injected into the service by Spring. -

    - -

    - Note that, for the sake of simplicity we used the interface UserMapper.java for the DAO scenario - where a DAO is built with an interface and a implementation though in this case it would have been more - adequate to use an interface called UserDao.java instead. -

    -

    - We will see different ways to find the mapper interface, register it to Spring and inject it into the service bean: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Scenarios
    Sample testDescription
    - SampleMapperTest.java - - Shows you the base configuration based on a MapperFactoryBean - that will dynamically build an implementation for UserMapper -
    - SampleScannerTest.java - - Shows how to use the MapperScannerConfigurer so all the mappers in a project are autodiscovered. -
    - SampleSqlSessionTest.java - - Shows how to hand code a DAO using a Spring managed SqlSession - and providing your own implementation UserDaoImpl.java. -
    - SampleEnableTest - - Shows how to use Spring's @Configuration with the @MapperScann annotation so - mappers are autodiscovered. -
    - SampleNamespaceTest - - Shows how to use the custom MyBatis XML namespace. -
    - SampleJavaConfigTest.java - - Shows how to use Spring's @Configuration to create MyBatis beans manually. -
    - SampleJobJavaConfigTest.java - - Shows how to use ItemReader and ItemWriter on Spring Batch using Java Configuration. -
    - SampleJobXmlConfigTest.java - - Shows how to use ItemReader and ItemWriter on Spring Batch using XML Configuration. -
    -

    - Please take a look at the different applicationContext.xml files to see MyBatis-Spring in action. -

    - -
    - -
    - diff --git a/src/site/es/xdoc/sqlsession.xml b/src/site/es/xdoc/sqlsession.xml deleted file mode 100644 index 925a7552b9..0000000000 --- a/src/site/es/xdoc/sqlsession.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - MyBatis-Spring | Utilizar un SqlSession - Hunter Presnall - Eduardo Macarron - - - -
    -

    - En MyBatis usas un SqlSessionFactory para crear un SqlSession. - Una vez tienes una sesión, la usas para ejecutar tus mapped statements, hacer commit o rollback y finalmente - cuando no la necesitas la cierras. Con MyBatis-Spring no es necesario que utilices la SqlSessionFactory - directamente porque puedes inyectar en tus beans una SqlSession thread safe (reentrante) - que hará de forma automática el commit, rollback y se cerrará conforme a la configuración de la transacción en Spring. -

    - - -

    - El SqlSessionTemplate is el corazón de MyBatis-Spring. - Implementa SqlSession y está pensado para que sea directamente reemplazable por cualquier código - que actualmente use SqlSession. - SqlSessionTemplate es thread safe y se puede compartir por más de un DAO. -

    - -

    - Cuando se invoca a cualquier método SQL, incluyendo cualquier método de un mapper devuelto por - getMapper(), el SqlSessionTemplate - se asegurará de que la SqlSession utilizada es la asociada con la transacción Spring en curso. - Adicionalmente, se encarga de gestionar su ciclo de vida, incluyendo su cierre, commit o rollback de la sesión si fuera necesario. -

    - -

    - Se debe usar siempre un SqlSessionTemplate en lugar de la implementación de sesión - por default MyBatis: DefaultSqlSession - porque el template puede participar en transacciones Spring y es thread safe con lo que puede ser inyectado - en múltiples mappers (proxies). Cambiar de uno a otro puede crear problemas de integridad de datos. -

    - -

    - El SqlSessionTemplate puede construirse usando un SqlSessionFactory como argumento de su constructor. -

    - - -]]> - - - -

    - Este bean puede ser inyectado directamente en tus DAOs. Necesitarás una propiedad - SqlSession en tu bean como se muestra a continuación: -

    - -

    - E inyectar el SqlSessionTemplate de la siguiente forma: -

    - - -]]> - -

    - El SqlSessionTemplate tiene también un constructor que recibe como parámetro - un ExecutorType. Esto permite construir, por ejemplo, - una SqlSession batch utilizando la siguiente configuracíon de Spring: -

    - - - -]]> - - - -

    - Ahora todos tus statements se ejecutarán en batch de forma que puedes programar lo siguiente: -

    - users) { - for (User user : users) { - sqlSession.insert("org.mybatis.spring.sample.mapper.UserMapper.insertUser", user); - } -}]]> - -

    - Fijate que esta configuración si el método de ejecución deseado es distinto del establecido por defecto - en el SqlSessionFactory. -

    - -

    - La contrapartida de esto es que no es posible cambiar el méodo de ejecución dentro de una transacción. - Por tanto asegurate que o bien todas las llamadas a un SqlSessionTemplates con distinto método de ejecución - se ejecutan en una transacción diferente (p.ej: with PROPAGATION_REQUIRES_NEW) o completamente fuera de la transacción. -

    -
    - - -

    - SqlSessionDaoSupport es una clase de soporte abstracta que proporciona un SqlSession. - Llamando a getSqlSession() obtiene un SqlSessionTemplate - que puedes utilizar para ejecutar métodos SQL, como sigue: -

    - -

    - Normalmente es preferible usar un MapperFactoryBean a esta clase dao que no requeire código extra. - Pero esta clase es de utilidad cuando es necesario hacer algún otro tipo de trabajo no-MyBatis en el DAO y se necesitan - clases concretas. -

    - -

    - SqlSessionDaoSupport que se informe la propiedad - sqlSessionFactory o la sqlSessionTemplate. - Si se informan ambas propiedades, la sqlSessionFactory se ignora. -

    - -

    - Asumiendo una clase UserDaoImpl que extiende - SqlSessionDaoSupport, se puede configurar Spring de la siguiente forma: -

    - - -]]> -
    -
    - -
    diff --git a/src/site/es/xdoc/transactions.xml b/src/site/es/xdoc/transactions.xml deleted file mode 100644 index 5bf472c578..0000000000 --- a/src/site/es/xdoc/transactions.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - MyBatis-Spring | Transacciones - Hunter Presnall - Eduardo Macarron - - - -
    -

    - Uno de los principales motivos para usar MyBatis-Spring es que permite que MyBatis participe en transacciones - de Spring. En lugar de haber creado un TransactionManager especifico para MyBatis, MyBatis-Spring aprovecha - el existente DataSourceTransactionManager de Spring. -

    -

    - Una vez que has configurado un TransactionManager in Spring puedes configurar tus transacciones en Spring como siempre. - Tanto las anotaciones @Transactional como las configuraciones de tipo AOP se soportan. - Se creará una sola instancia de SqlSession para toda la transacción. - Se hará commit o rollback de esta sesión cuando la transacción finalice. -

    -

    - MyBatis-Spring se encargará de gestionar las transacciones de forma transparente una vez se hayan configurado. No es necesario - incluir código adicional en tus clases. -

    - - -

    - Para habilitar las transacciones Spring, simplemente crea un DataSourceTransactionManager en tu fichero de configuración: -

    - - -]]> - - - -

    - El DataSource especificado puede ser cualquier DataSource JDBC que usarías normalmente con Spring. - Esto incluye connection pools y DataSources obtenidos mediante JNDI. -

    -

    - Fijate que el DataSource especificado en el transaction manager debe ser el mismo que el que se use para - crear el SqlSessionFactoryBean o la gestión de transacciones no funcionará. -

    -
    - - -

    - Si estás usando un contenedor JEE y quiere que spring participe en las transacciones gestionadas por contenedor (CMT), entonces debes - configurar un JtaTransactionManager en Spring o alguna de sus clases específicas de cada contenedor. - Lo más sencillo es utilizar el namespace tx de Spring or the JtaTransactionManagerFactoryBean: -

    - ]]> - - - -

    - Con esta configuración, MyBatis se comportará como cualquier otro recurso configurado con CMT. - Spring utilizará cualquier transacción CMT existente y asociará la SqlSession a ella. - Si no no hay ninguna transacción previa pero se necesita una en base a la configuración de la transacción, Spring creará - una transacción gestionada por contenedor nueva. -

    -

    - Fijate que si quieres usar transacciones CMT pero no quieres utilizar la gestión de transacciones de Spring - no debes configurar ningun transaction manager en Spring y debes - configurar el SqlSessionFactoryBean para que use la clase ManagedTransactionFactory de MyBatis de la siguiente forma: -

    - - - - - -]]> - - - -
    - - -

    - La interfaz SqlSession proporciona métodos especificos para gestionar la transacción. - Pero al usar MyBatis-Spring en tus beans se inyectará una SqlSession o un mapper gestionados por Spring. - Esto significa que Spring siempre gestionará tus transacciones. -

    -

    - No puedes llamar a los métodos SqlSession.commit(), SqlSession.rollback() - o SqlSession.close() en una SqlSession gestionada por Spring. - Si lo intentas obtendrás una excepción UnsupportedOperationException. - Además, estos métodos no se exponen en los mapper interfaces. -

    -

    - Independientemente de el estado del autocommit de la conexión JDBC cualquier llamada - a un metodo SQL de SqlSession fuera de una transacción Spring será automaticamente commitada. -

    -

    - Si quieres controlar las transacciones programaticamente consulta el the Spring reference document(Data Access -Programmatic transaction management-). - Este código muetra como controlar una transacción manualmente usando el PlatformTransactionManager. -

    - - -

    - You can omit to call the commit and rollback method using the TransactionTemplate. -

    - - { - userMapper.insertUser(user); - return null; -});]]> - -

    - Este código usa un mapper pero también funcionaría con SqlSession. -

    -
    -
    - -
    diff --git a/src/site/es/xdoc/using-api.xml b/src/site/es/xdoc/using-api.xml deleted file mode 100644 index f07f473f3c..0000000000 --- a/src/site/es/xdoc/using-api.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - MyBatis-Spring | Using the MyBatis API - Hunter Presnall - Eduardo Macarron - - - -
    -

    - With MyBatis-Spring, you can continue to directly use the MyBatis API. - Simply create an SqlSessionFactory in Spring using - SqlSessionFactoryBean and use the factory in your code. -

    - - -

    - Use this option with care because wrong usage may produce runtime errors or - worse, data integrity problems. Be aware of the following caveats with direct API usage: -

    -
      -
    • -

      - It will not participate in any Spring transactions. -

      -
    • -
    • -

      - If the SqlSession is using a DataSource - that is also being used by a Spring transaction manager and there is currently - a transaction in progress, this code will throw an exception. -

      -
    • -
    • -

      - MyBatis' DefaultSqlSession is not thread safe. If you - inject it in your beans you will get errors. -

      -
    • -
    • -

      - Mappers created using DefaultSqlSession are not thread safe either. - If you inject them it in your beans you will get errors. -

      -
    • -
    • -

      - You must make sure that your SqlSessions - are always closed in a finally block. -

      -
    • -
    -
    - -
    diff --git a/src/site/ja/markdown/README.md b/src/site/ja/markdown/README.md new file mode 100644 index 0000000000..3280241e0c --- /dev/null +++ b/src/site/ja/markdown/README.md @@ -0,0 +1,18 @@ +# 目次 + +このページはGitHub上でドキュメントの目次を表示するため用意したものです。 + +> **NOTE:** +> +> リンクはmaven-site-pluginでHTMLに変換することを前提に指定されているため、GitHubでのレンダリングではリンク切れになっているものがあります。 + +* [イントロダクション](./index.md) +* [スタートガイド](./getting-started.md) +* [SqlSessionFactoryBean](./factorybean.md) +* [トランザクション](./transactions.md) +* [SqlSessionの利用](./sqlsession.md) +* [Mapperの注入](./mappers.md) +* [Spring Boot](./boot.md) +* [MyBatis APIの利用](./using-api.md) +* [Spring Batch](./batch.md) +* [サンプルコード](./sample.md) diff --git a/src/site/ja/markdown/batch.md b/src/site/ja/markdown/batch.md new file mode 100644 index 0000000000..0c0d55257e --- /dev/null +++ b/src/site/ja/markdown/batch.md @@ -0,0 +1,344 @@ + +# Spring Batch + +MyBatis-Spring 1.1.0 以降では、 Spring Batch を構築するための Bean として `MyBatisPagingItemReader` 、 `MyBatisCursorItemReader` 、 `MyBatisBatchItemWriter` が用意されています。 +また、2.0.0 以降では、Java Configuration をサポートするための Builder クラスとして `MyBatisPagingItemReaderBuilder` 、 `MyBatisCursorItemReaderBuilder` 、 `MyBatisBatchItemWriterBuilder` が用意されています。 + +NOTE +ここで扱うのは [Spring Batch](http://static.springsource.org/spring-batch/) を使ったバッチ処理で、MyBatis の [`SqlSession`](sqlsession.html) を利用したバッチ処理ではありません。 + +## MyBatisPagingItemReader + +この Bean は、MyBatis を利用してデータベースからページ単位でレコードを読み出す `ItemReader` です。 + +結果を取得する際は `setQueryId` プロパティで指定したクエリが実行されます。1ページあたりの件数は setPageSize プロパティで指定することができます。 +`read()` メソッドが呼び出されると、必要に応じて追加のページを取得するクエリが実行されます。 +実行されるクエリでは、Reader によって提供されるページング処理を行う際に必要となるパラメーターを使って期待される結果を返す SQL 文を記述することになります(実際の SQL 文は方言依存です)。 +提供されるパラメーターは次の通りです。 + +* `_page`: 取得対象のページ番号(最初のページは0 +* `_pagesize`: 1ページあたりの件数 +* `_skiprows`: `_page` と `_pagesize` の積 + +これらのパラメーターは、例えば次のように SELECT 文中で指定することができます。 + +```xml + +``` + +設定例: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisPagingItemReader reader() { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +**さらに複雑な例:** + +```xml + +``` +```xml + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @StepScope + @Bean + public MyBatisPagingItemReader dateBasedCriteriaReader( + @Value("#{@datesParameters}") Map datesParameters) throws Exception { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(batchReadingSessionFactory()) + .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") + .parameterValues(datesParameters) + .pageSize(200) + .build(); + } + + @StepScope + @Bean + public Map datesParameters( + @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, + @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { + Map map = new HashMap<>(); + map.put("yesterday", yesterday); + map.put("today", today); + map.put("first_day_of_the_month", firstDayOfTheMonth); + map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); + return map; + } +} +``` + +The previous example makes use of a few different things: + +* `sqlSessionFactory`: あなた自身の sessionFactory を reader に指定することができます。複数のデータベースから読み取る場合は有用かも知れません。 +* `queryId`: レコード取得時に実行されるクエリの ID を指定します。異なるネームスペースに属するクエリを指定する場合はネームスペースの指定を忘れないようにしてください。 +* `parameterValues`: クエリ実行時に使用する追加のパラメーターを Map 形式で渡すことができます。上の例では Spring が `jobExecutionContext` から SpEL 式を使って取得した値をもとに構築した `Map` を指定しています。 + MyBatis の Mapper ファイルでは `Map` のキーをパラメーター名として指定します(例: *yesterday* を指定する場合は `#{yesterday,jdbcType=TIMESTAMP}` のように指定します)。 + `jobExecutionContext` と Spring EL 式を利用するため、`Map` および `Reader` はどちらも `step` スコープ内で構築されているという点に注意してください。 + また、MyBatis の `TypeHandler` が正しく設定されていれば、この例のように JodaTime のようなカスタムのインスタンスを引数として渡すこともできます。 +* `pageSize`: バッチ処理のチャンクサイズを指定します。 + +## MyBatisCursorItemReader + +This bean is an `ItemReader` that reads records from a database using a cursor. + +NOTE +To use this bean you need at least MyBatis 3.4.0 or a newer version. + +It executes the query specified as the `setQueryId` property to retrieve requested data by using the method `selectCursor()`. +Each time a `read()` method is called it will return the next element of the cursor until no more elements are left. + +The reader will use a separate connection so the select statement does no participate in any transactions created as part of the step processing. + +When using the cursor you can just execute a regular query: + +```xml + +``` + +Follows below a sample configuration snippet: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisCursorItemReader reader() { + return new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +## MyBatisBatchItemWriter + +`SqlSessionTemplate` のバッチ機能を使って渡された一連のアイテムを処理する `ItemWriter` です。 `SqlSessionFactory` は `ExecutorType.BATCH` を使って設定する必要があります。 + +`write()` の呼び出し時に実行するステートメントの ID を指定しておく必要があります。 `write()` はトランザクション内で呼び出されることを前提としています。 + +設定例: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") + .build(); + } +} +``` + +**`ItemReader`を使用して読み込んだアイテムを任意のパラメータオブジェクトへ変換する** + +デフォルトの動作では、`MyBatisBatchItemWriter` は `ItemReader` を使用して読みこんだアイテム (または `ItemProcessor` によって変換したアイテム)を、そのままMyBatis(`SqlSession` の `update` メソッド)のパラメーターオブジェクトとして渡します。 +もしMyBatisへ渡すパラメーターオブジェクトをカスタマイズしたい場合は、`itemToParameterConverter` オプションを利用することで実現するすることができます。 +たとえば、`itemToParameterConverter` オプションを使用すると、 アイテムオブジェクト以外のオブジェクトをMyBatisへ渡すことができます。 +以下にサンプルを示します。 + +まず、任意のパラメータオブジェクトに変換するためのコンバータクラス(またはファクトリメソッド)を作成します。以下のサンプルではファクトリメソッドを使用します。 + +```java +public class ItemToParameterMapConverters { + public static Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; + } +} +``` + +つぎに, SQLマッピングを書きます。 + +```xml + +``` + +さいごに, `MyBatisBatchItemWriter` の設定を行います。 + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() throws Exception { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); + } +} +``` + +```xml + + + + + + + + + + +``` + +**Composite Writer を使って複数のテーブルに書き込む(注意事項あり)** + +このテクニックを使うには MyBatis 3.2 以降が必要です。それ以前のバージョンには [問題](http://code.google.com/p/mybatis/issues/detail?id=741) があるため、Writer が期待通りに動作しません。 + +まず、*Interaction* と1対1の関係にある *InteractionMetadata* と、これらとは独立した *VisitorInteraction* および *CustomerInteraction* を保持する Item クラスを用意します。 + +```java +public class InteractionRecordToWriteInMultipleTables { + private final VisitorInteraction visitorInteraction; + private final CustomerInteraction customerInteraction; + private final Interaction interaction; + // ... +} +``` +```java +public class Interaction { + private final InteractionMetadata interactionMetadata; +} +``` + +`CompositeItemWriter` の設定では、それぞれのオブジェクトの writer を順番に呼び出すように設定します。 +この例では *Interaction* をアップデートするためのキーを取得するため、*InteractionMetadata* を先に書き込む必要があります。 + +```xml + + + + + + + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public CompositeItemWriter interactionsItemWriter() { + CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); + List> writers = new ArrayList<>(4); + writers.add(visitorInteractionsWriter()); + writers.add(customerInteractionsWriter()); + writers.add(interactionMetadataWriter()); + writers.add(interactionWriter()); + compositeItemWriter.setDelegates(writers); + return compositeItemWriter; + } +} +``` + +それぞれの writer を必要に応じて設定します。例えば *Interaction* と *InteractionMetadata* の設定は次のようになります。 + +```xml + +``` +```xml + +``` + +reader の場合と同様、 `statementId` はネームスペースを含むステートメント ID です。 + +Mapper ファイルにステートメントを定義します。 + +```xml + + + +``` +```xml + + + +``` + +はじめに `insertInteractionMetadata` が呼ばれ、その際に取得した主キーを使って親となる `Interaction` を `insertInteraction` を使って書き込むことができます。 + +***JDBC ドライバによって動作が異なるので注意が必要です。例えば MySQL の JDBC ドライバは作成された全ての行の ID を返しますが、H2 バージョン 1.3.168 ではバッチモードでも最後に作成された行の ID のみが返されます。*** diff --git a/src/site/ja/markdown/boot.md b/src/site/ja/markdown/boot.md new file mode 100644 index 0000000000..0243b87200 --- /dev/null +++ b/src/site/ja/markdown/boot.md @@ -0,0 +1,4 @@ + +# Using Spring Boot + +詳細は [MyBatis Spring-boot-starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure) のドキュメントを参照してください。 diff --git a/src/site/ja/markdown/factorybean.md b/src/site/ja/markdown/factorybean.md new file mode 100644 index 0000000000..f1fef7443c --- /dev/null +++ b/src/site/ja/markdown/factorybean.md @@ -0,0 +1,99 @@ + +# SqlSessionFactoryBean + +基となる MyBatis では、`SqlSessionFactory` をビルドする際 `SqlSessionFactoryBuilder` を使いましたが、MyBatis-Spring では、`SqlSessionFactoryBean` を使います。 + +## 設定 + +Spring の XML 設定ファイルに次の Bean を定義することで Factory Bean を生成することができます。 + +```xml + + + +``` + +`SqlSessionFactoryBean` は Spring の `FactoryBean` インターフェイス([the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-extension-factorybean) を参照してください)を実装しています。 +これはつまり、最終的に Spring が生成するのは `SqlSessionFactoryBean` ではなく、Factory の `getObject()` メソッドによって返されるオブジェクトであるということです。 +上記の設定では、Spring は `SqlSessionFactory` を生成し、`sqlSessionFactory` という名前の Bean として登録します。 +これに相当する Java のコードは下記のようになるでしょう。 + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +通常 MyBatis-Spring を使う場合、`SqlSessionFactoryBean` や対応する `SqlSessionFactory` を直接利用する必要はありません。 +`SqlSessionFactory` は `MapperFactoryBean` や `SqlSessionDaoSupport` を継承した他の DAO にインジェクト(注入)されます。 + +## プロパティ + +`SqlSessionFactory` で必須のプロパティは JDBC の `DataSource` のみです。 どのような `DataSource` でも構いません。Spring でデータベース接続を定義する通常の手順で定義してください。 + +`configLocation` は、MyBatis の XML 設定ファイルの場所を指定する際に使用します。これは、例えば基になる MyBatis の設定の一部を変更したい場合などに必要となります。 +よくあるのは `>settings>` や `` などの設定です。 + +ここで指定する設定ファイルは、完全な MyBatis 設定ファイルである必要はありません。 環境、データソース、MyBatis のトランザクションマネージャーに関する設定は**無視されます**。 +`SqlSessionFactoryBean` は、独自にカスタマイズした MyBatis `Environment` を生成し、必要に応じてこれらの値を設定するようになっています。 + +設定ファイルの指定が必要とされるもう一つの例は、MyBatis の Mapper XML ファイルが Mapper クラスとは別のクラスパスに存在する場合です。 +このような構成にする場合、次のどちらかの方法で設定することができます。最初の方法は、MyBatis の設定ファイルの `` で各 XML ファイルのクラスパスを指定する方法です。 +そしてもう一つは、Factory Bean の `mapperLocations` を使った方法です。 + +`mapperLocations` プロパティは Resource Location のリストを取り、ここで MyBatis の XML Mapper ファイルの場所を指定することができます。 +Ant スタイルのパターン文字列を使って特定のディレクトリ内の全ファイルを指定したり、内包するディレクトリを再帰的に検索対象にすることもできます。次の例を見てください。 + +```xml + + + + +``` + +このように指定すると、クラスパス内の `sample.config.mappers` パッケージと、そのサブパッケージに含まれる全ての MyBatis Mapper XML ファイルがロードされます。 + +Container-Managed トランザクションを利用する環境では、`transactionFactoryClass` プロパティが必須となります。「トランザクション」章の該当する節を参照してください。 + +複数のデータベースを使用する場合は、`databaseIdProvider` プロパティを設定する必要があります。 + +```xml + + + + sqlserver + db2 + oracle + mysql + + + +``` +```xml + + + + + +``` + +NOTE +1.3.0より、`configuration` プロパティが追加されました。このプロパティには、MyBatisのXML設定ファイルを使わずに`Configuration`インスタンスを直接指定することができます。 +次の例を見てください。 + +```xml + + + + + + + + +``` diff --git a/src/site/ja/markdown/getting-started.md b/src/site/ja/markdown/getting-started.md new file mode 100644 index 0000000000..d1ed42e4c1 --- /dev/null +++ b/src/site/ja/markdown/getting-started.md @@ -0,0 +1,100 @@ + +# スタートガイド + +この章では、MyBatis-Spring のインストール・設定手順と、トランザクション処理を含むシンプルなアプリケーションの構築する方法について説明します。 + +## インストール + +MyBatis-Spring を使うためには、 `mybatis-spring-${project.version}.jar` と依存するライブラリをクラスパスに追加するだけで OK です。 + +Maven をお使いの場合は、 pom.xml に次の dependency を追加してください。 + +```xml + + org.mybatis + mybatis-spring + ${project.version} + +``` + +## クイックセットアップ + +MyBatis と Spring を組み合わせて使う場合、Spring の Application Context 内に少なくとも `SqlSessionFactory` と一つ以上の Mapper インターフェイスを定義する必要があります。 + +MyBatis-Spring では `SqlSessionFactory` の生成に `SqlSessionFactoryBean` を使います。この Factory Bean を設定するため、Spring の 設定ファイルに次の Bean を追加してください。 + +```xml + + + +``` + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +`SqlSessionFactory` が `DataSource` を必要としている点に注意してください。どのような `DataSource` でも構いません。通常の手順で設定してください。 + +Mapper インターフェイスが次のように定義されている場合... + +```java +public interface UserMapper { + @Select("SELECT * FROM users WHERE id = #{userId}") + User getUser(@Param("userId") String userId); +} +``` + +`MapperFactoryBean` を使ってこのインターフェイスを Spring に登録する場合、以下のように設定します。 + +```xml + + + + +``` + +ここで指定した Mapper は、実装クラスではなく **インターフェイス** である必要がありますので注意してください。 +この例では、アノテーションを使って SQL を指定していますが、Mapper XML ファイルを使うこともできます。 + +上記のように設定しておけば、あとは他の Spring Bean と同様にビジネス/サービス層のオブジェクトにインジェクト(注入)することができます。 +`MapperFactoryBean` は `SqlSession` の生成とクローズを行います。 +もし Spring のトランザクション内で実行された場合は、トランザクション終了時にセッションがコミットあるいはロールバックされます。 +最後にもう一点、全ての例外は Spring の `DataAccessException` に変換されます。 + +Java Configurationを使用する場合: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public UserMapper userMapper() throws Exception { + SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); + return sqlSessionTemplate.getMapper(UserMapper.class); + } +} +``` + +MyBatis のデータメソッドは、一行だけで実行可能となります。 + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` diff --git a/src/site/ja/markdown/index.md b/src/site/ja/markdown/index.md new file mode 100644 index 0000000000..0c6adb2296 --- /dev/null +++ b/src/site/ja/markdown/index.md @@ -0,0 +1,52 @@ + +# イントロダクション + +## MyBatis-Spring とは? + +MyBatis-Spring によって MyBatis と Spring をシームレスに連携させることができます。このライブラリを使えば、MyBatis のステートメントを Spring のトランザクション内で実行することもできますし、Mapper や `SqlSession` の生成、他の Bean への注入、MyBatis の例外から Spring の `DataAccessException` への変換、さらには MyBatis や Spring, MyBatis-Spring に依存しないコードでアプリケーションを構築することも可能になります。 + +## 動機 + +Spring バージョン 2 は iBATIS バージョン 2 しかサポートしていません。Spring 3 の開発時に MyBatis 3 への対応が検討されました(こちらの [チケット](https://jira.springsource.org/browse/SPR-5991) 参照)が、Spring 3 が MyBatis 3 よりも前に正式リリースを迎えたため、残念ながら実装は見送られました。Spring 開発陣としては、未リリースの MyBatis 3 に合わせたコードをリリースしたくなかったという事情があり、Spring 側での正式対応は保留となっていました。MyBatis コミュニティの中で Spring 対応への要望が強かったため、有志によって Spring との連携を行う MyBatis のサブプロジェクトが立ち上げられました。 + +## 動作条件 + +MyBatis-Spring を利用するためには、MyBatis と Spring の用語について理解しておくことが重要です。このドキュメントには MyBatis や Spring についての説明や基本設定といった情報は含まれていません。 + +MyBatis-Spring は以下のバージョンを必要とします。 + +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +| --- | --- | --- | --- | --- | +| **2.0** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | + +## 謝辞 + +このプロジェクトの実現にご協力頂いた次の方々に感謝します(アルファベット順): +Eduardo Macarron, Hunter Presnall, Putthiphong Boonphong(コーディング、テスト、ドキュメント作成); +Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan, Tomas Pinos(コントリビューション); +Simone Tripodi(メンバーを集め、MyBatis のサブプロジェクトとしてまとめてくれました) +このプロジェクトは彼らの協力なしには実現できなかったでしょう。 + +## このドキュメントの改善にご協力ください... + +このドキュメントの中で誤りや特定の機能に関する記述が抜けていることに気づいたら、詳しく調べてドキュメントを更新して頂けると助かります。 + +このマニュアルのソースは markdown 形式で、[プロジェクトの Git リポジトリ](https://github.com/mybatis/spring/tree/master/src/site) で配布されています。 +リポジトリをフォーク、それらを更新します、とプルリクエストを送信します。 + +このドキュメントを必要としている人、つまりあなたこそが最高の著者なのです! + +## Translations + +MyBatis-Spring は以下の言語の翻訳を用意しています。 + + + +母国語でMyBatis Springのリファレンスを読んでみませんか? ぜひドキュメントを母国語へ翻訳するためのIssue(パッチ)を作成してください! diff --git a/src/site/ja/markdown/mappers.md b/src/site/ja/markdown/mappers.md new file mode 100644 index 0000000000..03dcb250a1 --- /dev/null +++ b/src/site/ja/markdown/mappers.md @@ -0,0 +1,188 @@ + +# Mapper の注入 + +MyBatis-Spring がスレッドセーフな Mapper を生成してくれるので、`SqlSessionDaoSupport` や `SqlSessionTemplate` を使って手動で DAO オブジェクトを生成するコードは不要となります。 +生成された Mapper は他の Bean に注入することができます。 + +```xml + + + +``` + +アプリケーション側の処理では、注入された Mapper のメソッドを呼び出すだけです。 + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` + +このコードには `SqlSession` や MyBatis への参照が含まれていない点に注目してください。また、セッションの生成やオープン、クローズも MyBatis-Spring が処理してくれるため不要となります。 + + +## Mapper の登録 + +Mapper を Bean として登録する方法は、Spring の設定を XML ファイルを使って行う場合と Spring 3.0 以降で導入された Java Config (= `@Configuration`) を使う場合で異なります。 + +### XML で設定する場合 + +XML ファイルを使って Spring を設定する場合、次のように `MapperFactoryBean` のエントリーを追加することで Mapper を Spring Bean として登録することができます。 + +```xml + + + + +``` + +ここで指定した UserMapper のインターフェイスと同じクラスパスに MyBatis の XML Mapper ファイルが配置されている場合は自動的にロードされます。 +XML Mapper が異なるクラスパスに配置されている場合を除けば、MyBatis の設定ファイルでこの Mapper を指定する必要はありません。 +詳しくは `SqlSessionFactoryBean` の [`configLocation`](factorybean.html) プロパティの説明を参照してください。 + +`MapperFactoryBean` を登録する際は `SqlSessionFactory` あるいは `SqlSessionTemplate` のどちらかを指定する必要があります。 +指定対象のプロパティは、それぞれ `sqlSessionFactory` と `sqlSessionTemplate` です。 +両方が指定された場合、 `SqlSessionFactory` の指定は無視され、`SqlSessionTemplate` の登録時に指定した Session Factory が使われます。 + +### Java Config で設定する場合 + +```java +@Configuration +public class MyBatisConfig { + @Bean + public MapperFactoryBean userMapper() throws Exception { + MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); + factoryBean.setSqlSessionFactory(sqlSessionFactory()); + return factoryBean; + } +} +``` + + +## Mapper の自動検出 + +上で説明した方法では Mapper を個別に指定していましたが、MyBatis-Spring では特定のクラスパスに含まれる Mapper を自動検出させることもできます。 + +これには3通りの方法があります。 + +* `` 要素を使う。 +* `@MapperScan` アノテーションを使う。 +* Spring の XML 設定ファイルに `MapperScannerConfigurer` のエントリーを追加する。 + +`` または `@MapperScan` を使う場合は MyBatis-Spring 1.2.0 以降が必要です。また `@MapperScan` を使う場合は Spring 3.1 以降が必要となります。 + +2.0.2以降では、Mapperの自動検出機能は、Mapper Beanの遅延初期化の有効/無効を制御するオプション(`lazy-initialization`)をサポートします。 +このオプションを追加する動機は、Spring Boot 2.2でサポートされた遅延初期化を制御する機能をサポートすることです。このオプションのデフォルトは`false`です(遅延初期化を使用しません)。 +開発者がMapper Beanを遅延初期化したい場合は、明示的にこのオプションを`true`に設定する必要があります。 + +重要 +遅延初期化機能を使用する場合は、開発者は以下の制限を理解しておく必要があります。以下の条件のいずれかに一致する場合、通常あなたのアプリケーションで遅延初期化機能を使用することはできません。 + +* ``(`@One`) and ``(`@Many`)を利用して、**他のMapperの**ステートメントを参照している場合 +* ``を利用して、**他のMapperの**フラグメントをインクルードしている場合 +* ``(`@CacheNamespaceRef`)を利用して、**他のMapperの**キャッシュを参照している場合 +* `]]> - -

    設定例:

    - - - - -
    ]]> - - reader() { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -

    さらに複雑な例:

    - - - - - - - - -]]> - - dateBasedCriteriaReader( - @Value("#{@datesParameters}") Map datesParameters) throws Exception { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(batchReadingSessionFactory()) - .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") - .parameterValues(datesParameters) - .pageSize(200) - .build(); -} - -@StepScope -@Bean -public Map datesParameters( - @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, - @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { - Map map = new HashMap<>(); - map.put("yesterday", yesterday); - map.put("today", today); - map.put("first_day_of_the_month", firstDayOfTheMonth); - map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); - return map; -}]]> - -

    - The previous example makes use of a few different things: -

    - -
      -
    • sqlSessionFactory: あなた自身の sessionFactory を reader に指定することができます。複数のデータベースから読み取る場合は有用かも知れません。
    • -
    • queryId: レコード取得時に実行されるクエリの ID を指定します。異なるネームスペースに属するクエリを指定する場合はネームスペースの指定を忘れないようにしてください。
    • -
    • parameterValues: クエリ実行時に使用する追加のパラメーターを Map 形式で渡すことができます。上の例では Spring がjobExecutionContext から SpEL 式を使って取得した値をもとに構築した Map を指定しています。 - MyBatis の Mapper ファイルでは Map のキーをパラメーター名として指定します(例: yesterday を指定する場合は #{yesterday,jdbcType=TIMESTAMP} のように指定します)。 - jobExecutionContext と Spring EL 式を利用するため、Map および reader はどちらも step スコープ内で構築されているという点に注意してください。 - また、MyBatis の Type Handler が正しく設定されていれば、この例のように JodaTime のようなカスタムのインスタンスを引数として渡すこともできます。
    • -
    • pageSize: バッチ処理のチャンクサイズを指定します。
    • -
    - -
    - - -

    - This bean is an ItemReader that reads records from a database using a cursor. -

    - -

    - NOTE To use this bean you need at least MyBatis 3.4.0 or a newer version. -

    - -

    - It executes the query specified as the setQueryId property to retrieve requested data - by using the method selectCursor(). - Each time a read() method is called it will return the next element of the cursor until no more - elements are left. -

    - -

    - The reader will use a separate connection so the select statement does no participate in any transactions created - as part of the step processing. -

    - -

    When using the cursor you can just execute a regular query:

    - - SELECT id, name, job FROM employees ORDER BY id ASC -]]> - -

    Follows below a sample configuration snippet:

    - - - - -]]> - - reader() { - return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -
    - - - -

    - SqlSessionTemplate のバッチ機能を使って渡された一連のアイテムを処理する ItemWriter です。 - SqlSessionFactoryExecutorType.BATCH を使って設定する必要があります。 -

    - -

    - write() の呼び出し時に実行するステートメントの ID を指定しておく必要があります。 - write() はトランザクション内で呼び出されることを前提としています。 -

    - -

    設定例:

    - - - - -]]> - - writer() { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") - .build(); -}]]> - - -

    ItemReaderを使用して読み込んだアイテムを任意のパラメータオブジェクトへ変換する

    - -

    - デフォルトの動作では、MyBatisBatchItemWriterItemReader を使用して読みこんだアイテム - (または ItemProcessor によって変換したアイテム)を、 - そのままMyBatis(SqlSessionupdate メソッド)のパラメーターオブジェクトとして渡します。 - もしMyBatisへ渡すパラメーターオブジェクトをカスタマイズしたい場合は、 - itemToParameterConverter オプションを利用することで実現するすることができます。 - たとえば、itemToParameterConverter オプションを使用すると、 アイテムオブジェクト以外のオブジェクトをMyBatisへ渡すことができます。 - 以下にサンプルを示します。 -

    - -

    - まず、任意のパラメータオブジェクトに変換するためのコンバータクラス(またはファクトリメソッド)を作成します。以下のサンプルではファクトリメソッドを使用します。 -

    - - Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { - return item -> { - Map parameter = new HashMap<>(); - parameter.put("item", item); - parameter.put("operationBy", operationBy); - parameter.put("operationAt", operationAt); - return parameter; - }; -}]]> - -

    - つぎに, SQLマッピングを書きます。 -

    - - - insert into persons (first_name, last_name, operation_by, operation_at) - values(#{item.firstName}, #{item.lastName}, #{operationBy}, #{operationAt}) -]]> - -

    - さいごに, MyBatisBatchItemWriterの設定を行います。 -

    - - writer() throws Exception { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") - .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) - .build(); -}]]> - - - - - - - - - - - - -]]> - - -

    Composite Writer を使って複数のテーブルに書き込む(注意事項あり)

    - -

    このテクニックを使うには MyBatis 3.2 以降が必要です。それ以前のバージョンには 問題 があるため、Writer が期待通りに動作しません。 -

    - -

    まず、Interaction と1対1の関係にある InteractionMetadata と、これらとは独立した VisitorInteraction および CustomerInteraction を保持する Item クラスを用意します。 -

    - - - -

    CompositeItemWriter の設定では、それぞれのオブジェクトの writer を順番に呼び出すように設定します。 - この例では Interaction をアップデートするためのキーを取得するため、InteractionMetadata を先に書き込む必要があります。 -

    - - - - - - - - - - - - -]]> - - interactionsItemWriter() { - CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); - List> writers = new ArrayList<>(4); - writers.add(visitorInteractionsWriter()); - writers.add(customerInteractionsWriter()); - writers.add(interactionMetadataWriter()); - writers.add(interactionWriter()); - compositeItemWriter.setDelegates(writers); - return compositeItemWriter; -}]]> - -

    それぞれの writer を必要に応じて設定します。例えば InteractionInteractionMetadata の設定は次のようになります。 -

    - - -]]> - -

    reader の場合と同様、 statementId はネームスペースを含むステートメント ID です。

    - -

    Mapper ファイルにステートメントを定義します。

    - - - - - - -]]> - -

    はじめに insertInteractionMetadata が呼ばれ、その際に取得した主キーを使って親となる InteractioninsertInteraction を使って書き込むことができます。 -

    - -

    JDBC ドライバによって動作が異なるので注意が必要です。例えば MySQL の JDBC ドライバは作成された全ての行の ID を返しますが、H2 バージョン 1.3.168 ではバッチモードでも最後に作成された行の ID のみが返されます。 -

    -
    -
    - - diff --git a/src/site/ja/xdoc/boot.xml b/src/site/ja/xdoc/boot.xml deleted file mode 100644 index 102d8d1127..0000000000 --- a/src/site/ja/xdoc/boot.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - MyBatis-Spring | Spring Boot - Eduardo Macarron - - - -
    -

    - 詳細は MyBatis Spring-boot-starter のドキュメントを参照してください。 -

    -
    - -
    diff --git a/src/site/ja/xdoc/factorybean.xml b/src/site/ja/xdoc/factorybean.xml deleted file mode 100644 index 4f9db4e4a7..0000000000 --- a/src/site/ja/xdoc/factorybean.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - MyBatis-Spring | SqlSessionFactoryBean - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    -

    - 基となる MyBatis では、SqlSessionFactory をビルドする際 SqlSessionFactoryBuilder を使いましたが、MyBatis-Spring では、SqlSessionFactoryBean を使います。 -

    - - -

    - Spring の XML 設定ファイルに次の Bean を定義することで Factory Bean を生成することができます。 -

    - - -]]> -

    - SqlSessionFactoryBean は Spring の FactoryBean インターフェイス(the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-) を参照してください)を実装しています。 - これはつまり、最終的に Spring が生成するのは SqlSessionFactoryBean ではなく、Factory の getObject() メソッドによって返されるオブジェクトであるということです。
    - 上記の設定では、Spring は SqlSessionFactory を生成し、sqlSessionFactory という名前の Bean として登録します。 - これに相当する Java のコードは下記のようになるでしょう。 -

    - - - -

    - 通常 MyBatis-Spring を使う場合、SqlSessionFactoryBean や対応する SqlSessionFactory を直接利用する必要はありません。 - sqlSessionFactory は MapperFactoryBeanSqlSessionDaoSupport を継承した他の DAO にインジェクト(注入)されます。 -

    -
    - - - -

    - SqlSessionFactory で必須のプロパティは JDBC の DataSource のみです。 - どのような DataSource でも構いません。Spring でデータベース接続を定義する通常の手順で定義してください。 -

    - -

    - configLocation は、MyBatis の XML 設定ファイルの場所を指定する際に使用します。
    - これは、例えば基になる MyBatis の設定の一部を変更したい場合などに必要となります。 - よくあるのは <settings><typeAliases> などの設定です。 -

    - -

    - ここで指定する設定ファイルは、完全な MyBatis 設定ファイルである必要はありません。 - 環境、データソース、MyBatis のトランザクションマネージャーに関する設定は無視されます。 - SqlSessionFactoryBean は、独自にカスタマイズした MyBatis Environment を生成し、必要に応じてこれらの値を設定するようになっています。 -

    - -

    - 設定ファイルの指定が必要とされるもう一つの例は、MyBatis の Mapper XML ファイルが Mapper クラスとは別のクラスパスに存在する場合です。 - このような構成にする場合、次のどちらかの方法で設定することができます。 - 最初の方法は、MyBatis の設定ファイルの <mappers> で各 XML ファイルのクラスパスを指定する方法です。 - そしてもう一つは、Factory Bean の mapperLocations を使った方法です。 -

    - -

    - mapperLocations プロパティは Resource Location のリストを取り、ここで MyBatis の XML Mapper ファイルの場所を指定することができます。 - Ant スタイルのパターン文字列を使って特定のディレクトリ内の全ファイルを指定したり、内包するディレクトリを再帰的に検索対象にすることもできます。次の例を見てください。 -

    - - - - -]]> - -

    - このように指定すると、クラスパス内の sample.config.mappers パッケージと、そのサブパッケージに含まれる全ての MyBatis Mapper XML ファイルがロードされます。 -

    - -

    - Container-Managed トランザクションを利用する環境では、transactionFactoryClass プロパティが必須となります。 - 「トランザクション」章の該当する節を参照してください。 -

    - -

    - 複数のデータベースを使用する場合は、databaseIdProviderプロパティを設定する必要があります。 -

    - - - - - sqlserver - db2 - oracle - mysql - - - - - - - - -]]> - -

    - NOTE - 1.3.0より、configurationプロパティが追加されました。 - このプロパティには、MyBatisのXML設定ファイルを使わずにConfigurationインスタンスを直接指定することができます。 - 次の例を見てください。 -

    - - - - - - - - -]]> - -
    -
    - -
    diff --git a/src/site/ja/xdoc/getting-started.xml.vm b/src/site/ja/xdoc/getting-started.xml.vm deleted file mode 100644 index d2e5a91c8c..0000000000 --- a/src/site/ja/xdoc/getting-started.xml.vm +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - MyBatis-Spring | スタートガイド - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    -

    - この章では、MyBatis-Spring のインストール・設定手順と、トランザクション処理を含むシンプルなアプリケーションの構築する方法について説明します。 -

    - - -

    - MyBatis-Spring を使うためには、 - mybatis-spring-${project.version}.jar と依存するライブラリをクラスパスに追加するだけで OK です。 -

    -

    - Maven をお使いの場合は、 - pom.xml に次の dependency を追加してください。 -

    - - org.mybatis - mybatis-spring - ${project.version} -]]> -
    - - -

    - MyBatis と Spring を組み合わせて使う場合、Spring の Application Context 内に少なくとも - SqlSessionFactory と一つ以上の Mapper インターフェイスを定義する必要があります。 -

    - -

    - MyBatis-Spring では - SqlSessionFactory の生成に SqlSessionFactoryBean を使います。この Factory Bean を設定するため、Spring の 設定ファイルに次の Bean を追加してください。 -

    - - - -]]> - - - -

    - SqlSessionFactoryDataSource を必要としている点に注意してください。 - どのような DataSource でも構いません。通常の手順で設定してください。 -

    - -

    - Mapper インターフェイスが次のように定義されている場合... -

    - - -

    - MapperFactoryBean を使ってこのインターフェイスを Spring に登録する場合、以下のように設定します。 -

    - - - -]]> - -

    - ここで指定した Mapper は、実装クラスではなく インターフェイス である必要がありますので注意してください。
    - この例では、アノテーションを使って SQL を指定していますが、Mapper XML ファイルを使うこともできます。 -

    - -

    - 上記のように設定しておけば、あとは他の Spring Bean と同様にビジネス/サービス層のオブジェクトにインジェクト(注入)することができます。 - MapperFactoryBeanSqlSession の生成とクローズを行います。
    - もし Spring のトランザクション内で実行された場合は、トランザクション終了時にセッションがコミットあるいはロールバックされます。 - 最後にもう一点、全ての例外は Spring の DataAccessException に変換されます。 -

    - -

    - Java Configurationを使用する場合: -

    - - - -

    - MyBatis のデータメソッドは、一行だけで実行可能となります。 -

    - -
    -
    - -
    diff --git a/src/site/ja/xdoc/index.xml b/src/site/ja/xdoc/index.xml deleted file mode 100644 index edc7ac52c7..0000000000 --- a/src/site/ja/xdoc/index.xml +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - MyBatis-Spring | イントロダクション - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    - -

    - MyBatis-Spring によって MyBatis と Spring をシームレスに連携させることができます。このライブラリを使えば、MyBatis のステートメントを Spring のトランザクション内で実行することもできますし、Mapper や SqlSession の生成、他の Bean への注入、MyBatis の例外から Spring の DataAccessException への変換、さらには MyBatis や Spring, MyBatis-Spring に依存しないコードでアプリケーションを構築することも可能になります。 -

    -
    - - -

    - Spring バージョン 2 は iBATIS バージョン 2 しかサポートしていません。Spring 3 の開発時に MyBatis 3 への対応が検討されました(こちらの チケット 参照)が、Spring 3 が MyBatis 3 よりも前に正式リリースを迎えたため、残念ながら実装は見送られました。Spring 開発陣としては、未リリースの MyBatis 3 に合わせたコードをリリースしたくなかったという事情があり、Spring 側での正式対応は保留となっていました。MyBatis コミュニティの中で Spring 対応への要望が強かったため、有志によって Spring との連携を行う MyBatis のサブプロジェクトが立ち上げられました。 -

    -
    - - -

    - MyBatis-Spring を利用するためには、MyBatis と Spring の用語について理解しておくことが重要です。 - このドキュメントには MyBatis や Spring についての説明や基本設定といった情報は含まれていません。 -

    -

    - MyBatis-Spring は以下のバージョンを必要とします。 -

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - MyBatis-Spring - - MyBatis - - Spring Framework - - Spring Batch - - Java -
    - 2.0 - - 3.5+ - - 5.0+ - - 4.0+ - - Java 8+ -
    - 1.3 - - 3.4+ - - 3.2.2+ - - 2.1+ - - Java 6+ -
    -
    - - -

    - このプロジェクトの実現にご協力頂いた次の方々に感謝します(アルファベット順): - Eduardo Macarron, Hunter Presnall, Putthiphong Boonphong(コーディング、テスト、ドキュメント作成); - Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan, Tomas Pinos(コントリビューション); - Simone Tripodi(メンバーを集め、MyBatis のサブプロジェクトとしてまとめてくれました)
    - このプロジェクトは彼らの協力なしには実現できなかったでしょう。 -

    -
    - - -

    - このドキュメントの中で誤りや特定の機能に関する記述が抜けていることに気づいたら、詳しく調べてドキュメントを更新して頂けると助かります。 -

    -

    - このマニュアルのソースは xdoc 形式で、プロジェクトの Git リポジトリで配布されています。
    - リポジトリをフォーク、それらを更新します、とプルリクエストを送信します。 -

    -

    - このドキュメントを必要としている人、つまりあなたこそが最高の著者なのです! -

    -
    - - -

    MyBatis-Spring は以下の言語の翻訳を用意しています。

    - -

    母国語でMyBatis Springのリファレンスを読んでみませんか? ぜひドキュメントを母国語へ翻訳するためのIssue(パッチ)を作成してください!

    -
    -
    - - -
    diff --git a/src/site/ja/xdoc/mappers.xml b/src/site/ja/xdoc/mappers.xml deleted file mode 100644 index 16884c5181..0000000000 --- a/src/site/ja/xdoc/mappers.xml +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - MyBatis-Spring | Mapper をインジェクト(注入)する - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    -

    - MyBatis-Spring がスレッドセーフな Mapper を生成してくれるので、SqlSessionDaoSupportSqlSessionTemplate を使って手動で DAO オブジェクトを生成するコードは不要となります。 - 生成された Mapper は他の Bean に注入することができます。 -

    - - - -]]> - -

    - アプリケーション側の処理では、注入された Mapper のメソッドを呼び出すだけです。 -

    - -

    - このコードには SqlSession や MyBatis への参照が含まれていない点に注目してください。 - また、セッションの生成やオープン、クローズも MyBatis-Spring が処理してくれるため不要となります。 -

    - - -

    - Mapper を Bean として登録する方法は、Spring の設定を XML ファイルを使って行う場合と Spring 3.0 以降で導入された Java Config (= @Configuration) を使う場合で異なります。

    - -

    XML で設定する場合

    - -

    - XML ファイルを使って Spring を設定する場合、次のように MapperFactoryBean のエントリーを追加することで Mapper を Spring Bean として登録することができます。 -

    - - - -]]> - -

    - ここで指定した UserMapper のインターフェイスと同じクラスパスに MyBatis の XML Mapper ファイルが配置されている場合は自動的にロードされます。 - XML Mapper が異なるクラスパスに配置されている場合を除けば、MyBatis の設定ファイルでこの Mapper を指定する必要はありません。 - 詳しくは SqlSessionFactoryBeanconfigLocation プロパティの説明を参照してください。 -

    - -

    - MapperFactoryBean を登録する際は SqlSessionFactory あるいは SqlSessionTemplate のどちらかを指定する必要があります。 - 指定対象のプロパティは、それぞれ sqlSessionFactorysqlSessionTemplate です。 - 両方が指定された場合、 SqlSessionFactory の指定は無視され、SqlSessionTemplate の登録時に指定した Session Factory が使われます。 -

    - -

    Java Config で設定する場合

    - - userMapper() throws Exception { - MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); - factoryBean.setSqlSessionFactory(sqlSessionFactory()); - return factoryBean; -}]]> - -
    - - -

    - 上で説明した方法では Mapper を個別に指定していましたが、MyBatis-Spring では特定のクラスパスに含まれる Mapper を自動検出させることもできます。 -

    - -

    - これには3通りの方法があります。 -

    -
      -
    • <mybatis:scan/> 要素を使う。
    • -
    • @MapperScan アノテーションを使う。
    • -
    • Spring の XML 設定ファイルに MapperScannerConfigurer のエントリーを追加する。
    • -
    - -

    <mybatis:scan/> または @MapperScan を使う場合は MyBatis-Spring 1.2.0 以降が必要です。また @MapperScan を使う場合は Spring 3.1 以降が必要となります。

    - -

    - 2.0.2以降では、Mapperの自動検出機能は、Mapper Beanの遅延初期化の有効/無効を制御するオプション(lazy-initialization)をサポートします。 - このオプションを追加する動機は、Spring Boot 2.2でサポートされた遅延初期化を制御する機能をサポートすることです。 - このオプションのデフォルトはfalseです(遅延初期化を使用しません)。 - 開発者がMapper Beanを遅延初期化したい場合は、明示的にこのオプションをtrueに設定する必要があります。 -

    -

    - 重要 遅延初期化機能を使用する場合は、開発者は以下の制限を理解しておく必要があります。 - 以下の条件のいずれかに一致する場合、通常あなたのアプリケーションで遅延初期化機能を使用することはできません。 -

    -
      -
    • ]]>(@One) and ]]>(@Many)を利用して、他のMapperのステートメントを参照している場合
    • -
    • ]]>を利用して、他のMapperのフラグメントをインクルードしている場合
    • -
    • ]]>(@CacheNamespaceRef)を利用して、他のMapperのキャッシュを参照している場合
    • -
    • ]]>(@ResultMap)を利用して、他のMapperの結果マッピングを参照している場合
    • -
    - -

    - NOTE しかしながら、以下のように@DependsOn(Springの機能)を利用して、 - 依存するMapper Beanも同時に初期化すると遅延初期化機能を利用することができるようになります。 -

    - - - -

    - 2.0.6以降では、開発者はMapper BeanのスコープをMapperの自動検出機能のオプション(default-scope) - とスコープを指定するアノテーション(@Scope@RefreshScope など)を使用して指定することができるようになります。 - このオプションを追加する動機は、Spring Cloudから提供されている refresh スコープをサポートすることです。 - このオプションのデフォルトは空(singletonスコープを指定するのと同等)です。 - default-scope オプションで指定した値は、スキャンしたMapperのBean定義に指定されているスコープが singleton の際に適用され、 - 最終的なMapperのスコープが singleton でない場合はScoped ProxyのBeanを作成します。 -

    - -

    <mybatis:scan/>

    - -

    - <mybatis:scan/> は、Spring の <context:component-scan/> が Bean を検索するのと良く似た方法で Mapper を検出します。 -

    - -

    XML 設定の例:

    - - - - - - - -]]> - -

    - base-package 属性で Mapper ファイルを含むパッケージを指定します。 - セミコロンまたはカンマ区切りで複数のパッケージを指定することもできます。 - また、指定されたパッケージが内包するパッケージも検索対象となります。 -

    - -

    - ここでは <mybatis:scan/>SqlSessionFactorySqlSessionTemplate を指定していませんが、この場合は Autowired 可能な MapperFactoryBean が自動的に生成されます。 - ただし、複数の DataSource を利用する場合は Autowired に頼ることができないので、 factory-ref または template-ref 属性を使って適切な Bean を指定する必要があります。 -

    - -

    - <mybatis:scan/> を使う場合、マーカーインターフェイスまたはアノテーションを指定して Mapper をフィルタリングすることができます。 - 検出対象のアノテーションを指定するには annotation 属性を使います。 - 検出対象の Mapper が実装するインターフェイスを指定する場合は marker-interface 属性を使います。 - 両方の属性が指定された場合、どちらかの条件を満たすインターフェイスが Mapper として登録されます。 - デフォルトではどちらも null となっており、base-package で指定したパッケージに含まれるすべてのインターフェイスが Mapper としてロードされます。 -

    - -

    - 検出された Mapper は、Spring の自動検出コンポーネントに対するデフォルト命名規則によって Bean 名が決められます(the Spring reference document(Core Technologies -Naming autodetected components-) を参照してください)。 - アノテーションによる指定がない場合はクラス名の先頭を小文字にした文字列が Bean 名となりますが、@Component あるいは JSR-330 の @Named アノテーションを使って Bean 名を明示的に指定することもできます。 - 先に説明した annotation 属性で org.springframework.stereotype.Componentjavax.inject.Named (Java 6 以降を利用している場合のみ)を指定すれば、検出時のマーカーと Bean 名の指定を1つのアノテーションで兼ねることができます。 - 同じ目的で独自に定義したアノテーションを使うこともできますが、このアノテーション自体に @Component か @Named を付加しておく必要があります。 -

    - -

    - NOTE Spring 標準の <context:component-scan/> を使って Mapper を検出することはできません。 - Mapper はインターフェイスなので、各 Mapper に対する MapperFactoryBean の生成方法が分かっていないと Spring Bean として登録することができないのです。 -

    - -

    @MapperScan

    - -

    - Java Config を使って Spring を設定しているのなら、<mybatis:scan/> よりも @MapperScan を使う方が気に入ると思います。 -

    - -

    @MapperScan アノテーションは次のように使用します。

    - - - -

    - このアノテーションは前章で説明した <mybatis:scan/> と全く同じ要領で Mapper の検出を行います。 - 引数 markerInterface, annotationClass を使えば検出対象のマーカーインターフェイスとアノテーションを指定することもできますし、sqlSessionFactory, sqlSessionTemplateSqlSessionFactorySqlSessionTemplate を指定することができます。 -

    - -

    - NOTE 2.0.4以降では、 basePackageClasses もしくは basePackages が指定されていない場合、このアノテーションが定義されているクラスのパッケージを基準にスキャンします。 -

    - -

    MapperScannerConfigurer

    - -

    - MapperScannerConfigurerBeanDefinitionRegistryPostProcessor として定義されているので、従来の XML による設定で通常の Bean として登録することができます。 - MapperScannerConfigurer の登録は次のように行います。 -

    - - -]]> - -

    - 特定の sqlSessionFactory または sqlSessionTemplate を指定する場合は、 Bean を参照ではなく 名前で 指定する必要があるので、ref ではなく value を使います。 -

    - ]]> - -

    - NOTE MyBatis-Spring 1.0.2 までは有効なプロパティは sqlSessionFactoryBeansqlSessionTemplateBean のみでしたが、 MapperScannerConfigurerPropertyPlaceholderConfigurer よりも先に読み込まれるためエラーの原因となっていました。 - この問題を回避するため、これらのプロパティの使用は非推奨となり、新たに追加された sqlSessionFactoryBeanNamesqlSessionTemplateBeanName を使うことが推奨されています。 -

    -
    -
    - -
    diff --git a/src/site/ja/xdoc/sample.xml b/src/site/ja/xdoc/sample.xml deleted file mode 100644 index cd0620f742..0000000000 --- a/src/site/ja/xdoc/sample.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - MyBatis-Spring | Sample Code - Eduardo Macarron - - - -
    - -

    - NOTE - See JPetstore 6 demo to know about how to use Spring with a full web application server. -

    - -

    - You can check out sample code from the MyBatis-Spring repo: -

    -

    - Any of the samples can be run with JUnit 5. -

    -

    - The sample code shows a typical design where a transactional service gets domain objects from a data access layer. -

    -

    - FooService.java acts as the service: -

    - -

    - It is a transactional bean, so when the method is called, the transaction is started - and the transaction is committed when the method ends without throwing an uncaught exception. - Notice that transactional behaviour is configured with the - @Transactional - attribute. This is not required; any other way provided by Spring can be used to demarcate - your transactions. -

    -

    - This service calls a data access layer built with MyBatis. This layer - consists on a just an interface UserMapper.java - that will be used with a dynamic proxy built by MyBatis at - runtime and injected into the service by Spring. -

    - -

    - Note that, for the sake of simplicity we used the interface UserMapper.java for the DAO scenario - where a DAO is built with an interface and a implementation though in this case it would have been more - adequate to use an interface called UserDao.java instead. -

    -

    - We will see different ways to find the mapper interface, register it to Spring and inject it into the service bean: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Scenarios
    Sample testDescription
    - SampleMapperTest.java - - Shows you the base configuration based on a MapperFactoryBean - that will dynamically build an implementation for UserMapper -
    - SampleScannerTest.java - - Shows how to use the MapperScannerConfigurer so all the mappers in a project are autodiscovered. -
    - SampleSqlSessionTest.java - - Shows how to hand code a DAO using a Spring managed SqlSession - and providing your own implementation UserDaoImpl.java. -
    - SampleEnableTest - - Shows how to use Spring's @Configuration with the @MapperScann annotation so - mappers are autodiscovered. -
    - SampleNamespaceTest - - Shows how to use the custom MyBatis XML namespace. -
    - SampleJavaConfigTest.java - - Shows how to use Spring's @Configuration to create MyBatis beans manually. -
    - SampleJobJavaConfigTest.java - - Shows how to use ItemReader and ItemWriter on Spring Batch using Java Configuration. -
    - SampleJobXmlConfigTest.java - - Shows how to use ItemReader and ItemWriter on Spring Batch using XML Configuration. -
    -

    - Please take a look at the different applicationContext.xml files to see MyBatis-Spring in action. -

    - -
    - -
    - diff --git a/src/site/ja/xdoc/sqlsession.xml b/src/site/ja/xdoc/sqlsession.xml deleted file mode 100644 index 72be2d5841..0000000000 --- a/src/site/ja/xdoc/sqlsession.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - MyBatis-Spring | Using an SqlSession - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    -

    - MyBatis では SqlSessionFactory を使って SqlSession を生成しました。 - そして取得したセッションを使って Mapped Statement を実行し、接続をコミットあるいはロールバックした後、最終的に不要となったセッションをクローズする、というのが一連の流れでした。 - MyBatis-Spring では、SPring のトランザクション設定に基づいて自動的にコミット、ロールバック、クローズされるスレッドセーフな SqlSession が注入されるので、直接 SqlSessionFactory を使う必要はありません。 -

    - - -

    - SqlSessionTemplate は MyBatis-Spring で最も重要なクラスです。 - このクラスが MyBatis の SqlSession を管理して、SQL メソッドの実行や例外の変換を行なっています。 - このクラスは既存のコードで使用している SqlSession の代わりに使うことを前提に SqlSession インターフェイスを実装しています。 - SqlSessionTemplate はスレッドセーフで、複数の DAO, Mapper 間で共有することができます。 -

    - -

    - getMapper() から返された Mapper のメソッドも含めて、SQL メソッドを呼び出す場合、確実に現在の Spring トランザクションに付加された SqlSession が使われるようにするのも SqlSessionTemplate の仕事です。 - それ以外にも、セッションのクローズや状況に応じたコミットあるいはロールバックといったライフサイクルの管理、更には MyBatis の例外を Spring の DataAccessException に変換する処理も行います。 -

    - -

    - SqlSessionTemplate は Spring が管理するトランザクション内で実行され、また Spring によってインジェクトされる複数の Mapper から呼び出すことができるようにスレッドセーフとなっているので、常にこのクラスを MyBatis のデフォルト実装である DefaultSqlSession の代わりに使用するべきです。 - 同一アプリケーション内でこれら2つのクラスを混在させて使用するとデータの不整合などの問題が発生する可能性があります。 -

    - -

    - SqlSessionTemplate を生成する際は、SqlSessionFactory をコンストラクタ引数として渡します。 -

    - - -]]> - - - -

    - この Bean は、直接あなたの DAO Bean にインジェクト(注入)することができます。 - 注入対象の Bean には SqlSession プロパティを定義しておく必要があります。 -

    - -

    - そして、以下のようにして SqlSessionTemplate を注入します。 -

    - - -]]> - -

    - SqlSessionTemplate には、ExecutorType を引数に取るコンストラクタも定義されています。 - このコンストラクタを使うと、例えばバッチ処理を行う SqlSession を取得することができます。 -

    - - - -]]> - - - -

    - これで実行されるステートメントは全てバッチ処理の対象となります。 - DAO クラス中では、例えば次のように書くことができます。 -

    - users) { - for (User user : users) { - sqlSession.insert("org.mybatis.spring.sample.mapper.UserMapper.insertUser", user); - } -}]]> - -

    - デフォルト以外の ExecutorType を使用する場合にのみ SqlSessionFactory の Bean を定義する際に2つの引数を指定する必要があります。 -

    - -

    - この初期化方式を使用する場合の注意点として、このメソッドが呼び出される時点で異なる ExecutorType で実行されているトランザクションが存在していてはならない、という制限があります。 - そのためには、異なる ExecutorType が指定された SqlSessionTemplate への呼び出しを、それぞれが独立したトランザクション内で実行する(例えば PROPAGATION_REQUIRES_NEW を指定しておく)か、あるいは完全にトランザクションの外で実行するようにしてください。 -

    -
    - - -

    - SqlSessionDaoSupportSqlSession を提供する抽象クラスです。 - getSqlSession() を呼び出すことで、SQL メソッドを実行するための SqlSessionTemplate を取得することができます。 -

    - -

    - 普通は MapperFactoryBean を使った方がコード量が少なくて済みますが、DAO の中で MyBatis 以外の処理を行うため実装クラスが必要となる場合には便利なクラスです。 -

    - -

    - SqlSessionDaoSupport を使用する際は、sqlSessionFactory または sqlSessionTemplate をセットする必要があります。 - もし両方のプロパティがセットされた場合、sqlSessionFactory は無視されます。 -

    - -

    - SqlSessionDaoSupport のサブクラスである UserDaoImpl を Spring Bean として定義する例を挙げておきます。 -

    - - -]]> -
    -
    - -
    diff --git a/src/site/ja/xdoc/transactions.xml b/src/site/ja/xdoc/transactions.xml deleted file mode 100644 index 36d6324f4e..0000000000 --- a/src/site/ja/xdoc/transactions.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - MyBatis-Spring | トランザクション - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    -

    - これは MyBatis-Spring を使う主な理由の一つでもありますが、MyBatis-Spring を使うと MyBatis の処理を Spring が管理するトランザクションの一部として実行できるようになります。 - MyBatis-Spring は、MyBatis のために新しいトランザクションマネージャーを生成するのではなく、Spring が生成した DataSourceTransactionManager を利用します。 -

    -

    - Spring のトランザクションマネージャーが定義されていれば、通常の手順で Spring のトランザクションを利用することができます。 - @Transactional アノテーションと AOP 形式での指定、どちらも利用可能です。 - トランザクション内では SqlSession が一つ生成され、トランザクションの生存期間中はこの SqlSession が使用されます。 - このセッションは、トランザクション完了時にコミットあるいはロールバックされます。 -

    -

    - MyBatis-Spring ではトランザクションは透過的に管理されるので、あなたの DAO クラスにコードを追加する必要はありません。 -

    - - -

    - Spring の 設定ファイルで DataSourceTransactionManager を生成するだけで、Spring のトランザクション処理が有効となります。 -

    - - -]]> - - - -

    - ここで指定する DataSource は、通常 Spring で利用される JDBC DataSource であればどのようなデータソースでも構いません。 - 例えば、コネクションプールや JNDI 経由で取得した DataSource などです。 -

    -

    - ただし、トランザクションマネージャーに対して指定する DataSource は、SqlSessionFactoryBean に対して指定したものと同じでなくてはなりません。もし別のデータソースを指定した場合、トランザクション機能は正しく動作しません。 -

    -
    - - -

    - JEEコンテナを利用していて、Spring の処理を CMT (Container Managed Transaction) の一部として利用したい場合、JtaTransactionManager あるいはそのコンテナ固有のサブクラスを使って Spring を設定する必要があります。 - 最も簡単なのは、Spring のトランザクション名前空間 又は JtaTransactionManagerFactoryBean を使う方法です。 -

    - ]]> - - - -

    - このように設定しておくと MyBatis は、CMT を使うように設定された他の Spring リソースと同じように動作します。 - Spring は、既存のコンテナ管理されたトランザクションがあれば、そのトランザクションに SqlSession を付加して利用します。 - もしトランザクションを要求する処理が呼び出された時点で開始されたトランザクションがなければ、Spring が新しいコンテナ管理されたトランザクションを開始します。 -

    -

    - CMT は使いたいが、Spring のトランザクション管理は利用したくないという場合、Spring のトランザクションマネージャーを定義してはいけません。 - またこの場合、MyBatis 側で生成された ManagedTransactionFactory を使うように SqlSessionFactoryBean を設定する必要があります。 -

    - - - - - -]]> - - - -
    - - -

    - MyBatis の SqlSession では、トランザクションをプログラム的に制御するためのメソッドが用意されています。 - しかし、MyBatis-Spring では、あなたの Bean にインジェクト(注入)されるのは Spring が管理する SqlSession あるいは Mapper です。 - つまり、トランザクションを制御するのは常に Spring でなくてはなりません。 -

    -

    - Spring が管理している SqlSession に対して SqlSession.commit(), SqlSession.rollback(), SqlSession.close() を呼び出すことはできません。 - もしこれらのメソッドを呼び出した場合、UnsupportedOperationException がスローされます。 - あなたの Bean に注入される Mapper クラスでは、これらのメソッドは隠蔽されています。 -

    -

    - Spring が管理するトランザクションの外側で SqlSession のデータメソッドあるいは Mapper メソッドを呼び出した場合、JDBC 接続に対する auto-commit の設定に関わらず、変更は直ちにコミットされます。 -

    -

    - もしあなたがトランザクションをプログラム的に制御したいのであれば、the Spring reference document(Data Access -Programmatic transaction management-) を参照してください。 - 以下のコードは、PlatformTransactionManager を使ってトランザクションを手動で制御する例です。 -

    - - -

    - TransactionTemplate を使用して commitrollback メソッドを省略することもできます。 -

    - - { - userMapper.insertUser(user); - return null; -});]]> - -

    - ここでは Mapper を使っていますが、SqlSession を使うこともできます。 -

    -
    -
    - -
    diff --git a/src/site/ja/xdoc/using-api.xml b/src/site/ja/xdoc/using-api.xml deleted file mode 100644 index e853d45986..0000000000 --- a/src/site/ja/xdoc/using-api.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - MyBatis-Spring | MyBatis API の使用 - Hunter Presnall - Eduardo Macarron - Iwao AVE! - - - -
    -

    - MyBatis-Spring を使っている場合でも、直接 MyBatis API を呼び出すことができます。 - Spring の設定で SqlSessionFactoryBean を使って SqlSessionFactory を生成すれば、コード内で使用することができます。 -

    - - -

    - この方法を使う場合は注意が必要です。 - なぜなら、誤った使い方をすると実行時エラーや、最悪の場合データの不整合といった問題を生じる可能性があるからです。 - MyBatis API を直接使用する場合、次のような点に注意してください。 -

    -
      -
    • -

      - API の呼び出しは Spring で管理されているトランザクション内では実行されません。 -

      -
    • -
    • -

      - SqlSession が Spring のトランザクションマネージャーが使っているのと同じ DataSource を使っていて、既に進行中のトランザクションが存在している場合、このコードは例外を投げます。 -

      -
    • -
    • -

      - MyBatis の DefaultSqlSession はスレッドセーフではありません。 - もしあなたの Bean に注入した場合、エラーが発生します。 -

      -
    • -
    • -

      - DefaultSqlSession を使って生成した Mapper もスレッドセーフとはなりません。 - もしあなたの Bean に注入した場合、エラーが発生します。 -

      -
    • -
    • -

      - SqlSession は常に finally ブロックでクローズする必要があります。 -

      -
    • -
    -
    - -
    diff --git a/src/site/ko/markdown/README.md b/src/site/ko/markdown/README.md new file mode 100644 index 0000000000..4e31a121bc --- /dev/null +++ b/src/site/ko/markdown/README.md @@ -0,0 +1,18 @@ +# 목차 + +이 페이지는 GitHub에서 인덱스를 렌더링하기위한 것입니다. + +> **NOTE:** +> +> 링크 대상은 maven-site-plugin을 사용하여 html로 변환된다는 가정하에 지정되므로 GitHub의 렌더링에서 끊어진 앵커가 있습니다. + +* [소개](./index.md) +* [시작하기](./getting-started.md) +* [SqlSessionFactoryBean](./factorybean.md) +* [트랜잭션](./transactions.md) +* [SqlSession 사용](./sqlsession.md) +* [매퍼 주입](./mappers.md) +* [Spring Boot](./boot.md) +* [MyBatis API 사용](./using-api.md) +* [Spring Batch](./batch.md) +* [샘플 코드](./sample.md) diff --git a/src/site/ko/markdown/batch.md b/src/site/ko/markdown/batch.md new file mode 100644 index 0000000000..29ec3f6df6 --- /dev/null +++ b/src/site/ko/markdown/batch.md @@ -0,0 +1,353 @@ + +# Spring Batch + +마이바티스 스프링 연동모듈의 1.1.0버전에서는 스프링 배치 애플리케이션을 만들기 위해 두개의 빈을 제공한다. +두개의 빈은 `MyBatisPagingItemReader` 와 `MyBatisCursorItemReader` 와 MyBatisBatchItemWriter이다. + +또한 2.0.0 버전에서는 Java Configuration 을 지원하는 다음의 세 가지 Builder class 를 제공한다. +`MyBatisPagingItemReaderBuilder`, `MyBatisCursorItemReaderBuilder` 그리고 `MyBatisBatchItemWriterBuilder` 이다. + +중요 +이 문서는 [스프링 배치](http://static.springsource.org/spring-batch/) 에 대한 것으로 마이바티스 배치 `SqlSession` 을 다루지는 않는다. +배치 세션에 대해서는 [SqlSession 사용](sqlsession.html) 에서 좀더 다루었다. + +# MyBatisPagingItemReader + +이 빈은 마이바티스로 페이지를 처리하는 형태로 데이터베이스 데이터를 읽어오는 `ItemReader`이다. + +요청된 데이터를 가져오기 위해 `setQueryId` 프로퍼티에 명시된 쿼리를 실행한다. +쿼리는 `setPageSize` 프로퍼티에 명시된 크기만큼 데이터를 가져오도록 실행된다. +`read()` 메서드를 사용하면 필요할 때 현재 위치에서 정해진 수 만큼 더 추가 데이터를 가져온다. +reader는 몇가지의 표준적인 쿼리 파라미터를 제공하고 명명된 쿼리의 SQL은 요청된 크기만큼의 데이터를 만들기 위해 파라미터의 일부 혹은 모두 사용한다. +여기서 사용가능한 파라미터이다. + +* `_page`: 읽을 페이지 수(0부터 시작) +* `_pagesize`: 페이지의 크기, 이를테면 리턴하는 로우 수 +* `_skiprows`: `_page` 와 `_pagesize`의 결과 + +각각의 파라미터는 selet구문에서 다음처럼 매핑될 수 있다. + +```xml + +``` + +다음의 코드는 샘플 설정이다. + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisPagingItemReader reader() { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +**좀더 복잡한 예제를 보자.** + +```xml + +``` +```xml + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @StepScope + @Bean + public MyBatisPagingItemReader dateBasedCriteriaReader( + @Value("#{@datesParameters}") Map datesParameters) throws Exception { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(batchReadingSessionFactory()) + .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") + .parameterValues(datesParameters) + .pageSize(200) + .build(); + } + + @StepScope + @Bean + public Map datesParameters( + @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, + @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { + Map map = new HashMap<>(); + map.put("yesterday", yesterday); + map.put("today", today); + map.put("first_day_of_the_month", firstDayOfTheMonth); + map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); + return map; + } +} +``` + +앞의 예제와는 몇가지 차이점이 있다. + +* `sqlSessionFactory`: reader에 별도로 구현한 sessionFactory를 지정할 수 있다. 이 옵션은 다양한 데이터베이스에서 데이터를 읽을때 유용하다. +* `queryId`: 여러개의 테이블에서 데이터를 읽어야 하고 서로 다른 쿼리를 사용한다면 서로다른 네임스페이스를 가진 매퍼 파일을 사용하는게 좋을수 있다. 쿼리를 알아볼때, 매퍼 파일의 네임스페이스를 잊지 말아야 한다. +* `parameterValues`: 이 맵을 사용해서 추가로 파라미터를 전달할 수 있다. 위 예제는 `jobExecutionContext`에서 값들을 가져오는 SpEL표현식을 사용하는 맵을 사용하고 있다. + 맵의 키는 매퍼파일에서 마이바티스가 사용할 것이다. (예: *yesterday* 는 `#{yesterday,jdbcType=TIMESTAMP}` 로 사용될수 있다.). + 맵과 reader 모두 `jobExecutionContext`에서 SpEL표현식을 사용하기 위해 `step` 스코프를 사용한다. 마이바티스의 타입핸들러가 제대로 설정이 되었다면 JodaTime날짜를 맵을 사용해서 파라미터로 넘길수 있다. +* `pageSize`: 배치가 청크크기가 지정된 형태로 처리가 되면 reader에 이 값을 전달하는게 적절하다. + +## MyBatisCursorItemReader + +이 빈은 cursor 를 사용하여 데이터베이스에서 레코드를 읽는 `ItemReader` 이다. + +중요 +이 빈을 사용하려면 최소한 MyBatis 3.4.0 이나 그 이상이어야 한다. + +`setQueryId` 속성으로 지정된 쿼리를 실행하여 `selectCursor()` 메서드를 사용하여 요청 된 데이터를 검색한다. `read()` 메서드가 호출 될 때마다 요소가 더 이상 남아 있지 않을 때까지 cursor 의 다음 요소를 반환한다. + +reader 는 별도의 connection 을 사용하므로 select 문은 step processing 일부로 생성된 트랜잭션에 속하지 않는다. + +cursor 를 사용할 때 다음과 같이 일반 쿼리를 실행할 수 있다. + +```xml + +``` + +아래는 샘플 설정이다. + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisCursorItemReader reader() { + return new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +# MyBatisBatchItemWriter + +모든 아이템을 배치로 구문을 일괄실행하기 위해 `SqlSessionTemplate`에서 배치로 작업을 처리하는 `ItemWriter`이다. `SqlSessionFactory`는 `BATCH` 실행자로 설정할 필요가 있다. + +사용자는 `write()` 메서드가 호출될때 실행될 매핑구문 아이디를 제공해야 한다. `write()` 메서드는 트랜잭션내에서 호출되는 것으로 예상된다. + +다음의 코드는 샘플설정이다. + +```xml + + + + +``` +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") + .build(); + } +} +``` + + +**Converting a item that read using ItemReader to an any parameter object:** + +By default behavior, the `MyBatisBatchItemWriter` passes a item that read using `ItemReader` (or convert by `ItemProcessor`) to the MyBatis(`SqlSession#update()`) as the parameter object. +If you want to customize a parameter object that passes to the MyBatis, you can realize to use the `itemToParameterConverter` option. +For example using `itemToParameterConverter` option, you can passes any objects other than the item object to the MyBatis. +Follows below a sample: + +At first, you create a custom converter class (or factory method). The following sample uses a factory method. + +```java +public class ItemToParameterMapConverters { + public static Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; + } +} +``` + +At next, you write a sql mapping. + +```xml + +``` + +At last, you configure the `MyBatisBatchItemWriter`. + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() throws Exception { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); + } +} +``` + +```xml + + + + + + + + + + +``` + +**여러개의 테이블에 데이터를 쓰려면 한꺼번에 처리할 수 있도록 만든 writer(몇가지 규칙을 가지고)를 사용하자.** + +이 기능은 마이바티스 3.2이상에서만 사용할 수 있다. 이전의 버전에서는 예상과 다르게 동작하는데 그 내용은 [이슈](http://code.google.com/p/mybatis/issues/detail?id=741)를 참고하면 된다. + +배치가 관계를 가지는 데이터나 여러개의 데이터베이스를 다루는 것처럼 복잡한 데이터를 작성할때 필요하다면 insert구문이 한개에 테이블에만 데이터를 넣을수 있다는 사실만 피하면 가능하기도 하다. +이런 복잡한 데이터를 처리하기 위해 writer가 작성하는 아이템(Item)을 준비해야 한다. 다음의 기술을 사용하면 단순한 관계를 가진 데이터나 관계가 없는 테이블을 처리하는 아이템에서 사용할 수 있다. + +이러한 방법으로 스프링 배치 아이템은 모든 레코드를 *다룰것이다*. +여기에는 1:1 *관계*를 가지는 *InteractionMetadata*, 관계가 없는 두개의 로우는 *VisitorInteraction* 와 *CustomerInteraction*이 있다. +이 각각의 객체는 다음과 같이 볼수 있다. + +```java +public class InteractionRecordToWriteInMultipleTables { + private final VisitorInteraction visitorInteraction; + private final CustomerInteraction customerInteraction; + private final Interaction interaction; + // ... +} +``` +```java +public class Interaction { + private final InteractionMetadata interactionMetadata; +} +``` + +그리고 스프링 설정에는 각각의 레코드를 처리하기위해 특별히 설정된 전용(delegates) writer를 사용하는 `CompositeItemWriter`가 있다. + +```xml + + + + + + + + + + + + +``` +```java +@Bean +@Configuration +public class BatchAppConfig { + public CompositeItemWriter interactionsItemWriter() { + CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); + List> writers = new ArrayList<>(4); + writers.add(visitorInteractionsWriter()); + writers.add(customerInteractionsWriter()); + writers.add(interactionMetadataWriter()); + writers.add(interactionWriter()); + compositeItemWriter.setDelegates(writers); + return compositeItemWriter; + } +} +``` + +각각의 전용(delegate) writer는 필요할 만큼 설정할 수 있다. 예를들면 *Interaction* 과 *InteractionMetadata*를 위한 writer가 있다. + +```xml + +``` +```xml + +``` + +reader와 동일하게 `statementId`는 네임스페이스를 가진 구문을 가리킬수 있다. + +매퍼 파일에서 구문은 다음과 같은 방법으로 각각의 레코드를 위해 만들어져있다. + +```xml + + + +``` +```xml + + + +``` + +먼저 `insertInteractionMetadata`가 호출될것이고 update구문은 jdbc드라이버에 의해(`keyProperty` 와 `keyColumn`) 생성된 아이디들을 리턴하기 위해 설정되었다. +`InteractionMetadata` 객체가 이 쿼리에 의해 업데이트되면 다음의 쿼리는 `insertInteraction`를 통해 상위객체인 `Interaction`를 작성하기 위해 사용될수 있다. + +***방금 언급한 내용에 관련하여 JDBC드라이버가 똑같이 동작하지 않을수 있다. +이 글을 쓰는 시점에 H2 드라이버 1.3.168버전(`org.h2.jdbc.JdbcStatement#getGeneratedKeys`를 보라)만 배치모드에서 마지막 인덱스를 리턴한다. +반면에 MySQL 드라이버는 기대한 것과 동일하게 동작하고 모든 아이디를 리턴한다.*** diff --git a/src/site/ko/markdown/boot.md b/src/site/ko/markdown/boot.md new file mode 100644 index 0000000000..7e932a7fa6 --- /dev/null +++ b/src/site/ko/markdown/boot.md @@ -0,0 +1,4 @@ + +# 스프링 부트 사용하기 + +자세한 내용은 [MyBatis Spring-boot-starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure) 하위 프로젝트 문서를 참조하십시오. diff --git a/src/site/ko/markdown/factorybean.md b/src/site/ko/markdown/factorybean.md new file mode 100644 index 0000000000..e0a79081ad --- /dev/null +++ b/src/site/ko/markdown/factorybean.md @@ -0,0 +1,97 @@ + +# SqlSessionFactoryBean + +마이바티스만 사용하면, `SqlSessionFactory`는 `SqlSessionFactoryBuilder`를 사용해서 생성한다. +마이바티스 스프링 연동모듈에서는, `SqlSessionFactoryBean`가 대신 사용된다. + +## 설정 + +팩토리 빈을 생성하기 위해, 스프링 XML설정파일에 다음설정을 추가하자. + +```xml + + + +``` + +`SqlSessionFactoryBean` 은 스프링의 `FactoryBean` 인터페이스를 구현(see [the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-)](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-extension-factorybean))한다는 점을 알아야 한다. +이 설정은 스프링이 `SqlSessionFactoryBean` 자체를 생성하는 것이 **아니라** 팩토리에서 `getObject()` 메서드를 호출한 결과를 리턴한다는 것을 의미한다. +이 경우, 스프링은 애플리케이션 시작 시점에 `SqlSessionFactory`를 빌드하고 `sqlSessionFactory` 라는 이름으로 저장한다. 자바에서 코드로 표현하면 아래와 같다. + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +일반적인 마이바티스 스프링 사용법에서는, `SqlSessionFactoryBean`이나 관련된 `SqlSessionFactory`를 직접 사용할 필요가 없다. +대신 세션 팩토리가 `MapperFactoryBean`나 `SqlSessionDaoSupport`를 확장하는 다른 DAO에 주입될것이다. + +## 속성 + +`SqlSessionFactory`는 JDBC `DataSource`의 필수 프로퍼티가 필요하다. 어떤 `DataSource`라도 상관없고 다른 스프링 데이터베이스 연결처럼 설정되어야만 한다. + +하나의 공통적인 프로퍼티는 마이바티스 XML설정파일의 위치를 지정하기 위해 사용되는 `configLocation`이다. 이 프로퍼티를 설정하는 것은 디폴트 설정을 가진 마이바티스 설정을 변경해야 할 경우 뿐이다. +대개는 ``과 `` 섹션을 변경하는 경우이다. + +설정파일이 마이바티스 설정을 완전히 다룰 필요는 없다. 어떤 환경, 어떤 데이터소스 그리고 마이바티스 트랜잭션 관리자가 **무시**될수도 있다. +`SqlSessionFactoryBean` 는 필요에 따라 이 값들을 설정하여 자체적인 MyBatis `Environment` 를 만든다. + +설정파일이 필요한 다른 이유는 마이바티스 XML파일이 매퍼 클래스와 동일한 클래스패스에 있지 않은 경우이다. 이 설정을 사용하면 두가지 옵션이 있다. +첫번째는 마이바티스 설정파일에 `` 섹션을 사용해서 XML파일의 클래스패스를 지정하는 것이다. 두번째는 팩토리 빈의 `mapperLocations` 프로퍼티를 사용하는 것이다. + +`mapperLocations` 프로퍼티는 매퍼에 관련된 자원의 위치를 나열한다. 이 프로퍼티는 마이바티스의 XML매퍼 파일들의 위치를 지정하기 위해 사용될 수 있다. +디렉터리 아래 모든 파일을 로드하기 위해 앤트(Ant) 스타일의 패턴을 사용할수도 있고 가장 상위 위치를 지정하는 것으로 재귀적으로 하위 경로를 찾도록 할수도 있다. 예를 들어보면 다음과 같다. + +```xml + + + + +``` + +이 설정은 `sample.config.mappers` 패키지 아래와 그 하위 패키지를 모두 검색해서 마이바티스 매퍼 XML파일을 모두 로드할 것이다. + +컨테이너 관리 트랜잭션을 사용하는 환경에서 필요한 하나의 프로퍼티는 `transactionFactoryClass` 이다. 이에 관련해서는 트랜잭션을 다루는 장에서 볼수 있다. + +만약 multi-db 기능을 사용한다면 다음과 같이 `databaseIdProvider` 속성을 설정해야 한다. + +```xml + + + + sqlserver + db2 + oracle + mysql + + + +``` +````xml + + + + + +```` + +NOTE +1.3.0 버전 부터 `configuration` 속성이 추가되었다. 다음과 같이 MyBatis XML 설정 파일없이 `Configuration` 인스턴스를 직접 지정할 수 있습니다. + +```xml + + + + + + + + +``` diff --git a/src/site/ko/markdown/getting-started.md b/src/site/ko/markdown/getting-started.md new file mode 100644 index 0000000000..f04bde22cc --- /dev/null +++ b/src/site/ko/markdown/getting-started.md @@ -0,0 +1,98 @@ + +# 시작하기 + +이 장은 마이바티스 스프링 연동모듈을 설치하고 셋팅하는 방법에 대해 간단히 보여준다. 그리고 트랜잭션을 사용하는 간단한 애플리케이션을 만드는 방법까지 다룰 것이다. + +## 설치 + +마이바티스 스프링 연동모듈을 사용하기 위해서, 클래스패스에 `mybatis-spring-${project.version}.jar`를 포함시켜야 한다. + +메이븐을 사용하고 있다면 pom.xml에 다음처럼 의존성을 추가하면 된다. + +```xml + + org.mybatis + mybatis-spring + ${project.version} + +``` + +## 빠른 설정 + +마이바티스를 스프링과 함께 사용하려면 스프링의 애플리케이션 컨텍스트에 적어도 두개를 정의해줄 필요가 있다. +두가지는 `SqlSessionFactory`와 한개 이상의 매퍼 인터페이스이다. + +마이바티스 스프링 연동모듈에서, `SqlSessionFactoryBean`은 `SqlSessionFactory`를 만들기 위해 사용된다. 팩토리 빈을 설정하기 위해, 스프링 설정파일에 다음 설정을 추가하자. + +```xml + + + +``` + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +`SqlSessionFactory`는 `DataSource`를 필요로 하는 것을 알아둘 필요가 있다. 어떤 `DataSource`도 상관없지만 다른 스프링의 데이터베이스 연결과 동일하게 설정되어야 한다. + +매퍼 인터페이스가 다음처럼 정의되었다고 가정해보자. + +```java +public interface UserMapper { + @Select("SELECT * FROM users WHERE id = #{userId}") + User getUser(@Param("userId") String userId); +} +``` + +UserMapper인터페이스는 다음처럼 `MapperFactoryBean`을 사용해서 스프링에 추가된다. + +```xml + + + + +``` + +매퍼는 **반드시** 구현체 클래스가 아닌 인터페이스로 정의되어야 한다. 예를들어, 애노테이션이 SQL을 명시하기 위해 사용되지만 마이바티스 매퍼 XML파일 또한 사용될 수 있다. + +한번만 설정하면, 다른 스프링 빈에 주입하는 같은 방법으로 비즈니스/서비스 객체에 매퍼를 직접 주입할 수 있다. `MapperFactoryBean`은 `SqlSession`을 생성하고 닫는 작업을 잘 다룬다. +실행중인 스프링 트랜잭션이 있다면, 트랜잭션이 완료되는 시점에 커밋이나 롤백이 될 것이다. 마지막으로 예외가 발생하면 스프링의 `DataAccessException`예외가 발생한다. + +자바로 설정하면 다음과 같다. + +```java +@Configuration +public class MyBatisConfig { + @Bean + public UserMapper userMapper() throws Exception { + SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); + return sqlSessionTemplate.getMapper(UserMapper.class); + } +} +``` + +마이바티스의 데이터 관련 메서드는 호출하는 것은 한줄이면 된다. + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` diff --git a/src/site/ko/markdown/index.md b/src/site/ko/markdown/index.md new file mode 100644 index 0000000000..393eec171f --- /dev/null +++ b/src/site/ko/markdown/index.md @@ -0,0 +1,54 @@ + +# 소개 + +## MyBatis-Spring 은 무엇일까? + +마이바티스 스프링 연동모듈은 마이바티스와 스프링을 편하고 간단하게 연동한다. 이 모듈은 마이바티스로 하여금 스프링 트랜잭션에 쉽게 연동되도록 처리한다. 게다가 마이바티스 매퍼와 `SqlSession`을 다루고 다른 빈에 주입시켜준다. +마이바티스 예외를 스프링의 `DataAccessException`로 변환하기도 하고 마이바티스, 스프링 또는 마이바티스 스프링 연동모듈에 의존성을 없애기도 한다. + +## 동기 부여 + +스프링 2.x은 아이바티스 2.x만을 지원한다. 스프링 3.x에서 마이바티스 3.x를 지원하기 위한 시도가 진행중이다. (스프링의 이슈관리 시스템인 [이슈](https://jira.springsource.org/browse/SPR-5991) 를 보라.) +불행하게도 스프링 3의 개발이 마이바티스 3.0의 정식릴리즈전에 개발이 완료되었다. 그래서 스프링팀은 릴리즈가 안된 마이바티스 코드를 함께 릴리즈하는 것을 원하지 않았고 실제적인 스프링 지원을 기다릴수밖에 없었다. +스프링의 마이바티스 지원에 대한 관심으로 인해, 마이바티스 커뮤니티는 재결합하는 형태로 결정을 내고 대신 마이바티스의 하위 프로젝트 형태로 스프링 연동 프로젝트를 추가한다. + +## 필요 조건 + +마이바티스 스프링 연동을 시작하기 전에, 마이바티스와 스프링의 용어를 맞추는 일이 굉장히 중요했다. 이 문서는 배경지식이나 기본적인 셋업방법 그리고 마이바티스와 스프링의 설정에 대한 튜토리얼등은 제공하지 않는다. + +MyBatis-Spring requires following versions: + +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +| --- | --- | --- | --- | --- | +| **2.0** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | + +## 감사 인사 + +이 프로젝트가 실제로 만들어지게 도와준 모든 특별한 분들에게 정말 감사한다. +알파벳 순서로 보면, 코딩및 테스트 그리고 문서화를 담당했던 Eduardo Macarron, Hunter Presnall, Putthiphong Boonphong; +그외 다양한 프로젝트 기여자인 Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan, Tomas Pinos; +그리고 마이바티스에 하위 프로젝트로 가져올수 있도록 많은 것을 찾아준 Simone Tripodi 에게 감사한다. ;) +이들이 없었다면 이 프로젝트는 존재하지 않았을 것이다. + +## 이 문서가 더 나아지도록 도와주세요… + +만약에 어떤 방법으로든 이 문서의 취약점이 발견되거나 기능에 대한 문서화가 빠진 부분이 보인다면, 가장 좋은 방법은 먼저 공부해서 자신만의 문서를 작성하는 것이다. + +이 문서의 원본은 xdoc포맷이며 [프로젝트의 Git](https://github.com/mybatis/spring/tree/master/src/site)에서 찾을 수 있다. repository 를 fork 하고, 업데이트하고 pull request 를 보내주십시오. + +당신처럼 이 문서를 읽는 사람들에게 이 문서의 최고의 저자가 될수 있다! + +## 번역 + +사용자들은 다음의 번역문서별로 마이바티스 스프링 연동모듈에 대해 알수 있다. + + + +위 번역문서에는 없지만 자국의 언어로 문서로 보고 싶다면, 자국의 언어로 된 문서를 만들어서 우리에게 보내달라. diff --git a/src/site/ko/markdown/mappers.md b/src/site/ko/markdown/mappers.md new file mode 100644 index 0000000000..c56ba731ff --- /dev/null +++ b/src/site/ko/markdown/mappers.md @@ -0,0 +1,184 @@ + +# 매퍼 주입 + +`SqlSessionDaoSupport` 나 `SqlSessionTemplate` 를 직접적으로 사용하는 데이터 접근 객체(DAO)를 생성하기 보다, 마이바티스 스프링 연동모듈은 다른 빈에 직접 주입할 수 있는 쓰레드에 안전한 매퍼를 생성할 수 있다. + +```xml + + + +``` + +한번 주입하고나면 매퍼는 애플리케이션 로직에서 사용할수 있는 준비가 된다. + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` + +이 코드를 보면 `SqlSession`이나 마이바티스 객체가 보이지 않는다. 게다가 세션을 생성하거나 열고 닫을필요도 없어보인다. 마이바티스 스프링 연동모듈이 알아서 처리할 것이다. + + +## 매퍼 등록하기 + +매퍼를 등록하는 방법은 기존의 전통적인 XML설정법을 사용하거나 새로운 3.0 이후의 자바설정(일명 `@Configuration`)을 사용하느냐에 따라 다르다. + +### XML설정 사용 + +매퍼는 다음처럼 XML설정파일에 `MapperFactoryBean`을 두는 것으로 스프링에 등록된다. + +```xml + + + + +``` + +UserMapper가 매퍼 인터페이스와 같은 경로의 클래스패스에 마이바티스 XML매퍼 파일을 가지고 있다면 `MapperFactoryBean`이 자동으로 파싱할것이다. +매퍼 XML파일을 다른 클래스패스에 두는게 아니라면 마이바티스 설정파일에 매퍼를 지정할 필요가 없다. 좀더 세부적인 정보는 `SqlSessionFactoryBean`의 [`configLocation`](factorybean.html) 프로퍼티를 살펴보자. + +`MapperFactoryBean`은 `SqlSessionFactory` 나 `SqlSessionTemplate`가 필요하다. `sqlSessionFactory` 와 `sqlSessionTemplate` 프로퍼티를 셋팅하면 된다. +둘다 셋팅하면 `SqlSessionFactory`가 무시된다. 세션 팩토리 셋은 `SqlSessionTemplate`이 필요하고 `MapperFactoryBean`는 팩토리를 사용할것이다. + +### 자바설정 사용 + +```java +@Configuration +public class MyBatisConfig { + @Bean + public MapperFactoryBean userMapper() throws Exception { + MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); + factoryBean.setSqlSessionFactory(sqlSessionFactory()); + return factoryBean; + } +} +``` + + +## 매퍼 스캔 + +하나씩 매퍼를 모두 등록할 필요가 없다. 대신 클래스패스를 지정해서 마이바티스 스프링 연동모듈의 자동스캔기능을 사용할 수 있다. + +자동스캔을 사용하는데는 3가지 방법이 있다. + +* `` 엘리먼트 사용 +* `@MapperScan` 애노테이션 사용 +* 스프링 XML파일을 사용해서 `MapperScannerConfigurer`를 등록 + +`` 와 `@MapperScan` 모두 마이바티스 스프링 연동모듈 1.2.0에서 추가된 기능이다. `@MapperScan` 은 스프링 버전이 3.1이상이어야 한다. + +Since 2.0.2, mapper scanning feature support a option (`lazy-initialization`) that control lazy initialization enabled/disabled of mapper bean. +The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. +The default of this option is `false` (= not use lazy initialization). If developer want to use lazy initialization for mapper bean, it should be set to the `true` expressly. + +IMPORTANT +If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, usually the lazy initialization feature cannot use on your application. + +* When refers to the statement of **other mapper** using ``(`@One`) and ``(`@Many`) +* When includes to the fragment of **other mapper** using `` +* When refers to the cache of **other mapper** using ``(`@CacheNamespaceRef`) +* When refers to the result mapping of **other mapper** using `]]> - -

    다음의 코드는 샘플 설정이다.

    - - - - -
    ]]> - - reader() { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -

    좀더 복잡한 예제를 보자.

    - - - - - - - - -]]> - - dateBasedCriteriaReader( - @Value("#{@datesParameters}") Map datesParameters) throws Exception { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(batchReadingSessionFactory()) - .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") - .parameterValues(datesParameters) - .pageSize(200) - .build(); -} - -@StepScope -@Bean -public Map datesParameters( - @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, - @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { - Map map = new HashMap<>(); - map.put("yesterday", yesterday); - map.put("today", today); - map.put("first_day_of_the_month", firstDayOfTheMonth); - map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); - return map; -}]]> - -

    앞의 예제와는 몇가지 차이점이 있다.

    - -
      -
    • sqlSessionFactory: reader에 별도로 구현한 sessionFactory를 지정할 수 있다. - 이 옵션은 다양한 데이터베이스에서 데이터를 읽을때 유용하다.
    • -
    • queryId: 여러개의 테이블에서 데이터를 읽어야 하고 서로 다른 쿼리를 사용한다면 - 서로다른 네임스페이스를 가진 매퍼 파일을 사용하는게 좋을수 있다. - 쿼리를 알아볼때, 매퍼 파일의 네임스페이스를 잊지 말아야 한다.
    • -
    • parameterValues: 이 맵을 사용해서 추가로 파라미터를 전달할 수 있다. - 위 예제는 jobExecutionContext에서 값들을 가져오는 SpEL표현식을 사용하는 맵을 사용하고 있다. - 맵의 키는 매퍼파일에서 마이바티스가 사용할 것이다. (예: yesterday#{yesterday,jdbcType=TIMESTAMP} 로 사용될수 있다.). - 맵과 reader 모두 jobExecutionContext에서 SpEL표현식을 사용하기 위해 step 스코프를 사용한다. - 마이바티스의 타입핸들러가 제대로 설정이 되었다면 JodaTime날짜를 맵을 사용해서 파라미터로 넘길수 있다.
    • -
    • pageSize: 배치가 청크크기가 지정된 형태로 처리가 되면 reader에 이 값을 전달하는게 적절하다.
    • -
    - - - - -

    - 이 빈은 cursor 를 사용하여 데이터베이스에서 레코드를 읽는 ItemReader 이다. -

    - -

    - 중요 이 빈을 사용하려면 최소한 MyBatis 3.4.0 이나 그 이상이어야 한다. -

    - -

    - setQueryId 속성으로 지정된 쿼리를 실행하여 selectCursor() 메서드를 사용하여 요청 된 데이터를 검색한다. - read() 메서드가 호출 될 때마다 요소가 더 이상 남아 있지 않을 때까지 cursor 의 다음 요소를 반환한다. -

    - -

    - reader 는 별도의 connection 을 사용하므로 select 문은 step processing 일부로 생성된 트랜잭션에 속하지 않는다. -

    - -

    cursor 를 사용할 때 다음과 같이 일반 쿼리를 실행할 수 있다.

    - - SELECT id, name, job FROM employees ORDER BY id ASC -]]> - -

    아래는 샘플 설정이다.

    - - - - -
    ]]> - - reader() { - return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - - - - - -

    모든 아이템을 배치로 구문을 일괄실행하기 위해 SqlSessionTemplate에서 배치로 작업을 처리하는 ItemWriter이다. - SqlSessionFactoryBATCH 실행자로 설정할 필요가 있다.

    - -

    사용자는 write() 메서드가 호출될때 실행될 매핑구문 아이디를 제공해야 한다. - write() 메서드는 트랜잭션내에서 호출되는 것으로 예상된다.

    - -

    다음의 코드는 샘플설정이다.

    - - - - -
    ]]> - - writer() { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") - .build(); -}]]> - - -

    Converting a item that read using ItemReader to an any parameter object:

    - -

    - By default behavior, the MyBatisBatchItemWriter passes a item that read using ItemReader - (or convert by ItemProcessor) to the MyBatis(SqlSession#update()) as the parameter object. - If you want to customize a parameter object that passes to the MyBatis, you can realize to use the itemToParameterConverter option. - For example using itemToParameterConverter option, you can passes any objects other than the item object to the MyBatis. - Follows below a sample: -

    - -

    - At first, you create a custom converter class (or factory method). The following sample uses a factory method. -

    - - Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { - return item -> { - Map parameter = new HashMap<>(); - parameter.put("item", item); - parameter.put("operationBy", operationBy); - parameter.put("operationAt", operationAt); - return parameter; - }; -}]]> - -

    - At next, you write a sql mapping. -

    - - - insert into persons (first_name, last_name, operation_by, operation_at) - values(#{item.firstName}, #{item.lastName}, #{operationBy}, #{operationAt}) -]]> - -

    - At last, you configure the MyBatisBatchItemWriter. -

    - - writer() throws Exception { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") - .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) - .build(); -}]]> - - - - - - - - - - - - -]]> - - -

    여러개의 테이블에 데이터를 쓰려면 한꺼번에 처리할 수 있도록 만든 writer(몇가지 규칙을 가지고)를 사용하자.

    - -

    이 기능은 마이바티스 3.2이상에서만 사용할 수 있다. 이전의 버전에서는 예상과 다르게 동작하는데 그 내용은 - 이슈를 참고하면 된다.

    - -

    배치가 관계를 가지는 데이터나 여러개의 데이터베이스를 다루는 것처럼 복잡한 데이터를 작성할때 필요하다면 - insert구문이 한개에 테이블에만 데이터를 넣을수 있다는 사실만 피하면 가능하기도 하다. - 이런 복잡한 데이터를 처리하기 위해 writer가 작성하는 아이템(Item)을 준비해야 한다. - 다음의 기술을 사용하면 단순한 관계를 가진 데이터나 관계가 없는 테이블을 처리하는 아이템에서 사용할 수 있다.

    - -

    이러한 방법으로 스프링 배치 아이템은 모든 레코드를 다룰것이다. - 여기에는 1:1 관계를 가지는 InteractionMetadata, - 관계가 없는 두개의 로우는 VisitorInteractionCustomerInteraction이 있다. - 이 각각의 객체는 다음과 같이 볼수 있다.

    - - - -

    그리고 스프링 설정에는 각각의 레코드를 처리하기위해 특별히 설정된 - 전용(delegates) writer를 사용하는 CompositeItemWriter가 있다.

    - - - - - - - - - - - - -]]> - - interactionsItemWriter() { - CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); - List> writers = new ArrayList<>(4); - writers.add(visitorInteractionsWriter()); - writers.add(customerInteractionsWriter()); - writers.add(interactionMetadataWriter()); - writers.add(interactionWriter()); - compositeItemWriter.setDelegates(writers); - return compositeItemWriter; -}]]> - -

    각각의 전용(delegate) writer는 필요할 만큼 설정할 수 있다. - 예를들면 InteractionInteractionMetadata를 위한 writer가 있다.

    - - -]]> - -

    reader와 동일하게 statementId는 네임스페이스를 가진 구문을 가리킬수 있다.

    - -

    매퍼 파일에서 구문은 다음과 같은 방법으로 각각의 레코드를 위해 만들어져있다.

    - - - - - - -]]> - -

    먼저 insertInteractionMetadata가 호출될것이고 - update구문은 jdbc드라이버에 의해(keyPropertykeyColumn) 생성된 아이디들을 리턴하기 위해 설정되었다. - InteractionMetadata 객체가 이 쿼리에 의해 업데이트되면 다음의 쿼리는 - insertInteraction를 통해 상위객체인 Interaction를 작성하기 위해 사용될수 있다.

    - -

    방금 언급한 내용에 관련하여 JDBC드라이버가 똑같이 동작하지 않을수 있다. - 이 글을 쓰는 시점에 H2 드라이버 1.3.168버전(org.h2.jdbc.JdbcStatement#getGeneratedKeys를 보라)만 배치모드에서 마지막 인덱스를 리턴한다. - 반면에 MySQL 드라이버는 기대한 것과 동일하게 동작하고 모든 아이디를 리턴한다.

    - -
    - - diff --git a/src/site/ko/xdoc/boot.xml b/src/site/ko/xdoc/boot.xml deleted file mode 100644 index 8684637274..0000000000 --- a/src/site/ko/xdoc/boot.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - MyBatis-Spring | Spring Boot - Eduardo Macarron - - - -
    -

    - 자세한 내용은 MyBatis Spring-boot-starter - 하위 프로젝트 문서를 참조하십시오. -

    -
    - -
    diff --git a/src/site/ko/xdoc/factorybean.xml b/src/site/ko/xdoc/factorybean.xml deleted file mode 100644 index cc3d839a59..0000000000 --- a/src/site/ko/xdoc/factorybean.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | SqlSessionFactoryBean - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    -

    마이바티스만 사용하면, SqlSessionFactorySqlSessionFactoryBuilder를 사용해서 생성한다. - 마이바티스 스프링 연동모듈에서는, SqlSessionFactoryBean가 대신 사용된다.

    - - -

    팩토리 빈을 생성하기 위해, 스프링 XML설정파일에 다음설정을 추가하자.

    - - -]]> -

    SqlSessionFactoryBean 은 스프링의 FactoryBean 인터페이스를 구현(see the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-))한다는 점을 알아야 한다. - 이 설정은 스프링이 SqlSessionFactoryBean 자체를 생성하는 것이 아니라 팩토리에서 getObject() 메서드를 호출한 결과를 리턴한다는 것을 의미한다. - 이 경우, 스프링은 애플리케이션 시작 시점에 SqlSessionFactory를 빌드하고 sqlSessionFactory 라는 이름으로 저장한다. - 자바에서 코드로 표현하면 아래와 같다.

    - - - -

    일반적인 마이바티스 스프링 사용법에서는, SqlSessionFactoryBean이나 관련된 SqlSessionFactory를 직접 사용할 필요가 없다. - 대신 세션 팩토리가 MapperFactoryBeanSqlSessionDaoSupport를 확장하는 다른 DAO에 주입될것이다.

    -
    - - - -

    SqlSessionFactory는 JDBC DataSource의 필수 프로퍼티가 필요하다. - 어떤 DataSource라도 상관없고 다른 스프링 데이터베이스 연결처럼 설정되어야만 한다.

    - -

    하나의 공통적인 프로퍼티는 마이바티스 XML설정파일의 위치를 지정하기 위해 사용되는 configLocation이다. - 이 프로퍼티를 설정하는 것은 디폴트 설정을 가진 마이바티스 설정을 변경해야 할 경우 뿐이다. - 대개는 <settings><typeAliases> 섹션을 변경하는 경우이다.

    - -

    설정파일이 마이바티스 설정을 완전히 다룰 필요는 없다. - 어떤 환경, 어떤 데이터소스 그리고 마이바티스 트랜잭션 관리자가 무시될수도 있다. - SqlSessionFactoryBean 는 필요에 따라 이 값들을 설정하여 자체적인 MyBatis Environment 를 만든다.

    - -

    설정파일이 필요한 다른 이유는 마이바티스 XML파일이 매퍼 클래스와 동일한 클래스패스에 있지 않은 경우이다. - 이 설정을 사용하면 두가지 옵션이 있다. - 첫번째는 마이바티스 설정파일에 <mappers> 섹션을 사용해서 XML파일의 클래스패스를 지정하는 것이다. - 두번째는 팩토리 빈의 mapperLocations 프로퍼티를 사용하는 것이다.

    - -

    mapperLocations 프로퍼티는 매퍼에 관련된 자원의 위치를 나열한다. - 이 프로퍼티는 마이바티스의 XML매퍼 파일들의 위치를 지정하기 위해 사용될 수 있다. - 디렉터리 아래 모든 파일을 로드하기 위해 앤트(Ant) 스타일의 패턴을 사용할수도 있고 가장 상위 위치를 지정하는 것으로 재귀적으로 하위 경로를 찾도록 할수도 있다. - 예를 들어보면 다음과 같다.

    - - - - -]]> - -

    이 설정은 sample.config.mappers 패키지 아래와 그 하위 패키지를 모두 검색해서 마이바티스 매퍼 XML파일을 모두 로드할 것이다.

    - -

    컨테이너 관리 트랜잭션을 사용하는 환경에서 필요한 하나의 프로퍼티는 transactionFactoryClass 이다. - 이에 관련해서는 트랜잭션을 다루는 장에서 볼수 있다.

    - -

    - 만약 multi-db 기능을 사용한다면 다음과 같이 databaseIdProvider 속성을 설정해야 한다. -

    - - - - - sqlserver - db2 - oracle - mysql - - - - - - - - -]]> - -

    - NOTE - 1.3.0 버전 부터 configuration 속성이 추가되었다. - 다음과 같이 MyBatis XML 설정 파일없이 Configuration 인스턴스를 직접 지정할 수 있습니다. -

    - - - - - - - - -]]> - -
    -
    - -
    diff --git a/src/site/ko/xdoc/getting-started.xml.vm b/src/site/ko/xdoc/getting-started.xml.vm deleted file mode 100644 index 2596988331..0000000000 --- a/src/site/ko/xdoc/getting-started.xml.vm +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | 시작하기 - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    -

    이 장은 마이바티스 스프링 연동모듈을 설치하고 셋팅하는 방법에 대해 간단히 보여준다. - 그리고 트랜잭션을 사용하는 간단한 애플리케이션을 만드는 방법까지 다룰 것이다.

    - - -

    마이바티스 스프링 연동모듈을 사용하기 위해서, 클래스패스에 mybatis-spring-${project.version}.jar를 포함시켜야 한다.

    -

    메이븐을 사용하고 있다면 pom.xml에 다음처럼 의존성을 추가하면 된다.

    - - org.mybatis - mybatis-spring - ${project.version} -]]> -
    - - -

    마이바티스를 스프링과 함께 사용하려면 스프링의 애플리케이션 컨텍스트에 적어도 두개를 정의해줄 필요가 있다. - 두가지는 SqlSessionFactory와 한개 이상의 매퍼 인터페이스이다.

    - -

    마이바티스 스프링 연동모듈에서, SqlSessionFactoryBeanSqlSessionFactory를 만들기 위해 사용된다. - 팩토리 빈을 설정하기 위해, 스프링 설정파일에 다음 설정을 추가하자. -

    - - - -]]> - - - -

    SqlSessionFactoryDataSource를 필요로 하는 것을 알아둘 필요가 있다. - 어떤 DataSource도 상관없지만 다른 스프링의 데이터베이스 연결과 동일하게 설정되어야 한다.

    - -

    매퍼 인터페이스가 다음처럼 정의되었다고 가정해보자.

    - - -

    UserMapper인터페이스는 다음처럼 MapperFactoryBean을 사용해서 스프링에 추가된다.

    - - - -]]> - -

    매퍼는 반드시 구현체 클래스가 아닌 인터페이스로 정의되어야 한다. - 예를들어, 애노테이션이 SQL을 명시하기 위해 사용되지만 마이바티스 매퍼 XML파일 또한 사용될 수 있다.

    - -

    한번만 설정하면, 다른 스프링 빈에 주입하는 같은 방법으로 비즈니스/서비스 객체에 매퍼를 직접 주입할 수 있다. - MapperFactoryBeanSqlSession을 생성하고 닫는 작업을 잘 다룬다. - 실행중인 스프링 트랜잭션이 있다면, 트랜잭션이 완료되는 시점에 커밋이나 롤백이 될 것이다. - 마지막으로 예외가 발생하면 스프링의 DataAccessException예외가 발생한다.

    - -

    - 자바로 설정하면 다음과 같다. -

    - - - -

    마이바티스의 데이터 관련 메서드는 호출하는 것은 한줄이면 된다.

    - -
    -
    - -
    diff --git a/src/site/ko/xdoc/index.xml b/src/site/ko/xdoc/index.xml deleted file mode 100644 index 635a642b81..0000000000 --- a/src/site/ko/xdoc/index.xml +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | 소개 - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    - -

    마이바티스 스프링 연동모듈은 마이바티스와 스프링을 편하고 간단하게 연동한다. - 이 모듈은 마이바티스로 하여금 스프링 트랜잭션에 쉽게 연동되도록 처리한다. - 게다가 마이바티스 매퍼와 SqlSession을 다루고 다른 빈에 주입시켜준다. - 마이바티스 예외를 스프링의 DataAccessException로 변환하기도 하고 마이바티스, 스프링 또는 마이바티스 스프링 연동모듈에 의존성을 없애기도 한다.

    -
    - - -

    스프링 2.x은 아이바티스 2.x만을 지원한다. - 스프링 3.x에서 마이바티스 3.x를 지원하기 위한 시도가 진행중이다. - (스프링의 이슈관리 시스템인 이슈 를 보라.) - 불행하게도 스프링 3의 개발이 마이바티스 3.0의 정식릴리즈전에 개발이 완료되었다. - 그래서 스프링팀은 릴리즈가 안된 마이바티스 코드를 함께 릴리즈하는 것을 원하지 않았고 실제적인 스프링 지원을 기다릴수밖에 없었다. - 스프링의 마이바티스 지원에 대한 관심으로 인해, - 마이바티스 커뮤니티는 재결합하는 형태로 결정을 내고 대신 마이바티스의 하위 프로젝트 형태로 스프링 연동 프로젝트를 추가한다.

    -
    - - -

    마이바티스 스프링 연동을 시작하기 전에, 마이바티스와 스프링의 용어를 맞추는 일이 굉장히 중요했다. - 이 문서는 배경지식이나 기본적인 셋업방법 그리고 마이바티스와 스프링의 설정에 대한 튜토리얼등은 제공하지 않는다.

    -

    - MyBatis-Spring requires following versions: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - MyBatis-Spring - - MyBatis - - Spring Framework - - Spring Batch - - Java -
    - 2.0 - - 3.5+ - - 5.0+ - - 4.0+ - - Java 8+ -
    - 1.3 - - 3.4+ - - 3.2.2+ - - 2.1+ - - Java 6+ -
    -
    - - -

    이 프로젝트가 실제로 만들어지게 도와준 모든 특별한 분들에게 정말 감사한다. - 알파벳 순서로 보면, 코딩및 테스트 그리고 문서화를 담당했던 Eduardo Macarron, Hunter Presnall, Putthiphong Boonphong; - 그외 다양한 프로젝트 기여자인 Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan, Tomas Pinos; - 그리고 마이바티스에 하위 프로젝트로 가져올수 있도록 많은 것을 찾아준 Simone Tripodi 에게 감사한다. ;) - 이들이 없었다면 이 프로젝트는 존재하지 않았을 것이다.

    -
    - - -

    만약에 어떤 방법으로든 이 문서의 취약점이 발견되거나 기능에 대한 문서화가 빠진 부분이 보인다면, - 가장 좋은 방법은 먼저 공부해서 자신만의 문서를 작성하는 것이다. -

    -

    이 문서의 원본은 xdoc포맷이며 프로젝트의 Git에서 찾을 수 있다. - repository 를 fork 하고, 업데이트하고 pull request 를 보내주십시오. -

    -

    당신처럼 이 문서를 읽는 사람들에게 이 문서의 최고의 저자가 될수 있다!

    -
    - - -

    사용자들은 다음의 번역문서별로 마이바티스 스프링 연동모듈에 대해 알수 있다.

    - -

    위 번역문서에는 없지만 자국의 언어로 문서로 보고 싶다면, 자국의 언어로 된 문서를 만들어서 우리에게 보내달라.

    -
    - - -

    번역자 : 이동국(fromm0@gmail.com, http://ldg.pe.kr, https://www.facebook.com/dongguk.lee.3)

    -
    -
    - - -
    diff --git a/src/site/ko/xdoc/mappers.xml b/src/site/ko/xdoc/mappers.xml deleted file mode 100644 index 32296b7086..0000000000 --- a/src/site/ko/xdoc/mappers.xml +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | 매퍼 주입 - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    -

    SqlSessionDaoSupportSqlSessionTemplate 를 직접적으로 사용하는 데이터 접근 객체(DAO)를 생성하기 보다, - 마이바티스 스프링 연동모듈은 다른 빈에 직접 주입할 수 있는 쓰레드에 안전한 매퍼를 생성할 수 있다.

    - - - -]]> - -

    한번 주입하고나면 매퍼는 애플리케이션 로직에서 사용할수 있는 준비가 된다.

    - -

    이 코드를 보면 SqlSession이나 마이바티스 객체가 보이지 않는다. - 게다가 세션을 생성하거나 열고 닫을필요도 없어보인다. - 마이바티스 스프링 연동모듈이 알아서 처리할 것이다.

    - - -

    매퍼를 등록하는 방법은 기존의 전통적인 XML설정법을 사용하거나 새로운 3.0 이후의 자바설정(일명 @Configuration)을 사용하느냐에 따라 다르다.

    - -

    XML설정 사용

    - -

    매퍼는 다음처럼 XML설정파일에 MapperFactoryBean을 두는 것으로 스프링에 등록된다.

    - - - -]]> - -

    UserMapper가 매퍼 인터페이스와 같은 경로의 클래스패스에 마이바티스 XML매퍼 파일을 가지고 있다면 MapperFactoryBean이 자동으로 파싱할것이다. - 매퍼 XML파일을 다른 클래스패스에 두는게 아니라면 마이바티스 설정파일에 매퍼를 지정할 필요가 없다. - 좀더 세부적인 정보는 SqlSessionFactoryBeanconfigLocation 프로퍼티를 살펴보자.

    - -

    MapperFactoryBeanSqlSessionFactorySqlSessionTemplate가 필요하다. - sqlSessionFactorysqlSessionTemplate 프로퍼티를 셋팅하면 된다. - 둘다 셋팅하면 SqlSessionFactory가 무시된다. - 세션 팩토리 셋은 SqlSessionTemplate이 필요하고 MapperFactoryBean는 팩토리를 사용할것이다.

    - -

    자바설정 사용

    - - userMapper() throws Exception { - MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); - factoryBean.setSqlSessionFactory(sqlSessionFactory()); - return factoryBean; -}]]> - -
    - - -

    하나씩 매퍼를 모두 등록할 필요가 없다. - 대신 클래스패스를 지정해서 마이바티스 스프링 연동모듈의 자동스캔기능을 사용할 수 있다.

    - -

    자동스캔을 사용하는데는 3가지 방법이 있다.

    -
      -
    • <mybatis:scan/> 엘리먼트 사용
    • -
    • @MapperScan 애노테이션 사용
    • -
    • 스프링 XML파일을 사용해서 MapperScannerConfigurer를 등록
    • -
    - -

    <mybatis:scan/>@MapperScan 모두 마이바티스 스프링 연동모듈 1.2.0에서 추가된 기능이다. - @MapperScan 은 스프링 버전이 3.1이상이어야 한다.

    - -

    - Since 2.0.2, mapper scanning feature support a option (lazy-initialization) - that control lazy initialization enabled/disabled of mapper bean. - The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. - The default of this option is false (= not use lazy initialization). - If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. -

    -

    - IMPORTANT If use the lazy initialization feature, - the developer need to understand following limitations. If any of following conditions are matches, - usually the lazy initialization feature cannot use on your application. -

    -
      -
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • -
    • When includes to the fragment of other mapper using ]]>
    • -
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • -
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • -
    - -

    - NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: -

    - - - -

    - Since 2.0.6, the develop become can specified scope of mapper using mapper scanning feature option(default-scope) - and scope annotation(@Scope, @RefreshScope, etc ...). - The motivation for adding this option is supporting the refresh scope provided by the Spring Cloud. - The default of this option is empty (= equiv to specify the singleton scope). - The default-scope apply to the mapper bean(MapperFactoryBean) when scope of scanned bean definition - is singleton(default scope) and create a scoped proxy bean for scanned mapper when final scope is not singleton. -

    - -

    <mybatis:scan/>

    - -

    <mybatis:scan/> XML엘리먼트는 스프링에서 제공하는 <context:component-scan/> 엘리먼트와 매우 유사한 방법으로 매퍼를 검색할 것이다.

    - -

    샘플 XML설정을 아래에서 볼수 있다.

    - - - - - - - -]]> - -

    base-package 속성은 매퍼 인터페이스 파일이 있는 가장 상위 패키지를 지정하면 된다. - 세미콜론이나 콤마를 구분자로 사용해서 한개 이상의 패키지를 셋팅할 수 있다. - 매퍼는 지정된 패키지에서 재귀적으로 하위 패키지를 모두 검색할 것이다.

    - -

    <mybatis:scan/>이 자동으로 주입할 수 있는 MapperFactoryBean를 생성하기 때문에 - SqlSessionFactorySqlSessionTemplate 를 명시할 필요가 없다. - 하지만 한개 이상의 DataSource를 사용한다면 자동주입이 생각한데로 동작하지 않을수도 있다. - 이 경우 사용할 빈 이름을 지정하기 위해 factory-reftemplate-ref 속성을 사용할수 있다.

    - -

    <mybatis:scan/>은 마커(marker) 인터페이스나 애노테이션을 명시해서 생성되는 매퍼를 필터링할수도 있다. - annotation 프로퍼티는 검색할 애노테이션을 지정한다. - marker-interface 프로퍼티는 검색할 상위 인터페이스를 지정한다. - 이 두개의 프로퍼티를 모두 지정하면, 매퍼는 두 조건을 모두 만족하는 인터페이스만을 추가한다. - 디폴트로 이 두가지 프로퍼티는 모두 null이다. - 그래서 base-package프로퍼티에 설정된 패키지 아래 모든 인터페이스가 매퍼로 로드될 것이다.

    - -

    발견된 매퍼는 자동검색된 컴포넌트를 위한 스프링의 디폴트 명명규칙 전략(see the Spring reference document(Core Technologies -Naming autodetected components-))을 사용해서 빈이름이 명명된다. - 빈 이름을 정하는 애노테이션이 없다면 매퍼의 이름에서 첫글자를 소문자로 변환한 형태로 빈 이름을 사용할 것이다. - @Component 나 JSR-330의 @Named 애노테이션이 있다면 애노테이션에 정의한 이름을 그대로 사용할 것이다. - annotation 프로퍼티를 org.springframework.stereotype.Component, - javax.inject.Named(자바SE 1.6을 사용한다면) 또는 개발자가 스스로 작성한 애노테이션으로 셋팅할 수 있다. - 그러면 애노테이션은 마커와 이름을 제공하는 역할로 동작할 것이다.

    - -

    - 중요 <context:component-scan/> 가 매퍼를 검색해서 등록을 하지 못할수도 있다. - 매퍼는 인터페이스고 스프링에 빈으로 등록하기 위해서는 각각의 인터페이스를 찾기 위해 스캐너가 MapperFactoryBean 를 생성하는 방법을 알아야만 한다.

    - -

    @MapperScan

    - -

    @Configuration 라고 불리는 스프링의 자바설정을 사용한다면 <mybatis:scan/>보다는 - @MapperScan를 사용하길 선호할것이다.

    - -

    @MapperScan 애노테이션은 다음처럼 사용된다.

    - - - -

    애노테이션은 앞서 본 <mybatis:scan/> 에서 설명하는 것과 동일하게 동작한다. - markerInterfaceannotationClass 프로퍼티를 사용해서 마커 인터페이스와 애노테이션 클래스를 명시하게 한다. - sqlSessionFactorysqlSessionTemplate 프로퍼티를 사용해서 - SqlSessionFactorySqlSessionTemplate을 제공할 수도 있다.

    - -

    - NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. -

    - -

    MapperScannerConfigurer

    - -

    MapperScannerConfigurer는 평범한 빈처럼 XML애플리케이션 컨텍스트에 포함된 BeanDefinitionRegistryPostProcessor 이다. - MapperScannerConfigurer를 셋업하기 위해 다음의 스프링 설정을 추가하자.

    - - -]]> - -

    sqlSessionFactorysqlSessionTemplate를 지정할 필요가 있다면 빈참조가 아닌 빈이름이 필요하다. - value 프로퍼티는 빈 이름을 지정하고 ref 는 빈 참조를 지정하기 때문에 value 프로퍼티를 사용하자.

    - ]]> - -

    중요 sqlSessionFactoryBeansqlSessionTemplateBean 프로퍼티는 - 마이바티스 스프링 연동모듈 1.0.2 버전 이상에서만 사용이 가능하다. 하지만 MapperScannerConfigurer는 잦은 에러를 발생시키는 - PropertyPlaceholderConfigurer보다 앞서 실행되기 때문에 이 프로퍼티들은 사용하지 말길 바란다(deprecated). - 대신 새롭게 추가된 프로퍼티인 sqlSessionFactoryBeanNamesqlSessionTemplateBeanName 를 사용하도록 권한다.

    -
    -
    - -
    diff --git a/src/site/ko/xdoc/sample.xml b/src/site/ko/xdoc/sample.xml deleted file mode 100644 index 7debe92347..0000000000 --- a/src/site/ko/xdoc/sample.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - MyBatis-Spring | Sample Code - Eduardo Macarron - - - -
    - -

    - 중요 - 전체 웹 애플리케이션 서버에서 Spring을 사용하는 방법을 알고 싶다면 JPetstore 6 demo 를 참조하십시오. -

    - -

    - MyBatis-Spring repository 에서 샘플 코드를 확인할 수 있다. -

    -

    - 모든 샘플은 JUnit5 에서 실행할 수 있다. -

    -

    - 샘플 코드는 트랜잭션 서비스가 data access layer 에서 도메인 개체를 가져 오는 일반적인 디자인을 보여준다. -

    -

    - 다음 FooService.java 는 서비스처럼 작동한다. -

    - -

    - 이것은 트랜잭션 빈이다. 따라서 어떤 메서드든 실행이 되면 트랜잭션이 시작되고 예외가 발생하지 않았을 때 커밋된다. - 트랜잭션은 @Transactional annotation 을 통해 설정할 수 있다. - 이것은 필수가 아니다. Spring이 제공하는 다른 방법을 사용하여 트랜잭션을 구분할 수 있다. -

    -

    - 이 서비스는 MyBatis로 이루어진 DAO layer 를 호출한다. - 이 layer는 런타임시 MyBatis에 의해 작성되고 Spring에 의해 서비스에 주입되는 동적 프록시와 함께 사용되는 UserMapper.java 인터페이스로 구성된다. -

    - -

    - 단순함을 위해서 DAO가 인터페이스와 그 구현체로 만들어진 DAO 시나리오를 위해 UserMapper.java 인터페이스를 사용했지만, - 이 경우 대신 UserDao.java라는 인터페이스를 사용하는 것이 더 적절하다. -

    -

    - 매퍼 인터페이스를 찾고 Spring에 등록하고 서비스 빈에 주입하는 여러 가지 방법을 살펴본다. -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    시나리오
    샘플 테스트설명
    - SampleMapperTest.java - - UserMapper 구현체를 동적으로 빌드 할 MapperFactoryBean에 기반한 기본 구성을 보여준다. -
    - SampleScannerTest.java - - MapperScannerConfigurer 를 사용하여 어떻게 프로젝트의 모든 매퍼들을 자동으로 검색되도록 하는 방법을 보여준다. -
    - SampleSqlSessionTest.java - - Spring에서 관리하는 SqlSession을 사용하여 DAO를 코딩하고 자체적인 구현체인 UserDaoImpl.java 를 제공하는 방법을 보여준다. -
    - SampleEnableTest - - 스프링의 @Configuration@MapperScann annotation을 함께 사용하여 매퍼를 자동으로 검색하는 방법을 보여준다. -
    - SampleNamespaceTest - - 커스텀 MyBatis XML 네임스페이스를 사용하는 방법을 보여준다. -
    - SampleJavaConfigTest.java - - 스프링의 @Configuration을 사용하여 MyBatis 빈들을 수동적으로 생성하는 방법을 보여준다. -
    - SampleJobJavaConfigTest.java - - Java Configuration을 이용하여 Spring Batch에서 어떻게 ItemReaderItemWriter를 사용하는지 보여준다. -
    - SampleJobXmlConfigTest.java - - XML Configuration을 이용하여 Spring Batch에서 어떻게 ItemReaderItemWriter를 사용하는지 보여준다. -
    -

    - MyBatis-Spring이 실제로 어떻게 다르게 작동하는지 보려면 applicationContext.xml 파일을 살펴보십시오. -

    - -
    - -
    - diff --git a/src/site/ko/xdoc/sqlsession.xml b/src/site/ko/xdoc/sqlsession.xml deleted file mode 100644 index 23c92828a7..0000000000 --- a/src/site/ko/xdoc/sqlsession.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | SqlSession 사용 - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    -

    마이바티스에서는 SqlSession를 생성하기 위해 SqlSessionFactory를 사용한다. - 세션을 한번 생성하면 매핑구문을 실행하거나 커밋 또는 롤백을 하기 위해 세션을 사용할수 있다. - 마지막으로 더 이상 필요하지 않은 상태가 되면 세션을 닫는다. - 마이바티스 스프링 연동모듈을 사용하면 SqlSessionFactory를 직접 사용할 필요가 없다. - 왜냐하면, 스프링 트랜잭션 설정에 따라 자동으로 커밋 혹은 롤백을 수행하고 닫혀지는, 쓰레드에 안전한 SqlSession 개체가 스프링 빈에 주입될 수 있기 때문이다.

    - - -

    SqlSessionTemplate은 마이바티스 스프링 연동모듈의 핵심이다. - SqlSessionTemplateSqlSession을 구현하고 코드에서 SqlSession를 대체하는 역할을 한다. - SqlSessionTemplate 은 쓰레드에 안전하고 여러개의 DAO나 매퍼에서 공유할수 있다.

    - -

    getMapper()에 의해 리턴된 매퍼가 가진 메서드를 포함해서 SQL을 처리하는 마이바티스 메서드를 호출할때 - SqlSessionTemplateSqlSession이 현재의 스프링 트랜잭션에서 사용될수 있도록 보장한다. - 추가적으로 SqlSessionTemplate은 필요한 시점에 세션을 닫고, 커밋하거나 롤백하는 것을 포함한 세션의 생명주기를 관리한다. - 또한 마이바티스 예외를 스프링의 DataAccessException로 변환하는 작업또한 처리한다.

    - -

    SqlSessionTemplate은 마이바티스의 디폴트 구현체인 DefaultSqlSession 대신 항상 사용된다. - 왜냐하면 템플릿은 스프링 트랜잭션의 일부처럼 사용될 수 있고 여러개 주입된 매퍼 클래스에 의해 사용되도록 쓰레드에 안전하다. - 동일한 애플리케이션에서 두개의 클래스간의 전환은 데이터 무결성 이슈를 야기할수 있다.

    - -

    SqlSessionTemplate은 생성자 인자로 SqlSessionFactory를 사용해서 생성될 수 있다.

    - - -]]> - - - -

    이 빈은 DAO빈에 직접 주입될 수 있다. 다음처럼 빈 설정에서 SqlSession 프로퍼티를 설정하면 된다.

    - -

    그리고 다음처럼 SqlSessionTemplate 를 주입하자.

    - - -]]> - -

    SqlSessionTemplate은 인자로 ExecutorType를 가지는 생성자를 가지고 있다. - 이 인자는 예를들면 스프링 설정 XML을 다음처럼 설정해서 배치형태의 SqlSession를 만들수도 있다.

    - - - -]]> - - - -

    DAO의 코드를 다음처럼 작성했다면 모든 구문은 배치형태로 실행이 될 것이다.

    - users) { - for (User user : users) { - sqlSession.insert("org.mybatis.spring.sample.mapper.UserMapper.insertUser", user); - } -}]]> - -

    이러한 설정형태는 SqlSessionFactory의 디폴트 형태가 아닌 다른형태로 메서드를 실행해야 할때만 사용할 필요가 있다.

    - -

    이러한 형태에 대해 굳이 경로를 하자면 메서드를 호출할때 ExecutorType이 다르면 이미 시작된 트랜잭션을 사용하지 못할것이다. - 다른 실행자(executor) 타입을 사용할때는 SqlSessionTemplate의 메서드를 구분된 트랜잭션(PROPAGATION_REQUIRES_NEW를 사용하는)이나 트랜잭션 외부에서 호출하는지 확실히해야 한다.

    -
    - - -

    SqlSessionDaoSupportSqlSession을 제공하는 추상클래스이다. - getSqlSession()메서드를 호출해서 다음처럼 SQL을 처리하는 마이바티스 메서드를 호출하기 위해 사용할 SqlSessionTemplate을 얻을 수 있다.

    - -

    대개 MapperFactoryBean은 추가적인 코드가 필요없기 때문에 이 클래스를 선호한다. - 하지만 DAO에서 마이바티스가 필요하지 않고 구현된 클래스가 필요하지 않을때만 유용하다.

    - -

    SqlSessionDaoSupportsqlSessionFactorysqlSessionTemplate 프로퍼티를 셋팅할 필요가 있다. - 두개의 프로퍼티를 모두 셋팅하면 sqlSessionFactory는 무시된다.

    - -

    SqlSessionDaoSupport의 하위클래스인 UserDaoImpl가 있다고 하면 스프링에서는 다음처럼 설정될 수 있다.

    - - -]]> -
    -
    - -
    diff --git a/src/site/ko/xdoc/transactions.xml b/src/site/ko/xdoc/transactions.xml deleted file mode 100644 index 0efb7ee971..0000000000 --- a/src/site/ko/xdoc/transactions.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | 트랜잭션 - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    -

    마이바티스 스프링 연동모듈을 사용하는 중요한 이유중 하나는 마이바티스가 스프링 트랜잭션에 자연스럽게 연동될수 있다는 것이다. - 마이바티스에 종속되는 새로운 트랜잭션 관리를 만드는 것보다는 마이바티스 스프링 연동모듈이 스프링의 DataSourceTransactionManager과 융합되는 것이 좋다.

    -

    스프링 트랜잭션 관리자를 한번 설정하면, 대개의 경우처럼 스프링에서 트랜잭션을 설정할 수 있다. - @Transactional 애노테이션과 AOP스타일의 설정 모두 지원한다. - 하나의 SqlSession객체가 생성되고 트랜잭션이 동작하는 동안 지속적으로 사용될것이다. - 세션은 트랜잭션이 완료되면 적절히 커밋이 되거나 롤백될것이다.

    -

    마이바티스 스프링 연동모듈은 한번 셋업되면 트랜잭션을 투명하게 관리한다. - DAO클래스에 어떠한 추가적인 코드를 넣을 필요가 없다.

    - - -

    스프링 트랜잭션을 가능하게 하려면, 스프링 설정파일에 DataSourceTransactionManager를 생성하자.

    - - -]]> - - - -

    명시된 DataSource는 스프링을 사용할때 일반적으로 사용한다면 어떠한 JDBC DataSource도 될수 있다. - JNDI룩업을 통해 얻어진 DataSource뿐 아니라 커넥션 풀링 기능도 포함한다.

    -

    트랜잭션 관리자에 명시된 DataSourceSqlSessionFactoryBean을 생성할때 사용된 것과 반드시 동일한 것이어야 하는 것만 꼭 기억하자. - 그렇지 않으면 트랜잭션 관리가 제대로 되지 않을것이다.

    -
    - - -

    만약에 JEE컨테이너를 사용하고 스프링을 컨테이너 관리 트랜잭션(container managed transactions, CMT)에 두려한다면, - 스프링은 JtaTransactionManager나 그 하위 클래스로 설정되어야 한다. - 이러한 설정을 가장 쉽게 하는 방법은 스프링의 트랜잭션 네임스페이스 or JtaTransactionManagerFactoryBean 를 사용하는 것이다.

    - - ]]> - - - -

    이 설정에서, 마이바티스는 CMT와 함께 설정된 스프링 트랜잭션 리소스처럼 동작할 것이다. - 스프링은 이미 설정된 트랜잭션을 사용해서 SqlSession을 이미 동작중인 트랜잭션에 넣을 것이다. - 시작된 트랜잭션이 없고 트랜잭션이 필요한 경우라면 스프링은 새로운 컨테이너 관리 트랜잭션을 시작할 것이다.

    -

    CMT는 사용하지만 스프링 트랜잭션 관리를 원하지 않는다면 어떠한 스프링 트랜잭션 관리자를 설정해서도 안되고 - 마이바티스 ManagedTransactionFactory를 사용하기 위해 SqlSessionFactoryBean를 설정해야만 한다.

    - - - - - -]]> - - - -
    - - -

    마이바티스 SqlSession은 트랜잭션을 제어하는 메서드를 제공한다. - 하지만 마이바티스 스프링 연동모듈은 빈을 스프링이 관리하는 SqlSession이나 스프링이 관리하는 매퍼에 주입한다. - 이 말은 스프링이 항상 트랜잭션을 관리한다는 뜻이다.

    -

    스프링이 관리하는 SqlSession에서는 SqlSession.commit(), SqlSession.rollback() - 또는 SqlSession.close() 메서드를 호출할수가 없다. - 그럼에도 불구하고 이 메서드들을 사용하면 UnsupportedOperationException 예외가 발생한다. - 이러한 메서드는 주입된 매퍼 클래스에서는 사용할 수 없다.

    -

    JDBC연결의 자동커밋 설정을 어떻게 하더라도 스프링 트랜잭션 밖의 SqlSession 데이터 메서드나 매퍼 메서드의 실행은 자동으로 커밋된다.

    -

    트래잭션을 수동으로 제어하고자 한다면 the Spring reference document(Data Access -Programmatic transaction management-) 을 참고하자. - 다음의 코드는 스프링 레퍼런스 에서 언급된 내용으로 PlatformTransactionManager를 사용해서 수동으로 트랜잭션을 다루는 방법을 보여준다.

    - - - -

    - You can omit to call the commit and rollback method using the TransactionTemplate. -

    - - { - userMapper.insertUser(user); - return null; -});]]> - -

    이 코드는 매퍼를 사용하지만 SqlSession를 사용해도 잘 동작한다.

    -
    -
    - -
    diff --git a/src/site/ko/xdoc/using-api.xml b/src/site/ko/xdoc/using-api.xml deleted file mode 100644 index 760c6030c5..0000000000 --- a/src/site/ko/xdoc/using-api.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - 마이바티스 스프링 연동모듈 | 마이바티스 API 사용 - Hunter Presnall - Eduardo Macarron - 이동국(한국어 번역) - - - -
    -

    MyBatis-Spring 연동 모듈을 사용해도 계속해서 MyBatis API를 직접 사용할 수 있다. - SqlSessionFactoryBean을 사용해서 스프링에서 SqlSessionFactory를 생성하고 팩토리를 사용하면 된다.

    - - -

    이 방법은 신중히 사용하자. 왜냐하면 잘못사용하면 런타임 에러나 데이터 문제등을 야기할수 있기 때문이다. - API를 직접 사용할때는 다음의 규칙들에 유의해야 한다.

    -
      -
    • -

      스프링 트랜잭션에 속하지 않고 별도의 트랜잭션에서 동작한다.

      -
    • -
    • -

      SqlSession이 스프링 트랜잭션 관리자가 사용하는 DataSource를 사용하고 - 이미 트랜잭션이 동작하고 있다면 이 코드는 예외를 발생시킬 것이다.

      -
    • -
    • -

      마이바티스의 DefaultSqlSession은 쓰레드에 안전하지 않다. - 빈에 이 객체를 주입하면 아마도 에러를 발생시킬 수 있다.

      -
    • -
    • -

      DefaultSqlSession을 사용해서 생성한 매퍼 또한 쓰레드에 안전하지 않다. - 이렇게 만든 매퍼를 빈에 주입하면 에러를 발생시킬 수 있다.

      -
    • -
    • -

      SqlSession항상 마지막에 close() 메서드를 호출해야 한다.

      -
    • -
    -
    - -
    diff --git a/src/site/markdown/README.md b/src/site/markdown/README.md new file mode 100644 index 0000000000..74036dbd21 --- /dev/null +++ b/src/site/markdown/README.md @@ -0,0 +1,18 @@ +# Table of contents + +This page is for rendering index on GitHub. + +> **NOTE:** +> +> Since the link destination is specified on the assumption that it is converted to html with maven-site-plugin, there is an anchor that is broken in the rendering on GitHub. + +* [Introduction](./index.md) +* [Getting Started](./getting-started.md) +* [SqlSessionFactoryBean](./factorybean.md) +* [Transactions](./transactions.md) +* [Using an SqlSession](./sqlsession.md) +* [Injecting Mappers](./mappers.md) +* [Spring Boot](./boot.md) +* [Using the MyBatis API](./using-api.md) +* [Spring Batch](./batch.md) +* [Sample Code](./sample.md) diff --git a/src/site/markdown/batch.md b/src/site/markdown/batch.md new file mode 100644 index 0000000000..a6ad50418c --- /dev/null +++ b/src/site/markdown/batch.md @@ -0,0 +1,359 @@ + +# Spring Batch + +As of version 1.1.0 MyBatis-Spring provides three beans for building Spring Batch applications: the `MyBatisPagingItemReader`, the `MyBatisCursorItemReader` and the `MyBatisBatchItemWriter`. +Also, As of version 2.0.0 provides three builder classes for supporting the Java Configuration: the `MyBatisPagingItemReaderBuilder`, the `MyBatisCursorItemReaderBuilder` and the `MyBatisBatchItemWriterBuilder`. + +NOTE +This is about [Spring Batch](http://static.springsource.org/spring-batch/) and not about MyBatis batch SqlSessions. For information about batch sessions go to section [Using an SqlSession](sqlsession.html). + +## MyBatisPagingItemReader + +This bean is an `ItemReader` that reads records from a database in a paging fashion. + +It executes the query specified as the `setQueryId` property to retrieve requested data. +The query is executed using paged requests of a size specified in `setPageSize` property. +Additional pages are requested when needed as `read()` method is called, returning an object corresponding to current position. + +Some standard query parameters are provided by the reader and the SQL in the named query must use some or all of these parameters (depending on the SQL variant) to construct a result set of the required size. +The parameters are: + +* `_page`: the page number to be read (starting at 0) +* `_pagesize`: the size of the pages, i.e. the number of rows to return +* `_skiprows`: the product of `_page` and `_pagesize` + +And they could be mapped as the follow in a select statement: + +```xml + +``` + +Follows below a sample configuration snippet: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisPagingItemReader reader() { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +**Explaining a more complex example:** + +```xml + +``` +```xml + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @StepScope + @Bean + public MyBatisPagingItemReader dateBasedCriteriaReader( + @Value("#{@datesParameters}") Map datesParameters) throws Exception { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(batchReadingSessionFactory()) + .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") + .parameterValues(datesParameters) + .pageSize(200) + .build(); + } + + @StepScope + @Bean + public Map datesParameters( + @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, + @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { + Map map = new HashMap<>(); + map.put("yesterday", yesterday); + map.put("today", today); + map.put("first_day_of_the_month", firstDayOfTheMonth); + map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); + return map; + } +} +``` + +The previous example makes use of a few different things: + +* `sqlSessionFactory`: You can specify your own sessionFactory to the reader, it might be useful if you want to read from several databases. + +* `queryId`: If the base code have several tables or databases to read from, and that you have different queries, it might be interesting to use different mapper files with different namespaces. + so when referring to the query, don't forget about the namespace of the mapper file. + +* `parameterValues`: You can pass additional parameters via this map, the example above uses a map that is build by spring using a SpEL expression taking values from the `jobExecutionContext`. + The keys of the map will be used by MyBatis in the mapper file (ex: *yesterday* could be used as `#{yesterday,jdbcType=TIMESTAMP}`). + Note that the map and the reader are both built in the `step` scope in order to be able to use the Spring EL expression with the `jobExecutionContext`. + Also if MyBatis type handlers are correctly configured you can pass custom instances like the parameters of this map that are JodaTime dates. + +* `pageSize`: If the batch flow is configured with chunk size, it is relevant to pass this information to the reader as well, which is done via this property. + +## MyBatisCursorItemReader + +This bean is an `ItemReader` that reads records from a database using a cursor. + +NOTE +To use this bean you need at least MyBatis 3.4.0 or a newer version. + +It executes the query specified as the `setQueryId` property to retrieve requested data by using the method `selectCursor()`. +Each time a `read()` method is called it will return the next element of the cursor until no more elements are left. + +The reader will use a separate connection so the select statement does no participate in any transactions created as part of the step processing. + +When using the cursor you can just execute a regular query: + +```xml + +``` + +Follows below a sample configuration snippet: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisCursorItemReader reader() { + return new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +## MyBatisBatchItemWriter + +It is an `ItemWriter` that uses the batching features from `SqlSessionTemplate` to execute a batch of statements for all items provided. +The `SqlSessionFactory` needs to be configured with a `BATCH` executor. + +When `write()` is called it executes the mapped statement indicated in the property `statementId`. It is expected that `write()` is called inside a transaction. + +Follows below a sample configuration snippet: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") + .build(); + } +} +``` + +**Converting a item that read using ItemReader to an any parameter object:** + +By default behavior, the `MyBatisBatchItemWriter` passes a item that read using `ItemReader` (or convert by `ItemProcessor`) to the MyBatis(`SqlSession#update()`) as the parameter object. +If you want to customize a parameter object that passes to the MyBatis, you can realize to use the `itemToParameterConverter` option. +For example using `itemToParameterConverter` option, you can passes any objects other than the item object to the MyBatis. +Follows below a sample: + +At first, you create a custom converter class (or factory method). The following sample uses a factory method. + +```java +public class ItemToParameterMapConverters { + public static Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; + } +} +``` + +At next, you write a sql mapping. + +```xml + +``` + +At last, you configure the MyBatisBatchItemWriter. + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() throws Exception { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); + } +} +``` + +```xml + + + + + + + + + + +``` + +**Writing to different tables using composite writers (with some caveats):** + +This technique can only be used with MyBatis 3.2+, as there was an [issue](http://code.google.com/p/mybatis/issues/detail?id=741) in previous versions that made the writer misbehave. + +If the batch needs to write complex data, like records with associations, or even to different databases, then it is possible to work around the fact that insert statements only insert in one table. +In order to make it happen the batch have to prepare the *Item* to be written by the writer. +However depending on the constraints, opportunities or insight on the processed data it might be interesting to use the following technique. +The following trick can work on items with simple associations or just with unrelated tables. + +In a processor craft the Spring Batch Item in such way it will *hold* all the different records. +Suppose for each Item there is an *Interaction* that have one association *InteractionMetadata*, +and two non associated rows *VisitorInteraction* and *CustomerInteraction*, the holder object will look like: + +```java +public class InteractionRecordToWriteInMultipleTables { + private final VisitorInteraction visitorInteraction; + private final CustomerInteraction customerInteraction; + private final Interaction interaction; + // ... +} +``` +```java +public class Interaction { + private final InteractionMetadata interactionMetadata; +} +``` + +Then in the spring configuration there will be a `CompositeItemWriter` that will use delegate writers specifically configured for each kind of records. +Note that as the *InteractionMetadata* is an association in the example it will need to be written first so that Interaction can have the updated key. + +```xml + + + + + + + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public CompositeItemWriter interactionsItemWriter() { + CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); + List> writers = new ArrayList<>(4); + writers.add(visitorInteractionsWriter()); + writers.add(customerInteractionsWriter()); + writers.add(interactionMetadataWriter()); + writers.add(interactionWriter()); + compositeItemWriter.setDelegates(writers); + return compositeItemWriter; + } +} +``` + +Then each delegate writer will be configured as needed; for example for *Interaction* and *InteractionMetadata*: + +```xml + +``` +```xml + +``` + +Same as the reader the `statementId` can refer to the statement with the prefixed namespace. + +Now in the mapper file the statement have to be crafted for each kind of records in the following way: + +```xml + + + +``` +```xml + + + +``` + +What's happening is that first the `insertInteractionMetadata` will be called, and the update statement is configured to return the ids created by the jdbc driver (`keyProperty` and `keyColumn`). +As the `InteractionMetadata` object were updated by this query the next query can be used to write the parent object `Interaction` via `insertInteraction`. + +***However note that JDBC drivers don't behave the same in this regard. At the time of this writing the H2 driver 1.3.168 will only return the latest index even in BATCH mode (see `org.h2.jdbc.JdbcStatement#getGeneratedKeys`), +while the MySQL JDBC driver will behave as expected and return all the IDs.*** diff --git a/src/site/markdown/boot.md b/src/site/markdown/boot.md new file mode 100644 index 0000000000..678db5d753 --- /dev/null +++ b/src/site/markdown/boot.md @@ -0,0 +1,4 @@ + +# Using Spring Boot + +Please see the [MyBatis Spring-boot-starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure) sub project docs for details. diff --git a/src/site/markdown/factorybean.md b/src/site/markdown/factorybean.md new file mode 100644 index 0000000000..cf403649f8 --- /dev/null +++ b/src/site/markdown/factorybean.md @@ -0,0 +1,100 @@ + +# SqlSessionFactoryBean + +In base MyBatis, the `SqlSessionFactory` is built using `SqlSessionFactoryBuilder`. In MyBatis-Spring, `SqlSessionFactoryBean` is used instead. + +## Setup + +To create the factory bean, put the following in the Spring XML configuration file: + +```xml + + + +``` +Note that `SqlSessionFactoryBean` implements Spring's `FactoryBean` interface see [the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-)](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-extension-factorybean)). +This means that the bean Spring ultimately creates is **not** the `SqlSessionFactoryBean` itself, but what the factory returns as a result of the `getObject()` call on the factory. +In this case, Spring will build an `SqlSessionFactory` for you at application startup and store it with the name `sqlSessionFactory`. +In Java, the equivalent code would be: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +In normal MyBatis-Spring usage, you will not need to use `SqlSessionFactoryBean` or the corresponding `SqlSessionFactory` directly. +Instead, the session factory will be injected into `MapperFactoryBean`s or other DAOs that extend `SqlSessionDaoSupport`. + +## Properties + +`SqlSessionFactory` has a single required property, the JDBC `DataSource`. This can be any `DataSource` and should be configured just like any other Spring database connection. + +One common property is `configLocation` which is used to specify the location of the MyBatis XML configuration file. +One case where this is needed is if the base MyBatis configuration needs to be changed. Usually this will be `` or `` sections. + +Note that this config file does **not** need to be a complete MyBatis config. Specifically, any environments, data sources and MyBatis transaction managers will be **ignored**. +`SqlSessionFactoryBean` creates its own, custom MyBatis `Environment` with these values set as required. + +Another reason to require a config file is if the MyBatis mapper XML files are not in the same classpath location as the mapper classes. With this configuration, there are two options. +This first is to manually specify the classpath of the XML files using a `` section in the MyBatis config file. A second option is to use the `mapperLocations` property of the factory bean. + +The `mapperLocations` property takes a list of resource locations. This property can be used to specify the location of MyBatis XML mapper files. +The value can contain Ant-style patterns to load all files in a directory or to recursively search all paths from a base location. + +For example: + +```xml + + + + +``` + +This will load all the MyBatis mapper XML files in the `sample.config.mappers` package and its sub-packages from the classpath. + +One property that may be required in an environment with container managed transactions is `transactionFactoryClass`. Please see the relevant section in the Transactions chapter. + +In case you are using the multi-db feature you will need to set the `databaseIdProvider` property: + +```xml + + + + sqlserver + db2 + oracle + mysql + + + +``` +```xml + + + + + +``` + +NOTE +Since 1.3.0, `configuration` property has been added. It can be specified a `Configuration` instance directly without MyBatis XML configuration file. + +For example: + +```xml + + + + + + + + +``` diff --git a/src/site/markdown/getting-started.md b/src/site/markdown/getting-started.md new file mode 100644 index 0000000000..c33f7f393d --- /dev/null +++ b/src/site/markdown/getting-started.md @@ -0,0 +1,100 @@ + +# Getting Started + +This chapter will show you in a few steps how to install and setup MyBatis-Spring and how to build a simple transactional application. + +## Installation + +To use the MyBatis-Spring module, you just need to include the `mybatis-spring-${project.version}.jar` file and its dependencies in the classpath. + +If you are using Maven just add the following dependency to your pom.xml: + +```xml + + org.mybatis + mybatis-spring + ${project.version} + +``` + +## Quick Setup + +To use MyBatis with Spring you need at least two things defined in the Spring application context: +an `SqlSessionFactory` and at least one mapper interface. + +In MyBatis-Spring, an `SqlSessionFactoryBean` is used to create an `SqlSessionFactory`. To configure the factory bean, put the following in the Spring configuration file: + +```xml + + + +``` + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +Notice that the `SqlSessionFactory` requires a `DataSource`. This can be any `DataSource` and should be configured just like any other Spring database connection. + +Assume you have a mapper interface defined like the following: + +```java +public interface UserMapper { + @Select("SELECT * FROM users WHERE id = #{userId}") + User getUser(@Param("userId") String userId); +} +``` + +This interface is added to Spring using a `MapperFactoryBean` like the following: + +```xml + + + + +``` + +Note that the mapper class specified **must** be an interface, not an actual implementation class. In this example, annotations are used to specify the SQL, but a MyBatis mapper XML file could also be used. + +Once configured, you can inject mappers directly into your business/service objects in the same way you inject any other Spring bean. +The `MapperFactoryBean` handles creating an `SqlSession` as well as closing it. +If there is a Spring transaction in progress, the session will also be committed or rolled back when the transaction completes. +Finally, any exceptions will be translated into Spring `DataAccessException`s. + +If you use the Java Configuration: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public UserMapper userMapper() throws Exception { + SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); + return sqlSessionTemplate.getMapper(UserMapper.class); + } +} +``` + +Calling MyBatis data methods is now only one line of code: + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md new file mode 100644 index 0000000000..c7b577c2ff --- /dev/null +++ b/src/site/markdown/index.md @@ -0,0 +1,54 @@ + +# Introduction + +## What is MyBatis-Spring? + +MyBatis-Spring integrates MyBatis seamlessly with Spring. +This library allows MyBatis to participate in Spring transactions, takes care of building MyBatis mappers and `SqlSession`s and inject them into other beans, translates MyBatis exceptions into Spring `DataAccessException`s, and finally, it lets you build your application code free of dependencies on MyBatis, Spring or MyBatis-Spring. + +## Motivation + +Spring version 2 only supports iBATIS version 2. An attempt was made to add MyBatis 3 support into Spring 3 (see the Spring Jira [issue](https://jira.springsource.org/browse/SPR-5991). +Unfortunately, Spring 3 development ended before MyBatis 3 was officially released. Because the Spring team did not want to release with code based on a non-released version of MyBatis, official Spring support would have to wait. +Given the interest in Spring support for MyBatis, the MyBatis community decided it was time to reunite the interested contributors and add Spring integration as a community sub-project of MyBatis instead. + +## Requirements + +Before starting with MyBatis-Spring integration, it is very important that you are familiar with both MyBatis and Spring terminology. +This document does not attempt to provide background information or basic setup and configuration tutorials for either MyBatis or Spring. + +MyBatis-Spring requires following versions: + +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +| --- | --- | --- | --- | --- | +| **2.0** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | + +## Acknowledgements + +A special thanks goes to all the special people who made this project a reality (in alphabetical order): Eduardo Macarron, Hunter Presnall and Putthiphong Boonphong for the coding, +testing and documentation; Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan and Tomas Pinos for their contributions; and Simone Tripodi for finding everyone and bringing them all back to the project under MyBatis ;) +Without them, this project wouldn't exist. + +## Help make this documentation better… + +If you find this documentation lacking in any way, or missing documentation for a feature, then the best thing to do is learn about it and then write the documentation yourself! + +Sources of this manual are available in markdown format at [project's Git](https://github.com/mybatis/spring/tree/master/src/site) Fork the repository, update them and send a pull request. + +You’re the best author of this documentation, people like you have to read it! + +## Translations + +Users can read about MyBatis-Spring in the following translations: + + + +Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your mother tongue documentation! + diff --git a/src/site/markdown/mappers.md b/src/site/markdown/mappers.md new file mode 100644 index 0000000000..7153f7385d --- /dev/null +++ b/src/site/markdown/mappers.md @@ -0,0 +1,182 @@ + +# Injecting Mappers + +Rather than code data access objects (DAOs) manually using `SqlSessionDaoSupport` or `SqlSessionTemplate`, Mybatis-Spring can create a thread safe mapper that you can inject directly into other beans: + +```xml + + + +``` + +Once injected, the mapper is ready to be used in application logic: + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` + +Notice that there are no `SqlSession` or MyBatis references in this code. Nor is there any need to create, open or close the session, MyBatis-Spring will take care of that. + + +## Registering a mapper + +The way you register a mapper depends on whether you are using a classic XML configuration or the new 3.0+ Java Config (a.k.a. `@Configuration`). + +### With XML Config + +A mapper is registered to Spring by including a `MapperFactoryBean` in your XML config file like follows: + +```xml + + + + +``` + +If the UserMapper has a corresponding MyBatis XML mapper file in the same classpath location as the mapper interface, it will be parsed automatically by the `MapperFactoryBean`. +There is no need to specify the mapper in a MyBatis configuration file unless the mapper XML files are in a different classpath location. See the `SqlSessionFactoryBean`'s `[configLocation](factorybean.html)` property for more information. + +Note that `MapperFactoryBean` requires either an `SqlSessionFactory` or an `SqlSessionTemplate`. These can be set through the respective `sqlSessionFactory` and `sqlSessionTemplate` properties. +If both properties are set, the `SqlSessionFactory` is ignored. Since the `SqlSessionTemplate` is required to have a session factory set, that factory will be used by `MapperFactoryBean`. + +### With Java Config + +```java +@Configuration +public class MyBatisConfig { + @Bean + public MapperFactoryBean userMapper() throws Exception { + MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); + factoryBean.setSqlSessionFactory(sqlSessionFactory()); + return factoryBean; + } +} +``` + + +## Scanning for mappers + +There is no need to register all your mappers one by one. Instead, you can let MyBatis-Spring scan your classpath for them. + +There are three different ways to do it: + +* Using the `` element. +* Using the annotation `@MapperScan` +* Using a classic Spring xml file and registering the `MapperScannerConfigurer` + +Both `` and `@MapperScan` are features introduced in MyBatis-Spring 1.2.0. `@MapperScan` requires Spring 3.1+. + +Since 2.0.2, mapper scanning feature support an option (`lazy-initialization`) that control lazy initialization enabled/disabled of mapper bean. +The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. The default of this option is `false` (= not use lazy initialization). +If developer want to use lazy initialization for mapper bean, it should be set to the `true` expressly. + +IMPORTANT +If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, usually the lazy initialization feature cannot use on your application. + +* When refers to the statement of **other mapper** using ``(`@One`) and ``(`@Many`) +* When includes to the fragment of **other mapper** using `` +* When refers to the cache of **other mapper** using ``(`@CacheNamespaceRef`) +* When refers to the result mapping of **other mapper** using `]]> - -

    Follows below a sample configuration snippet:

    - - - - -
    ]]> - - reader() { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -

    Explaining a more complex example:

    - - - - - - - - -]]> - - dateBasedCriteriaReader( - @Value("#{@datesParameters}") Map datesParameters) throws Exception { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(batchReadingSessionFactory()) - .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") - .parameterValues(datesParameters) - .pageSize(200) - .build(); -} - -@StepScope -@Bean -public Map datesParameters( - @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, - @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { - Map map = new HashMap<>(); - map.put("yesterday", yesterday); - map.put("today", today); - map.put("first_day_of_the_month", firstDayOfTheMonth); - map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); - return map; -}]]> - -

    - The previous example makes use of a few different things: -

    - -
      -
    • sqlSessionFactory: You can specify your own sessionFactory to the reader, it might be - useful if you want to read from several databases.
    • -
    • queryId: If the base code have several tables or databases to read from, and that you have different - queries, it might be interesting to use different mapper files with different namespaces. - so when referring to the query, don't forget about the namespace of the mapper file.
    • -
    • parameterValues: You can pass additional parameters via this map, the example above uses - a map that is build by spring using a SpEL expression taking values from the jobExecutionContext. - The keys of the map will be used by MyBatis in the mapper file (ex: - yesterday could be used as #{yesterday,jdbcType=TIMESTAMP}). - Note that the map and the reader are both built in the step scope in order to be able to use - the Spring EL expression with the jobExecutionContext. Also if MyBatis type handlers - are correctly configured you can pass custom instances like the parameters of this map that are JodaTime - dates.
    • -
    • pageSize: If the batch flow is configured with chunk size, it is relevant to pass this - information to the reader as well, which is done via this property.
    • -
    - - - - -

    - This bean is an ItemReader that reads records from a database using a cursor. -

    - -

    - NOTE To use this bean you need at least MyBatis 3.4.0 or a newer version. -

    - -

    - It executes the query specified as the setQueryId property to retrieve requested data - by using the method selectCursor(). - Each time a read() method is called it will return the next element of the cursor until no more - elements are left. -

    - -

    - The reader will use a separate connection so the select statement does no participate in any transactions created - as part of the step processing. -

    - -

    When using the cursor you can just execute a regular query:

    - - SELECT id, name, job FROM employees ORDER BY id ASC -]]> - -

    Follows below a sample configuration snippet:

    - - - - -
    ]]> - - reader() { - return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - - - - - -

    - It is an ItemWriter that uses the batching features from SqlSessionTemplate - to execute a batch of statements for all items provided. - The SqlSessionFactory needs to be configured with a BATCH executor. -

    - -

    - When write() is called it executes the mapped statement indicated in the property statementId. - It is expected that write() is called inside a transaction.
    -

    - -

    Follows below a sample configuration snippet:

    - - - - -
    ]]> - - writer() { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") - .build(); -}]]> - -

    Converting a item that read using ItemReader to an any parameter object:

    - -

    - By default behavior, the MyBatisBatchItemWriter passes a item that read using ItemReader - (or convert by ItemProcessor) to the MyBatis(SqlSession#update()) as the parameter object. - If you want to customize a parameter object that passes to the MyBatis, you can realize to use the itemToParameterConverter option. - For example using itemToParameterConverter option, you can passes any objects other than the item object to the MyBatis. - Follows below a sample: -

    - -

    - At first, you create a custom converter class (or factory method). The following sample uses a factory method. -

    - - Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { - return item -> { - Map parameter = new HashMap<>(); - parameter.put("item", item); - parameter.put("operationBy", operationBy); - parameter.put("operationAt", operationAt); - return parameter; - }; -}]]> - -

    - At next, you write a sql mapping. -

    - - - insert into persons (first_name, last_name, operation_by, operation_at) - values(#{item.firstName}, #{item.lastName}, #{operationBy}, #{operationAt}) -]]> - -

    - At last, you configure the MyBatisBatchItemWriter. -

    - - writer() throws Exception { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") - .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) - .build(); -}]]> - - - - - - - - - - - - -]]> - -

    Writing to different tables using composite writers (with some caveats):

    - -

    This technique can only be used with MyBatis 3.2+, as there was an - issue in previous - versions that made the writer misbehave. -

    - -

    If the batch needs to write complex data, like records with associations, or even to different databases, then - it is possible to work around the fact that insert statements only insert in one table. In order to make it - happen the batch have to prepare the Item to be written by the writer. However depending on the - constraints, opportunities or insight on the processed data it might be interesting to use the following technique. - The following trick can work on items with simple associations or just with unrelated tables. -

    - -

    In a processor craft the Spring Batch Item in such way it will hold all the different records. - Suppose for each Item there is an Interaction that have one association - InteractionMetadata, and two non associated rows VisitorInteraction and - CustomerInteraction, the holder object will look like: -

    - - - -

    Then in the spring configuration there will be a CompositeItemWriter that will use delegate - writers specifically configured for each kind of records. Note that as the InteractionMetadata is - an association in the example it will need to be written first so that Interaction can have the updated key. -

    - - - - - - - - - - - - -]]> - - interactionsItemWriter() { - CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); - List> writers = new ArrayList<>(4); - writers.add(visitorInteractionsWriter()); - writers.add(customerInteractionsWriter()); - writers.add(interactionMetadataWriter()); - writers.add(interactionWriter()); - compositeItemWriter.setDelegates(writers); - return compositeItemWriter; -}]]> - -

    Then each delegate writer will be configured as needed; for example for Interaction and - InteractionMetadata: -

    - - -]]> - -

    Same as the reader the statementId can refer to the statement with the prefixed namespace.

    - -

    Now in the mapper file the statement have to be crafted for each kind of records in the following way:

    - - - - - - -]]> - -

    What's happening is that first the insertInteractionMetadata will be called, and the update - statement is configured to return the ids created by the jdbc driver (keyProperty and keyColumn). - As the InteractionMetadata object were updated by this query the next query can be used to write the parent - object Interaction via insertInteraction. -

    - -

    However note that JDBC drivers don't behave the same in this regard. At the time of this writing - the H2 driver 1.3.168 will only return the latest index even in BATCH mode (see org.h2.jdbc.JdbcStatement#getGeneratedKeys), - while the MySQL JDBC driver will behave as expected and return all the IDs. -

    - - - - diff --git a/src/site/xdoc/boot.xml b/src/site/xdoc/boot.xml deleted file mode 100644 index fd430114c4..0000000000 --- a/src/site/xdoc/boot.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - MyBatis-Spring | Spring Boot - Eduardo Macarron - - - -
    -

    - Please see the MyBatis Spring-boot-starter - subproject docs for details. -

    -
    - -
    diff --git a/src/site/xdoc/factorybean.xml b/src/site/xdoc/factorybean.xml deleted file mode 100644 index 16c3f98444..0000000000 --- a/src/site/xdoc/factorybean.xml +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - MyBatis-Spring | SqlSessionFactoryBean - Hunter Presnall - Eduardo Macarron - - - -
    -

    - In base MyBatis, the SqlSessionFactory is built using - SqlSessionFactoryBuilder. In MyBatis-Spring, - SqlSessionFactoryBean is used instead. -

    - - -

    - To create the factory bean, put the following in the Spring XML - configuration file: -

    - - -]]> -

    - Note that - SqlSessionFactoryBean - implements Spring's - FactoryBean - interface (see the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-)). - This means that the bean Spring ultimately creates is - not - the - SqlSessionFactoryBean - itself, but what the - factory returns as a result of the - getObject() - call on - the factory. In this case, Spring will build an - SqlSessionFactory - for you at application startup and - store it with the name - sqlSessionFactory - . In Java, the - equivalent code would be: -

    - - - -

    - In normal MyBatis-Spring usage, you will not need to use - SqlSessionFactoryBean - or the corresponding - SqlSessionFactory - directly. Instead, the session - factory will be injected into - MapperFactoryBeans or - other DAOs that extend - SqlSessionDaoSupport - . -

    -
    - - - -

    - SqlSessionFactory - has a single required property, the - JDBC - DataSource - . This can be any - DataSource - and should be configured just - like any other Spring database - connection. -

    - -

    - One common property is - configLocation - which is used to - specify the location of the MyBatis XML - configuration file. One case - where this is needed is if the base - MyBatis configuration needs to be - changed. Usually this will be - <settings> - or - <typeAliases> - sections. -

    - -

    - Note that this config file does - not - need to be a - complete MyBatis config. Specifically, any environments, - data sources - and MyBatis transaction managers will be - ignored - . - SqlSessionFactoryBean - creates its own, custom MyBatis - Environment - with these values set as required. -

    - -

    - Another reason to require a config file is if the MyBatis mapper XML - files are not in the same classpath location as the mapper classes. - With - this configuration, there are two options. This first is to - manually - specify the classpath of the XML files using a - <mappers> - section in the MyBatis config - file. A second option is to use the - mapperLocations - property of the factory bean. -

    - -

    - The - mapperLocations - property takes a list of resource - locations. This property can be - used to specify the location of MyBatis - XML mapper files. The value - can contain Ant-style patterns to load all - files in a directory or to - recursively search all paths from a base - location. For example: -

    - - - - -]]> - -

    - This will load all the MyBatis mapper XML files in the - sample.config.mappers package and its sub-packages from the - classpath. -

    - -

    - One property that may be required in an environment with container - managed transactions is - transactionFactoryClass - . - Please see the relevant section in the - Transactions chapter. -

    - -

    - In case you are using the multi-db feature you will need to set the databaseIdProvider property: -

    - - - - - sqlserver - db2 - oracle - mysql - - - - - - - - -]]> - -

    - NOTE - Since 1.3.0, configuration property has been added. - It can be specified a Configuration instance directly without MyBatis XML configuration file. - For example: -

    - - - - - - - - -]]> - -
    -
    - -
    diff --git a/src/site/xdoc/getting-started.xml.vm b/src/site/xdoc/getting-started.xml.vm deleted file mode 100644 index c3bc9569ca..0000000000 --- a/src/site/xdoc/getting-started.xml.vm +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - MyBatis-Spring | Getting Started - Hunter Presnall - Eduardo Macarron - - - -
    -

    - This chapter will show you in a few steps how to install and setup - MyBatis-Spring and how to build - a simple transactional application. -

    - - -

    - To use the MyBatis-Spring module, you just need to include the - mybatis-spring-${project.version}.jar - file and its dependencies in the classpath. -

    -

    - If you are using Maven just add the following dependency - to your - pom.xml: -

    - - org.mybatis - mybatis-spring - ${project.version} -]]> -
    - - -

    - To use MyBatis with Spring you need at least two things defined in - the - Spring application context: an - SqlSessionFactory - and - at least one mapper interface. -

    - -

    - In MyBatis-Spring, an - SqlSessionFactoryBean - is used to - create an - SqlSessionFactory - . To configure the - factory bean, put the following in the Spring - configuration file: -

    - - - -]]> - - - -

    - Notice that the - SqlSessionFactory - requires a - DataSource - . This can be any - DataSource - and should be configured just like any other Spring database - connection. -

    - -

    - Assume you have a mapper interface defined like the following: -

    - - -

    - This interface is added to Spring using a - MapperFactoryBean - like the following: -

    - - - -]]> - -

    - Note that the mapper class specified - must - be an - interface, not an actual implementation class. In this example, - annotations are used to specify the SQL, but a MyBatis mapper XML - file - could also be used. -

    - -

    - Once configured, you can inject mappers directly into your - business/service objects in the same way you inject any other Spring - bean. The MapperFactoryBean - handles creating an SqlSession - as well as closing it. If there is a Spring transaction in - progress, - the session will also be committed or rolled back when the - transaction completes. Finally, any exceptions will be translated - into Spring DataAccessExceptions. -

    - -

    - If you use the Java Configuration: -

    - - - -

    - Calling MyBatis data methods is now only one line of code: -

    - -
    -
    - -
    diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml deleted file mode 100644 index c74c1048d5..0000000000 --- a/src/site/xdoc/index.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - MyBatis-Spring | Introduction - Hunter Presnall - Eduardo Macarron - - - -
    - -

    - MyBatis-Spring integrates MyBatis seamlessly with Spring. - This library allows MyBatis to participate in Spring transactions, takes care of - building MyBatis mappers and SqlSessions and inject them into other beans, - translates MyBatis exceptions into Spring DataAccessExceptions, - and finally, it lets you build your application code free of - dependencies on MyBatis, Spring or MyBatis-Spring. -

    -
    - - -

    - Spring version 2 only supports iBATIS version 2. An attempt was made to - add MyBatis 3 support into Spring 3 (see the Spring Jira - issue). - Unfortunately, Spring 3 development ended before MyBatis 3 was - officially released. Because the Spring team did not want to release with - code based on a non-released version of MyBatis, official Spring support - would have to wait. Given the interest in Spring support for MyBatis, - the MyBatis community decided it was time to reunite the interested contributors - and add Spring integration as a community sub-project of MyBatis instead. -

    -
    - - -

    - Before starting with MyBatis-Spring integration, it is very important - that you are familiar with both MyBatis and Spring terminology. This - document does not attempt to provide background information or basic - setup and configuration tutorials for either MyBatis or Spring. -

    -

    - MyBatis-Spring requires following versions: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - MyBatis-Spring - - MyBatis - - Spring Framework - - Spring Batch - - Java -
    - 2.0 - - 3.5+ - - 5.0+ - - 4.0+ - - Java 8+ -
    - 1.3 - - 3.4+ - - 3.2.2+ - - 2.1+ - - Java 6+ -
    -
    - - -

    - A special thanks goes to all the special people who made this project - a reality (in alphabetical order): Eduardo Macarron, Hunter Presnall - and Putthiphong Boonphong for the coding, testing and documentation; - Andrius Juozapaitis, Giovanni Cuccu, Mike Lanyon, Raj Nagappan and Tomas Pinos - for their contributions; and Simone Tripodi for finding everyone and - bringing them all back to the project under MyBatis ;) Without them, - this project wouldn't exist. -

    -
    - - -

    - If you find this documentation lacking in any way, or missing - documentation for a feature, then the best thing to do is learn - about it and then write the documentation yourself! -

    -

    - Sources of this manual are available in xdoc format at - project's Git - Fork the repository, update them and send a pull request. -

    -

    - You’re the best author of this documentation, people like you have - to read it! -

    -
    - - -

    Users can read about MyBatis-Spring in the following translations:

    - -

    Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your - mother tongue documentation!

    -
    -
    - - -
    diff --git a/src/site/xdoc/mappers.xml b/src/site/xdoc/mappers.xml deleted file mode 100644 index 6287690314..0000000000 --- a/src/site/xdoc/mappers.xml +++ /dev/null @@ -1,295 +0,0 @@ - - - - - - MyBatis-Spring | Injecting Mappers - Hunter Presnall - Eduardo Macarron - - - -
    -

    - Rather than code data access objects (DAOs) manually using - SqlSessionDaoSupport or - SqlSessionTemplate, Mybatis-Spring can create a - thread safe mapper that you can inject directly into other beans: -

    - - - -]]> - -

    - Once injected, the mapper is ready to be used in application logic: -

    - -

    - Notice that there are no SqlSession or MyBatis - references in this code. Nor is there any need to create, open or close - the session, MyBatis-Spring will take care of that. -

    - - -

    - The way you register a mapper depends on whether you are using a classic XML configuration - or the new 3.0+ Java Config (a.k.a. @Configuration).

    - -

    With XML Config

    - -

    - A mapper is registered to Spring by including a MapperFactoryBean in your XML - config file like follows: -

    - - - -]]> - -

    - If the UserMapper has a corresponding MyBatis XML mapper file - in the same classpath location as the mapper interface, it will be - parsed automatically by the MapperFactoryBean. There - is no need to specify the mapper in a MyBatis configuration file unless - the mapper XML files are in a different classpath location. See the - SqlSessionFactoryBean's - configLocation - property for more information. -

    - -

    - Note that MapperFactoryBean requires either an - SqlSessionFactory or an SqlSessionTemplate. - These can be set through the respective sqlSessionFactory and - sqlSessionTemplate properties. - If both properties are set, the SqlSessionFactory is ignored. - Since the SqlSessionTemplate is required to have a session - factory set, that factory will be used by MapperFactoryBean. -

    - -

    With Java Config

    - - userMapper() throws Exception { - MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); - factoryBean.setSqlSessionFactory(sqlSessionFactory()); - return factoryBean; -}]]> -
    - - -

    - There is no need to register all your mappers one by one. - Instead, you can let MyBatis-Spring scan your classpath for them. -

    - -

    - There are three different ways to do it: -

    -
      -
    • Using the <mybatis:scan/> element.
    • -
    • Using the annotation @MapperScan
    • -
    • Using a classic Spring xml file and registering the MapperScannerConfigurer
    • -
    - -

    Both <mybatis:scan/> and @MapperScan are features introduced in MyBatis-Spring 1.2.0. - @MapperScan requires Spring 3.1+.

    - -

    - Since 2.0.2, mapper scanning feature support a option (lazy-initialization) - that control lazy initialization enabled/disabled of mapper bean. - The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. - The default of this option is false (= not use lazy initialization). - If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. -

    -

    - IMPORTANT If use the lazy initialization feature, - the developer need to understand following limitations. If any of following conditions are matches, - usually the lazy initialization feature cannot use on your application. -

    -
      -
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • -
    • When includes to the fragment of other mapper using ]]>
    • -
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • -
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • -
    - -

    - NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: -

    - - - -

    - Since 2.0.6, the develop become can specified scope of mapper using mapper scanning feature option(default-scope) - and scope annotation(@Scope, @RefreshScope, etc ...). - The motivation for adding this option is supporting the refresh scope provided by the Spring Cloud. - The default of this option is empty (= equiv to specify the singleton scope). - The default-scope apply to the mapper bean(MapperFactoryBean) when scope of scanned bean definition - is singleton(default scope) and create a scoped proxy bean for scanned mapper when final scope is not singleton. -

    - -

    <mybatis:scan/>

    - -

    - The <mybatis:scan/> XML element will search for mappers - in a very similar way than the Spring built-in element <context:component-scan/> - searches for beans. -

    - -

    Follows below a sample XML configuration:

    - - - - - - - -]]> - -

    - The base-package attribute lets you set the base package - for your mapper interface files. You can set more than one package by - using a semicolon or comma as a separator. Mappers will be searched for - recursively starting in the specified package(s). -

    - -

    - Notice that there is no need to specify a SqlSessionFactory or - SqlSessionTemplate as an attribute in the <mybatis:scan/> - element because it will create MapperFactoryBeans that can be autowired. - But if you are using more than one DataSource autowire may not work for you. - In this case you can use the factory-ref or - template-ref attributes to set the right bean name to use. -

    - -

    - <mybatis:scan/> supports filtering the mappers - created by either specifying a marker interface or an annotation. The - annotation property specifies an annotation to - search for. The marker-interface attribute specifies a - parent interface to search for. If both properties are specified, mappers - are added for interfaces that match either criteria. - By default, these two properties are null, so all interfaces in the given - base package(s) will be loaded as mappers. -

    - -

    - Discovered mappers will be named using Spring default naming strategy for - autodetected components (see the Spring reference document(Core Technologies -Naming autodetected components-)). - That is, if no annotation is found, it will use the uncapitalized non-qualified class - name of the mapper. But if either a @Component or a JSR-330 @Named annotation is - found it will get the name from the annotation. - Notice that you can set the annotation attribute - to org.springframework.stereotype.Component, - javax.inject.Named (if you have JSE 6) or to your own annotation - (that must be itself annotated) so the annotation will work both as a marker - and as a name provider. -

    - -

    - NOTE <context:component-scan/> - won't be able to scan and register mappers. Mappers are interfaces and, in order to register them to - Spring, the scanner must know how to create a MapperFactoryBean for each interface - it finds. -

    - -

    @MapperScan

    - -

    - If you are using the Spring Java Configuration (a.k.a @Configuration) you would - prefer to use the @MapperScan rather than the - <mybatis:scan/>. -

    - -

    The @MapperScan annotation is used as follows:

    - - - -

    The annotation works in the same exact way than <mybatis:scan/> we - saw in the previous section. It also lets you specify a marker interface or an annotation class - through its properties markerInterface and annotationClass. - You can also provide an specific SqlSessionFactory or SqlSessionTemplate - by using its properties sqlSessionFactory and sqlSessionTemplate. -

    - -

    - NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. -

    - -

    MapperScannerConfigurer

    - -

    - The MapperScannerConfigurer is a BeanDefinitionRegistryPostProcessor that - can be included in a classic xml application context as a normal bean. - To set up a MapperScannerConfigurer add the following to the Spring configuration: -

    - - -]]> - -

    - If you need to specify an specific sqlSessionFactory or sqlSessionTemplate - note that bean names are required, - not bean references, thus the value attribute is used instead of the - usual ref: -

    - ]]> - -

    - NOTE sqlSessionFactoryBean and - sqlSessionTemplateBean properties were the only option available up to MyBatis-Spring 1.0.2 - but given that the MapperScannerConfigurer runs earlier in the startup - process that PropertyPlaceholderConfigurer there were frequent errors. - For that purpose that properties have been deprecated and the new properties - sqlSessionFactoryBeanName and sqlSessionTemplateBeanName - are recommended. -

    -
    -
    - -
    diff --git a/src/site/xdoc/sample.xml b/src/site/xdoc/sample.xml deleted file mode 100644 index df1846ac85..0000000000 --- a/src/site/xdoc/sample.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - MyBatis-Spring | Sample Code - Eduardo Macarron - - - -
    - -

    - NOTE - See JPetstore 6 demo to know about how to use Spring with a full web application server. -

    - -

    - You can check out sample code from the MyBatis-Spring repo: -

    -

    - Any of the samples can be run with JUnit 5. -

    -

    - The sample code shows a typical design where a transactional service gets domain objects from a data access layer. -

    -

    - FooService.java acts as the service: -

    - -

    - It is a transactional bean, so when the method is called, the transaction is started - and the transaction is committed when the method ends without throwing an uncaught exception. - Notice that transactional behaviour is configured with the - @Transactional - attribute. This is not required; any other way provided by Spring can be used to demarcate - your transactions. -

    -

    - This service calls a data access layer built with MyBatis. This layer - consists on a just an interface UserMapper.java - that will be used with a dynamic proxy built by MyBatis at - runtime and injected into the service by Spring. -

    - -

    - Note that, for the sake of simplicity we used the interface UserMapper.java for the DAO scenario - where a DAO is built with an interface and a implementation though in this case it would have been more - adequate to use an interface called UserDao.java instead. -

    -

    - We will see different ways to find the mapper interface, register it to Spring and inject it into the service bean: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Scenarios
    Sample testDescription
    - SampleMapperTest.java - - Shows you the base configuration based on a MapperFactoryBean - that will dynamically build an implementation for UserMapper -
    - SampleScannerTest.java - - Shows how to use the MapperScannerConfigurer so all the mappers in a project are autodiscovered. -
    - SampleSqlSessionTest.java - - Shows how to hand code a DAO using a Spring managed SqlSession - and providing your own implementation UserDaoImpl.java. -
    - SampleEnableTest - - Shows how to use Spring's @Configuration with the @MapperScann annotation so - mappers are autodiscovered. -
    - SampleNamespaceTest - - Shows how to use the custom MyBatis XML namespace. -
    - SampleJavaConfigTest.java - - Shows how to use Spring's @Configuration to create MyBatis beans manually. -
    - SampleJobJavaConfigTest.java - - Shows how to use ItemReader and ItemWriter on Spring Batch using Java Configuration. -
    - SampleJobXmlConfigTest.java - - Shows how to use ItemReader and ItemWriter on Spring Batch using XML Configuration. -
    -

    - Please take a look at the different applicationContext.xml files to see MyBatis-Spring in action. -

    - -
    - -
    - diff --git a/src/site/xdoc/sqlsession.xml b/src/site/xdoc/sqlsession.xml deleted file mode 100644 index 3b36295554..0000000000 --- a/src/site/xdoc/sqlsession.xml +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - MyBatis-Spring | Using an SqlSession - Hunter Presnall - Eduardo Macarron - - - -
    -

    - In MyBatis you use the SqlSessionFactory to create an - SqlSession. Once you have a session, you use it to - execute your mapped statements, commit or rollback connections and - finally, when it is no longer needed, you close the session. With - MyBatis-Spring you don't need to use SqlSessionFactory - directly because your beans can be injected with a thread safe - SqlSession that automatically commits, rollbacks and - closes the session based on Spring's transaction configuration. -

    - - -

    - SqlSessionTemplate is the heart of MyBatis-Spring. - It implements SqlSession and is meant to be a drop-in replacement - for any existing use of SqlSession in your code. - SqlSessionTemplate is thread safe and can be shared - by multiple DAOs or mappers. -

    - -

    - When calling SQL methods, including any method from Mappers returned by - getMapper(), SqlSessionTemplate - will ensure that the SqlSession used is the one - associated with the current Spring transaction. In addition, it manages - the session life-cycle, including closing, committing or rolling back the - session as necessary. It will also translate MyBatis exceptions - into Spring DataAccessExceptions. -

    - -

    - SqlSessionTemplate should always - be used instead of default MyBatis implementation DefaultSqlSession - because the template can participate in Spring transactions and is thread safe for use by - multiple injected mapper classes. Switching between the two classes in the - same application can cause data integrity issues. -

    - -

    - A SqlSessionTemplate can be constructed - using an SqlSessionFactory as a constructor argument. -

    - - -]]> - - - -

    - This bean can now be injected directly in your DAO beans. You need a - SqlSession property in your bean like the following -

    - -

    - And inject the SqlSessionTemplate as follows -

    - - -]]> - -

    - SqlSessionTemplate has also a constructor that takes - an ExecutorType as an argument. This allows you to - construct, for example, a batch SqlSession by using - the following in Spring's configuration file: -

    - - - -]]> - - - -

    - Now all your statements will be batched so the following could be coded - in a DAO -

    - users) { - for (User user : users) { - sqlSession.insert("org.mybatis.spring.sample.mapper.UserMapper.insertUser", user); - } -}]]> - -

    - Note that this configuration style only needs to be used if the desired - execution method differs from the default set for the - SqlSessionFactory. -

    - -

    - The caveat to this form is that - there cannot be an existing transaction running with - a different ExecutorType when this method is called. Either ensure that - calls to SqlSessionTemplates with different executor - types run in a separate transaction (e.g. with PROPAGATION_REQUIRES_NEW) or - completely outside of a transaction. -

    -
    - - -

    - SqlSessionDaoSupport is an abstract support class that - provides you with a SqlSession. Calling - getSqlSession() you will get a SqlSessionTemplate - which can then be used to execute SQL methods, like the following: -

    - -

    - Usually MapperFactoryBean is preferred to this class, - since it requires no extra code. But, this class is useful if you need - to do other non-MyBatis work in your DAO and concrete classes are - required. -

    - -

    - SqlSessionDaoSupport requires either an - sqlSessionFactory or an sqlSessionTemplate - property to be set. - If both properties are set, the sqlSessionFactory is ignored. -

    - -

    - Assuming a class UserDaoImpl that subclasses - SqlSessionDaoSupport, it can be configured in Spring - like the following: -

    - - -]]> -
    -
    - -
    diff --git a/src/site/xdoc/transactions.xml b/src/site/xdoc/transactions.xml deleted file mode 100644 index 12f358f780..0000000000 --- a/src/site/xdoc/transactions.xml +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - MyBatis-Spring | Transactions - Hunter Presnall - Eduardo Macarron - - - -
    -

    - One of the primary reasons for using MyBatis-Spring is that it allows - MyBatis to participate in Spring transactions. Rather than create a new - transaction manager specific to MyBatis, MyBatis-Spring leverages the - existing DataSourceTransactionManager in Spring. -

    -

    - Once a Spring transaction manager is configured, you can configure - transactions in Spring as you normally would. Both - @Transactional annotations and AOP style - configurations are supported. A single SqlSession - object will be created and used for the duration of the transaction. This - session will be committed or rolled back as appropriate when then - transaction completes. -

    -

    - MyBatis-Spring will transparently manage transactions once they are set up. - There is no need for additional code in your DAO classes. -

    - - -

    - To enable Spring transaction processing, simply create a - DataSourceTransactionManager in your Spring - configuration file: -

    - - - -]]> - - - -

    - The DataSource specified can be any JDBC - DataSource you would normally - use with Spring. This includes connection pools as well as DataSources - obtained through JNDI lookups. -

    -

    - Note that the DataSource specified for the transaction - manager must be the same one that is used to create - the SqlSessionFactoryBean or transaction management will - not work. -

    -
    - - -

    - If you are using a JEE container and would like Spring to participate in - container managed transactions (CMT), then Spring should be configured - with a JtaTransactionManager or one of its container - specific subclasses. The easiest way to do this is to use the Spring - transaction namespace or the JtaTransactionManagerFactoryBean: -

    - ]]> - - - -

    - In this configuration, MyBatis will behave like any other Spring - transactional resource configured with CMT. Spring will automatically use - any existing container transaction and attach an SqlSession to it. If no - transaction is started and one is needed based on the transaction - configuration, Spring will start a new container managed transaction. -

    -

    - Note that if you want to use CMT and do not want to - use Spring transaction management, you must not - configure any Spring transaction manager and you must - also configure the SqlSessionFactoryBean to use the base - MyBatis ManagedTransactionFactory: -

    - - - - - -]]> - - -
    - - -

    - MyBatis SqlSession provides you with specific methods to handle - transactions programmatically. But when using MyBatis-Spring your beans will be - injected with a Spring managed SqlSession or a Spring managed mapper. - That means that Spring will always handle your transactions. -

    -

    - You cannot call SqlSession.commit(), SqlSession.rollback() - or SqlSession.close() over a Spring managed SqlSession. - If you try to do so, a UnsupportedOperationException exception - will be thrown. Note these methods are not exposed in injected mapper classes. -

    -

    - Regardless of your JDBC connection's autocommit setting, any execution of a - SqlSession data method or any call to a mapper - method outside a Spring transaction will be automatically committed. -

    -

    - If you want to control your transactions programmatically please refer to - the Spring reference document(Data Access -Programmatic transaction management-). - This code shows how to handle a transaction manually using the PlatformTransactionManager. -

    - - -

    - You can omit to call the commit and rollback method using the TransactionTemplate. -

    - - { - userMapper.insertUser(user); - return null; -});]]> - -

    - Notice that this code uses a mapper, but it will also work with a SqlSession. -

    -
    -
    - -
    diff --git a/src/site/xdoc/using-api.xml b/src/site/xdoc/using-api.xml deleted file mode 100644 index d56943590d..0000000000 --- a/src/site/xdoc/using-api.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - MyBatis-Spring | Using the MyBatis API - Hunter Presnall - Eduardo Macarron - - - -
    -

    - With MyBatis-Spring, you can continue to directly use the MyBatis API. - Simply create an SqlSessionFactory in Spring using - SqlSessionFactoryBean and use the factory in your code. -

    - - -

    - Use this option with care because wrong usage may produce runtime errors or - worse, data integrity problems. Be aware of the following caveats with direct API usage: -

    -
      -
    • -

      - It will not participate in any Spring transactions. -

      -
    • -
    • -

      - If the SqlSession is using a DataSource - that is also being used by a Spring transaction manager and there is currently - a transaction in progress, this code will throw an exception. -

      -
    • -
    • -

      - MyBatis' DefaultSqlSession is not thread safe. If you - inject it in your beans you will get errors. -

      -
    • -
    • -

      - Mappers created using DefaultSqlSession are not thread safe either. - If you inject them it in your beans you will get errors. -

      -
    • -
    • -

      - You must make sure that your SqlSessions - are always closed in a finally block. -

      -
    • -
    -
    - -
    diff --git a/src/site/zh/markdown/README.md b/src/site/zh/markdown/README.md new file mode 100644 index 0000000000..823195bba3 --- /dev/null +++ b/src/site/zh/markdown/README.md @@ -0,0 +1,18 @@ +# 目录 + +此页面用于在GitHub上呈现索引。 + +> **NOTE:** +> +> 由于链接目标是在使用maven-site-plugin转换为html的假设下指定的,因此在GitHub上的呈现中有一个锚点已损坏。 + +* [简介](./index.md) +* [入门](./getting-started.md) +* [SqlSessionFactoryBean](./factorybean.md) +* [事务](./transactions.md) +* [使用 SqlSession](./sqlsession.md) +* [注入映射器](./mappers.md) +* [Spring Boot](./boot.md) +* [使用 MyBatis API](./using-api.md) +* [Spring Batch](./batch.md) +* [示例代码](./sample.md) diff --git a/src/site/zh/markdown/batch.md b/src/site/zh/markdown/batch.md new file mode 100644 index 0000000000..891ed531cb --- /dev/null +++ b/src/site/zh/markdown/batch.md @@ -0,0 +1,343 @@ + +# 使用 Spring Batch + +MyBatis-Spring 1.1.0 发布以后,提供了三个 bean 以供构建 Spring Batch 应用程序:`MyBatisPagingItemReader`、`MyBatisCursorItemReader` 和 `MyBatisBatchItemWriter`。 +而在 2.0.0 中,还提供了三个建造器(builder)类来对 Java 配置提供支持:`MyBatisPagingItemReaderBuilder`、`MyBatisCursorItemReaderBuilder` 和 `MyBatisBatchItemWriterBuilder`。 + +提示 +本章是关于 [Spring Batch](http://static.springsource.org/spring-batch/) 的,而不是关于 MyBatis 的批量 `SqlSession`。要查找关于批量 session 的更多信息,请参考 [使用 SqlSession](sqlsession.html) 一章。 + +## MyBatisPagingItemReader + +这个 bean 是一个 `ItemReader`,能够从数据库中分页地读取记录。 + +它执行 `setQueryId` 属性指定的查询来获取请求的数据。这个查询使用 `setPageSize` 属性指定了分页请求的大小,并被执行。其它的页面将在必要时被请求(例如调用 `read()` 方法时),返回对应位置上的对象。 + +reader 还提供了一些标准的请求参数。在命名查询的 SQL 中,必须使用部分或全部的参数(视乎 SQL 方言而定)来构造指定大小的结果集。这些参数是: + +* `_page`: 欲读取的页码(从 0 开始) +* `_pagesize`: 每一页的大小,也就是返回的行数 +* `_skiprows`: `_page` 和 `_pagesize` 的乘积 + +它们可以被映射成如下的 select 语句: + +```xml + +``` + +配合如下的配置样例: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisPagingItemReader reader() { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +**让我们通过一个更复杂一点的例子来阐明一切:** + +```xml + +``` +```xml + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @StepScope + @Bean + public MyBatisPagingItemReader dateBasedCriteriaReader( + @Value("#{@datesParameters}") Map datesParameters) throws Exception { + return new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(batchReadingSessionFactory()) + .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") + .parameterValues(datesParameters) + .pageSize(200) + .build(); + } + + @StepScope + @Bean + public Map datesParameters( + @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, + @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, + @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { + Map map = new HashMap<>(); + map.put("yesterday", yesterday); + map.put("today", today); + map.put("first_day_of_the_month", firstDayOfTheMonth); + map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); + return map; + } +} +``` + +上面的样例使用了几个东西: + +* `sqlSessionFactory:可以为 reader 指定你自定义的 sessionFactory,当你想从多个数据库中读取数据时尤其有用 +* `queryId`:指定在检索记录时要执行的查询的 ID,可以指定短的 ID 或是带命名空间的完整 ID。一般来说,你的应用可能从多个表或数据库中读取数据,因此会配置多个查询,可能会使用到在不同命名空间中的不同映射器。因此最好提供映射器文件的命名空间以便准确指定你想使用的查询 ID。 +* `parameterValues`:可以通过这个 map 传递多个附加的参数,上面的例子中就使用了一个由 Spring 构建的 map,并使用 SpEL 表达式从 `jobExecutionContext` 中获取信息。 + 而 map 的键将在映射器文件中被 MyBatis 使用(例如:*yesterday* 可以通过 `#{yesterday,jdbcType=TIMESTAMP}` 来读取)。注意,map 和 reader 都构建于 `step` 作用域,这样才能够在 Spring 表达式语言中使用 `jobExecutionContext`。 + 另外,如果正确配置了 MyBatis 的类型处理器,你可以将自定义的实例像参数那样传递到 map 中,比如将参数类型换成 JodaTime。 +* `pageSize`:如果批处理流配置了块大小(chunk size),需要通过此属性将块大小告知 reader。 + +## MyBatisCursorItemReader + +这个 bean 是一个 `ItemReader` ,能够通过游标从数据库中读取记录。 + +提示 +为了使用这个 bean,你需要使用 MyBatis 3.4.0 或更新的版本。 + +它执行 `setQueryId` 属性指定的查询来获取请求的数据(通过 `selectCursor()`方法)。每次调用 `read()` 方法时,将会返回游标指向的下个元素,直到没有剩余的元素了。 + +这个 reader 将会使用一个单独的数据库连接,因此 select 语句将不会参与到 step 处理中创建的任何事务。 + +当使用游标时,只需要执行普通的查询: + +```xml + +``` + +搭配以下的配置样例: + +```xml + + + + +``` +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisCursorItemReader reader() { + return new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") + .build(); + } +} +``` + +## MyBatisBatchItemWriter + +这是一个 `ItemWriter`,通过利用 `SqlSessionTemplate` 中的批量处理功能来对给定的所有记录执行多个语句。`SqlSessionFactory` 需要被配置为 `BATCH` 执行类型。 + +当调用 `write()` 时,将会执行 `statementId` 属性中指定的映射语句。一般情况下,`write()` 应该在一个事务中进行调用。 + +下面是一个配置样例: + +```xml + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") + .build(); + } +} +``` + +**将 ItemReader 读取的记录转换为任意的参数对象:** + +默认情况下,`MyBatisBatchItemWriter` 会将 `ItemReader` 读取的对象(或 `ItemProcessor` 转换过的对象) 以参数对象的形式传递给 MyBatis(`SqlSession#update()`)。 +如果你想自定义传递给 MyBatis 的参数对象,可以使用 `itemToParameterConverter` 选项。使用该选项后,可以传递任意对象给 MyBatis。 +举个例子: + +首先,创建一个自定义的转换器类(或工厂方法)。以下例子使用了工厂方法。 + +```java +public class ItemToParameterMapConverters { + public static Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { + return item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("operationBy", operationBy); + parameter.put("operationAt", operationAt); + return parameter; + }; + } +} +``` + +接下来,编写 SQL 映射。 + +```xml + +``` + +最后,配置 `MyBatisBatchItemWriter`。 + +```java +@Configuration +public class BatchAppConfig { + @Bean + public MyBatisBatchItemWriter writer() throws Exception { + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory()) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); + } +} +``` + +```xml + + + + + + + + + + +``` + +**使用复合 writer 对多个表进行写入(但带有问题):** + +这个小技巧只能在 MyBatis 3.2+ 以上的版本中使用,因为之前的版本中含有导致 writer 行为不正确的 [问题](http://code.google.com/p/mybatis/issues/detail?id=741)。 + +如果批量处理时需要写入复杂的数据,例如含有关联的记录,甚至是向多个数据库写入数据,你可能就需要一种办法来绕开 insert 语句只能插入到一个表中的限制。为了绕过此限制,批处理必须准备好要通过 writer 写入的*项*。 +然而,基于对被处理的数据的观察,可以尝试使用下面的方法来解决此问题。下面的方法能够工作于具有简单关联或不相关的多个表的项。 + +在这种方法中,处理 Spring Batch 项的处理器中将会*持有*各种不同的记录。假设每个项都有一个与 *InteractionMetadata* 相关联的 *Interaction*,并且还有两个不相关的行 *VisitorInteraction* 和 *CustomerInteraction*,这时候持有器(holder)看起来像这样: + +```java +public class InteractionRecordToWriteInMultipleTables { + private final VisitorInteraction visitorInteraction; + private final CustomerInteraction customerInteraction; + private final Interaction interaction; + // ... +} +``` +```java +public class Interaction { + private final InteractionMetadata interactionMetadata; +} +``` + +在 Spring 配置中要配置一个 `CompositeItemWriter`,它将会将写入操作委托到特定种类的 writer 上面去。注意 *InteractionMetadata* 在例子里面是一个关联,它需要首先被写入,这样 Interaction 才能获得更新之后的键。 + +```xml + + + + + + + + + + + + +``` + +```java +@Configuration +public class BatchAppConfig { + @Bean + public CompositeItemWriter interactionsItemWriter() { + CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); + List> writers = new ArrayList<>(4); + writers.add(visitorInteractionsWriter()); + writers.add(customerInteractionsWriter()); + writers.add(interactionMetadataWriter()); + writers.add(interactionWriter()); + compositeItemWriter.setDelegates(writers); + return compositeItemWriter; + } +} +``` + +接下来需要配置每一个被委托的 writer;例如 *Interaction* 和 *InteractionMetadata* 对应的 writer。 + +```xml + +``` +```xml + +``` + +和 reader 中的一样,通过 `statementId` 属性指定对应命名空间前缀的查询。 + +而在映射器配置文件中,应该根据每种特定的记录编写特定的语句,如下所示: + +```xml + + + +``` +```xml + + + +``` + +执行的时候会怎么样呢?首先,`insertInteractionMetadata` 将会被调用,update 语句被设置为返回由 JDBC 驱动返回的主键(参考 `keyProperty` 和 `keyColumn`)。 +由于 `InteractionMetadata` 的对象被此查询更新了,下一个查询将可以通过 `insertInteraction` 开展父对象 `Interaction` 的写入工作。 + +***然而要注意,JDBC 驱动在这方面的行为并不总是与此相一致。在编写文档时,H2 的数据库驱动 1.3.168 甚至只在 BATCH 模式下返回最后的索引值(参考 `org.h2.jdbc.JdbcStatement#getGeneratedKeys`), +而 MySQL 的 JDBC 驱动则工作良好并返回所有 ID。*** diff --git a/src/site/zh/markdown/boot.md b/src/site/zh/markdown/boot.md new file mode 100644 index 0000000000..187cd06688 --- /dev/null +++ b/src/site/zh/markdown/boot.md @@ -0,0 +1,4 @@ + +# 搭配 Spring Boot + +请查看 [MyBatis Spring-boot-starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure) 子项目获取更多信息。 diff --git a/src/site/zh/markdown/factorybean.md b/src/site/zh/markdown/factorybean.md new file mode 100644 index 0000000000..80dd1f51d4 --- /dev/null +++ b/src/site/zh/markdown/factorybean.md @@ -0,0 +1,94 @@ + +# SqlSessionFactoryBean + +在基础的 MyBatis 用法中,是通过 `SqlSessionFactoryBuilder` 来创建 `SqlSessionFactory` 的。而在 MyBatis-Spring 中,则使用 `SqlSessionFactoryBean` 来创建。 + +## 设置 + +要创建工厂 bean,将下面的代码放到 Spring 的 XML 配置文件中: + +```xml + + + +``` + +需要注意的是 `SqlSessionFactoryBean` 实现了 Spring 的 `FactoryBean` 接口(参见 Spring 官方文档 3.8 节 [通过工厂 bean 自定义实例化逻辑](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-extension-factorybean) )。 +这意味着由 Spring 最终创建的 bean **并不是** `SqlSessionFactoryBean` 本身,而是工厂类(`SqlSessionFactoryBean`)的 getObject() 方法的返回结果。这种情况下,Spring 将会在应用启动时为你创建 `SqlSessionFactory`,并使用 `sqlSessionFactory` 这个名字存储起来。 + +等效的 Java 代码如下: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +通常,在 MyBatis-Spring 中,你不需要直接使用 `SqlSessionFactoryBean` 或对应的 `SqlSessionFactory`。 +相反,session 的工厂 bean 将会被注入到 `MapperFactoryBean` 或其它继承于 `SqlSessionDaoSupport` 的 DAO(Data Access Object,数据访问对象)中。 + +## 属性 + +`SqlSessionFactory` 有一个唯一的必要属性:用于 JDBC 的 `DataSource`。这可以是任意的 `DataSource` 对象,它的配置方法和其它 Spring 数据库连接是一样的。 + +一个常用的属性是 `configLocation`,它用来指定 MyBatis 的 XML 配置文件路径。它在需要修改 MyBatis 的基础配置非常有用。通常,基础配置指的是 `` 或 `` 元素。 + +需要注意的是,这个配置文件并不需要是一个完整的 MyBatis 配置。确切地说,任何环境配置(``),数据源(``)和 MyBatis 的事务管理器(``)都会被**忽略**。 +`SqlSessionFactoryBean` 会创建它自有的 MyBatis 环境配置(`Environment`),并按要求设置自定义环境的值。 + +如果 MyBatis 在映射器类对应的路径下找不到与之相对应的映射器 XML 文件,那么也需要配置文件。这时有两种解决办法:第一种是手动在 MyBatis 的 XML 配置文件中的 `` 部分中指定 XML 文件的类路径;第二种是设置工厂 bean 的 `mapperLocations` 属性。 + +`mapperLocations` 属性接受多个资源位置。这个属性可以用来指定 MyBatis 的映射器 XML 配置文件的位置。属性的值是一个 Ant 风格的字符串,可以指定加载一个目录中的所有文件,或者从一个目录开始递归搜索所有目录。比如: + +```xml + + + + +``` + +这会从类路径下加载所有在 `sample.config.mappers` 包和它的子包中的 MyBatis 映射器 XML 配置文件。 + +在容器管理事务的时候,你可能需要的一个属性是 `transactionFactoryClass`。请参考事务一章的相关章节。 + +如果你使用了多个数据库,那么需要设置 `databaseIdProvider` 属性: + +```xml + + + + sqlserver + db2 + oracle + mysql + + + +``` +```xml + + + + + +``` + +提示 +自 1.3.0 版本开始,新增的 `configuration` 属性能够在没有对应的 MyBatis XML 配置文件的情况下,直接设置 `Configuration` 实例。例如: + +```xml + + + + + + + + +``` diff --git a/src/site/zh/markdown/getting-started.md b/src/site/zh/markdown/getting-started.md new file mode 100644 index 0000000000..69b7b84e40 --- /dev/null +++ b/src/site/zh/markdown/getting-started.md @@ -0,0 +1,97 @@ + +# 入门 + +本章将会以简略的步骤告诉你如何安装和配置 MyBatis-Spring,并构建一个简单的具备事务管理功能的数据访问应用程序。 + +## 安装 + +要使用 MyBatis-Spring 模块,只需要在类路径下包含 `mybatis-spring-${project.version}.jar` 文件和相关依赖即可。 + +如果使用 Maven 作为构建工具,仅需要在 pom.xml 中加入以下代码即可: + +```xml + + org.mybatis + mybatis-spring + ${project.version} + +``` + +## 快速上手 + +要和 Spring 一起使用 MyBatis,需要在 Spring 应用上下文中定义至少两样东西:一个 `SqlSessionFactory` 和至少一个数据映射器类。 + +在 MyBatis-Spring 中,可使用 `SqlSessionFactoryBean`来创建 `SqlSessionFactory`。 要配置这个工厂 bean,只需要把下面代码放在 Spring 的 XML 配置文件中: + +```xml + + + +``` + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory sqlSessionFactory() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(dataSource()); + return factoryBean.getObject(); + } +} +``` + +注意:`SqlSessionFactory` 需要一个 `DataSource`(数据源)。这可以是任意的 `DataSource`,只需要和配置其它 Spring 数据库连接一样配置它就可以了。 + +假设你定义了一个如下的 mapper 接口: + +```java +public interface UserMapper { + @Select("SELECT * FROM users WHERE id = #{userId}") + User getUser(@Param("userId") String userId); +} +``` + +那么可以通过 `MapperFactoryBean` 将接口加入到 Spring 中: + +```xml + + + + +``` + +需要注意的是:所指定的映射器类必须是一个接口,而不是具体的实现类。在这个示例中,通过注解来指定 SQL 语句,但是也可以使用 MyBatis 映射器的 XML 配置文件。 + +配置好之后,你就可以像 Spring 中普通的 bean 注入方法那样,将映射器注入到你的业务或服务对象中。`MapperFactoryBean` 将会负责 `SqlSession` 的创建和关闭。 +如果使用了 Spring 的事务功能,那么当事务完成时,session 将会被提交或回滚。最终任何异常都会被转换成 Spring 的 `DataAccessException` 异常。 + +使用 Java 代码来配置的方式如下: + +```java +@Configuration +public class MyBatisConfig { + @Bean + public UserMapper userMapper() throws Exception { + SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); + return sqlSessionTemplate.getMapper(UserMapper.class); + } +} +``` + +要调用 MyBatis 的数据方法,只需一行代码: + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` diff --git a/src/site/zh/markdown/index.md b/src/site/zh/markdown/index.md new file mode 100644 index 0000000000..74bc896278 --- /dev/null +++ b/src/site/zh/markdown/index.md @@ -0,0 +1,51 @@ + +# 简介 + +## 什么是 MyBatis-Spring? + +MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中。它将允许 MyBatis 参与到 Spring 的事务管理之中,创建映射器 mapper 和 `SqlSession` 并注入到 bean 中,以及将 Mybatis 的异常转换为 Spring 的 `DataAccessException`。 +最终,可以做到应用代码不依赖于 MyBatis,Spring 或 MyBatis-Spring。 + +## 动机 + +Spring 2.0 只支持 iBatis 2.0。那么,我们就想将 MyBatis3 的支持添加到 Spring 3.0 中(参见 Spring Jira 中的 [问题](https://jira.springsource.org/browse/SPR-5991) )。不幸的是,Spring 3.0 的开发在 MyBatis 3.0 官方发布前就结束了。 +由于 Spring 开发团队不想发布一个基于未发布版的 MyBatis 的整合支持,如果要获得 Spring 官方的支持,只能等待下一次的发布了。基于在 Spring 中对 MyBatis 提供支持的兴趣,MyBatis 社区认为,应该开始召集有兴趣参与其中的贡献者们,将对 Spring 的集成作为 MyBatis 的一个社区子项目。 + +## 知识基础 + +在开始使用 MyBatis-Spring 之前,你需要先熟悉 Spring 和 MyBatis 这两个框架和有关它们的术语。这很重要——因为本手册中不会提供二者的基本内容,安装和配置教程。 + +MyBatis-Spring 需要以下版本: + +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +| --- | --- | --- | --- | --- | +| **2.0** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | + +## 致谢 + +特别感谢那些使本项目变为现实的人们(按字母顺序排序): Eduardo Macarron, Hunter Presnall 和 Putthiphong Boonphong 负责本项目的代码实现,测试和编写文档工作; +Andrius Juozapaitis, Giovanni Cuccu, Raj Nagappan 和 Tomas Pinos 的贡献; +而 Simone Tripodi 发现了这些人并邀请他们参与到这一个 MyBatis 子项目之中。没有他们的努力,这个项目只能沦为空谈。 + +## 帮助改进文档... + +如果你发现文档有任何的缺失,或者缺少某一个功能点的说明,最好的解决办法是先自己学习,并且为缺失的部份补上相应的文档。 + +手册的 markdown 出自 [项目的 Git 仓库](https://github.com/mybatis/spring/tree/master/src/site) 。Fork 仓库,更新它并提交 Pull Request 吧。 + +还有其它像你一样的人都需要阅读这份文档,而你,就是这份文档最好的作者。 + +## 文档的翻译版本 + +可以阅读以下 MyBatis-Spring 文档的翻译版本: + + + +想用自己的母语阅读这篇文档吗?那就用你的母语翻译它吧! diff --git a/src/site/zh/markdown/mappers.md b/src/site/zh/markdown/mappers.md new file mode 100644 index 0000000000..2be7d90375 --- /dev/null +++ b/src/site/zh/markdown/mappers.md @@ -0,0 +1,183 @@ + +# 注入映射器 + +与其在数据访问对象(DAO)中手工编写使用 `SqlSessionDaoSupport` 或 `SqlSessionTemplate` 的代码,还不如让 Mybatis-Spring 为你创建一个线程安全的映射器,这样你就可以直接注入到其它的 bean 中了: + +```xml + + + +``` + +注入完毕后,映射器就可以在你的应用逻辑代码中使用了: + +```java +public class FooServiceImpl implements FooService { + + private final UserMapper userMapper; + + public FooServiceImpl(UserMapper userMapper) { + this.userMapper = userMapper; + } + + public User doSomeBusinessStuff(String userId) { + return this.userMapper.getUser(userId); + } +} +``` + +注意代码中并没有任何的对 `SqlSession` 或 MyBatis 的引用。你也不需要担心创建、打开、关闭 session,MyBatis-Spring 将为你打理好一切。 + + +## 注册映射器 + +注册映射器的方法根据你的配置方法,即经典的 XML 配置或新的 3.0 以上版本的 Java 配置(也就是常说的 `@Configuration`),而有所不同。 + +### XML 配置 + +在你的 XML 中加入 `MapperFactoryBean` 以便将映射器注册到 Spring 中。就像下面一样: + +```xml + + + + +``` + +如果映射器接口 UserMapper 在相同的类路径下有对应的 MyBatis XML 映射器配置文件,将会被 `MapperFactoryBean` 自动解析。不需要在 MyBatis 配置文件中显式配置映射器,除非映射器配置文件与接口类不在同一个类路径下。 +参考 `SqlSessionFactoryBean` 的 [`configLocation`](factorybean.html) 属性以获取更多信息。 + +注意 `MapperFactoryBean` 需要配置一个 `SqlSessionFactory` 或 `SqlSessionTemplate`。它们可以分别通过 `sqlSessionFactory` 和 `sqlSessionTemplate` 属性来进行设置。 +如果两者都被设置,`SqlSessionFactory` 将被忽略。由于 `SqlSessionTemplate` 已经设置了一个 session 工厂,`MapperFactoryBean` 将使用那个工厂。 + +### Java 配置 + +```java +@Configuration +public class MyBatisConfig { + @Bean + public MapperFactoryBean userMapper() throws Exception { + MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); + factoryBean.setSqlSessionFactory(sqlSessionFactory()); + return factoryBean; + } +} +``` + + +## 发现映射器 + +不需要一个个地注册你的所有映射器。你可以让 MyBatis-Spring 对类路径进行扫描来发现它们。 + + +有几种办法来发现映射器: + +* 使用 `` 元素 +* 使用 `@MapperScan` 注解 +* 在经典 Spring XML 配置文件中注册一个 `MapperScannerConfigurer` + +`` 和 `@MapperScan` 都在 MyBatis-Spring 1.2.0 中被引入。`@MapperScan` 需要你使用 Spring 3.1+。 + +Since 2.0.2, mapper scanning feature support a option (`lazy-initialization`) that control lazy initialization enabled/disabled of mapper bean. +The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. The default of this option is `false` (= not use lazy initialization). +If developer want to use lazy initialization for mapper bean, it should be set to the `true` expressly. + +IMPORTANT +If use the lazy initialization feature, the developer need to understand following limitations. +If any of following conditions are matches, usually the lazy initialization feature cannot use on your application. + +* When refers to the statement of **other mapper** using ``(`@One`) and ``(`@Many`) +* When includes to the fragment of **other mapper** using `` +* When refers to the cache of **other mapper** using ``(`@CacheNamespaceRef`) +* When refers to the result mapping of **other mapper** using `]]> - -

    配合如下的配置样例:

    - - - - -
    ]]> - - reader() { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - -

    让我们通过一个更复杂一点的例子来阐明一切:

    - - - - - - - - -]]> - - dateBasedCriteriaReader( - @Value("#{@datesParameters}") Map datesParameters) throws Exception { - return new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(batchReadingSessionFactory()) - .queryId("com.my.name.space.batch.ExampleMapper.queryUserInteractionsOnSpecificTimeSlot") - .parameterValues(datesParameters) - .pageSize(200) - .build(); -} - -@StepScope -@Bean -public Map datesParameters( - @Value("#{jobExecutionContext['EXTRACTION_START_DATE']}") LocalDate yesterday, - @Value("#{jobExecutionContext['TODAY_DATE']}") LocalDate today, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_MONTH_DATE']}") LocalDate firstDayOfTheMonth, - @Value("#{jobExecutionContext['FIRST_DAY_OF_THE_PREVIOUS_MONTH_DATE']}") LocalDate firstDayOfThePreviousMonth) { - Map map = new HashMap<>(); - map.put("yesterday", yesterday); - map.put("today", today); - map.put("first_day_of_the_month", firstDayOfTheMonth); - map.put("first_day_of_the_previous_month", firstDayOfThePreviousMonth); - return map; -}]]> - -

    - 上面的样例使用了几个东西: -

    - -
      -
    • sqlSessionFactory:可以为 reader 指定你自定义的 sessionFactory,当你想从多个数据库中读取数据时尤其有用
    • -
    • queryId:指定在检索记录时要执行的查询的 ID,可以指定短的 ID 或是带命名空间的完整 ID。一般来说,你的应用可能从多个表或数据库中读取数据,因此会配置多个查询,可能会使用到在不同命名空间中的不同映射器。因此最好提供映射器文件的命名空间以便准确指定你想使用的查询 ID。
    • -
    • parameterValues:可以通过这个 map 传递多个附加的参数,上面的例子中就使用了一个由 Spring 构建的 map,并使用 SpEL 表达式从 jobExecutionContext 中获取信息。而 map 的键将在映射器文件中被 MyBatis 使用(例如:yesterday 可以通过 #{yesterday,jdbcType=TIMESTAMP} 来读取)。注意,map 和 reader 都构建于 step 作用域,这样才能够在 Spring 表达式语言中使用 jobExecutionContext。另外,如果正确配置了 MyBatis 的类型处理器,你可以将自定义的实例像参数那样传递到 map 中,比如将参数类型换成 JodaTime。
    • -
    • pageSize:如果批处理流配置了块大小(chunk size),需要通过此属性将块大小告知 reader。
    • -
    - - - - -

    - 这个 bean 是一个 ItemReader ,能够通过游标从数据库中读取记录。 -

    - -

    - 提示 为了使用这个 bean,你需要使用 MyBatis 3.4.0 或更新的版本。 -

    - -

    - 它执行 setQueryId 属性指定的查询来获取请求的数据(通过 selectCursor()方法)。每次调用 read() 方法时,将会返回游标指向的下个元素,直到没有剩余的元素了。 -

    - -

    - 这个 reader 将会使用一个单独的数据库连接,因此 select 语句将不会参与到 step 处理中创建的任何事务。 -

    - -

    当使用游标时,只需要执行普通的查询:

    - - SELECT id, name, job FROM employees ORDER BY id ASC -]]> - -

    搭配以下的配置样例:

    - - - - -
    ]]> - - reader() { - return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .queryId("com.my.name.space.batch.EmployeeMapper.getEmployee") - .build(); -}]]> - - - - - -

    - 这是一个 ItemWriter,通过利用 SqlSessionTemplate - 中的批量处理功能来对给定的所有记录执行多个语句。SqlSessionFactory - 需要被配置为 BATCH 执行类型。 -

    - -

    - 当调用 write() 时,将会执行 statementId - 属性中指定的映射语句。一般情况下,write() - 应该在一个事务中进行调用。
    -

    - -

    下面是一个配置样例:

    - - - - -
    ]]> - - writer() { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("com.my.name.space.batch.EmployeeMapper.updateEmployee") - .build(); -}]]> - - -

    将 ItemReader 读取的记录转换为任意的参数对象:

    - -

    - 默认情况下,MyBatisBatchItemWriter 会将 ItemReader - 读取的对象(或 ItemProcessor 转换过的对象) 以参数对象的形式传递给 - MyBatis(SqlSession#update())。 - 如果你想自定义传递给 MyBatis 的参数对象,可以使用 itemToParameterConverter 选项。 - 使用该选项后,可以传递任意对象给 MyBatis。 - 举个例子: -

    - -

    - 首先,创建一个自定义的转换器类(或工厂方法)。以下例子使用了工厂方法。 -

    - - Converter> createItemToParameterMapConverter(String operationBy, LocalDateTime operationAt) { - return item -> { - Map parameter = new HashMap<>(); - parameter.put("item", item); - parameter.put("operationBy", operationBy); - parameter.put("operationAt", operationAt); - return parameter; - }; -}]]> - -

    - 接下来,编写 SQL 映射。 -

    - - - insert into persons (first_name, last_name, operation_by, operation_at) - values(#{item.firstName}, #{item.lastName}, #{operationBy}, #{operationAt}) -]]> - -

    - 最后,配置 MyBatisBatchItemWriter。 -

    - - writer() throws Exception { - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) - .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") - .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) - .build(); -}]]> - - - - - - - - - - - - -]]> - - -

    使用复合 writer 对多个表进行写入(但带有问题):

    - -

    - 这个小技巧只能在 MyBatis 3.2+ 以上的版本中使用,因为之前的版本中含有导致 writer 行为不正确的问题。 -

    - -

    - 如果批量处理时需要写入复杂的数据,例如含有关联的记录,甚至是向多个数据库写入数据,你可能就需要一种办法来绕开 insert 语句只能插入到一个表中的限制。为了绕过此限制,批处理必须准备好要通过 writer 写入的。然而,基于对被处理的数据的观察,可以尝试使用下面的方法来解决此问题。下面的方法能够工作于具有简单关联或不相关的多个表的项。 -

    - -

    - 在这种方法中,处理 Spring Batch 项的处理器中将会持有各种不同的记录。假设每个项都有一个与 InteractionMetadata 相关联的 Interaction,并且还有两个不相关的行 VisitorInteraction 和 - CustomerInteraction,这时候持有器(holder)看起来像这样: -

    - - - -

    - 在 Spring 配置中要配置一个 CompositeItemWriter,它将会将写入操作委托到特定种类的 writer 上面去。注意 InteractionMetadata 在例子里面是一个关联,它需要首先被写入,这样 Interaction 才能获得更新之后的键。 -

    - - - - - - - - - - - - -
    ]]> - - interactionsItemWriter() { - CompositeItemWriter compositeItemWriter = new CompositeItemWriter(); - List> writers = new ArrayList<>(4); - writers.add(visitorInteractionsWriter()); - writers.add(customerInteractionsWriter()); - writers.add(interactionMetadataWriter()); - writers.add(interactionWriter()); - compositeItemWriter.setDelegates(writers); - return compositeItemWriter; -}]]> - -

    - 接下来需要配置每一个被委托的 writer;例如 InteractionInteractionMetadata 对应的 writer。 -

    - - -]]> - -

    和 reader 中的一样,通过 statementId 属性指定对应命名空间前缀的查询。

    - -

    而在映射器配置文件中,应该根据每种特定的记录编写特定的语句,如下所示:

    - - - - - - -]]> - -

    - 执行的时候会怎么样呢?首先,insertInteractionMetadata 将会被调用,update 语句被设置为返回由 JDBC 驱动返回的主键(参考 keyPropertykeyColumn)。由于 InteractionMetadata 的对象被此查询更新了,下一个查询将可以通过 insertInteraction 开展父对象 Interaction 的写入工作。 -

    - -

    - 然而要注意,JDBC 驱动在这方面的行为并不总是与此相一致。在编写文档时,H2 的数据库驱动 1.3.168 甚至只在 BATCH 模式下返回最后的索引值(参考 org.h2.jdbc.JdbcStatement#getGeneratedKeys),而 MySQL 的 JDBC 驱动则工作良好并返回所有 ID。 - -

    - - - - diff --git a/src/site/zh/xdoc/boot.xml b/src/site/zh/xdoc/boot.xml deleted file mode 100644 index b493aee651..0000000000 --- a/src/site/zh/xdoc/boot.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - MyBatis-Spring | 搭配 Spring Boot - Eduardo Macarron - - - -
    -

    - 请查看 MyBatis Spring-boot-starter - 子项目获取更多信息。 -

    -
    - -
    diff --git a/src/site/zh/xdoc/factorybean.xml b/src/site/zh/xdoc/factorybean.xml deleted file mode 100644 index ec33d4492a..0000000000 --- a/src/site/zh/xdoc/factorybean.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - MyBatis-Spring | SqlSessionFactoryBean - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    -

    - 在基础的 MyBatis 用法中,是通过 SqlSessionFactoryBuilder 来创建 SqlSessionFactory 的。 - 而在 MyBatis-Spring 中,则使用 SqlSessionFactoryBean 来创建。 -

    - - -

    - 要创建工厂 bean,将下面的代码放到 Spring 的 XML 配置文件中: -

    - - -]]> - -

    - 需要注意的是 SqlSessionFactoryBean 实现了 Spring 的 FactoryBean 接口(参见 Spring 官方文档 3.8 节 通过工厂 bean 自定义实例化逻辑)。这意味着由 Spring 最终创建的 bean 并不是 SqlSessionFactoryBean 本身,而是工厂类(SqlSessionFactoryBean)的 getObject() 方法的返回结果。这种情况下,Spring 将会在应用启动时为你创建 SqlSessionFactory,并使用 sqlSessionFactory 这个名字存储起来。 -

    -

    - 等效的 Java 代码如下: -

    - - - -

    - 通常,在 MyBatis-Spring 中,你不需要直接使用 SqlSessionFactoryBean 或对应的 SqlSessionFactory。相反,session 的工厂 bean 将会被注入到 MapperFactoryBean 或其它继承于 SqlSessionDaoSupport 的 DAO(Data Access Object,数据访问对象)中。 -

    -
    - - - -

    - SqlSessionFactory 有一个唯一的必要属性:用于 JDBC 的 DataSource。这可以是任意的 DataSource 对象,它的配置方法和其它 Spring 数据库连接是一样的。 -

    - -

    - 一个常用的属性是 configLocation,它用来指定 MyBatis 的 XML 配置文件路径。它在需要修改 MyBatis 的基础配置非常有用。通常,基础配置指的是 <settings><typeAliases> 元素。 -

    - -

    - 需要注意的是,这个配置文件并不需要是一个完整的 MyBatis 配置。确切地说,任何环境配置(<environments>),数据源(<DataSource>)和 MyBatis 的事务管理器(<transactionManager>)都会被忽略SqlSessionFactoryBean 会创建它自有的 MyBatis 环境配置(Environment),并按要求设置自定义环境的值。 -

    - -

    - 如果 MyBatis 在映射器类对应的路径下找不到与之相对应的映射器 XML 文件,那么也需要配置文件。这时有两种解决办法:第一种是手动在 MyBatis 的 XML 配置文件中的 <mappers> 部分中指定 XML 文件的类路径;第二种是设置工厂 bean 的 mapperLocations 属性。 -

    - -

    - mapperLocations 属性接受多个资源位置。这个属性可以用来指定 MyBatis 的映射器 XML 配置文件的位置。属性的值是一个 Ant 风格的字符串,可以指定加载一个目录中的所有文件,或者从一个目录开始递归搜索所有目录。比如: -

    - - - - -]]> - -

    - 这会从类路径下加载所有在 sample.config.mappers 包和它的子包中的 MyBatis 映射器 XML 配置文件。 -

    - -

    - 在容器管理事务的时候,你可能需要的一个属性是 transactionFactoryClass。请参考事务一章的相关章节。 -

    - -

    - 如果你使用了多个数据库,那么需要设置 databaseIdProvider 属性: -

    - - - - - sqlserver - db2 - oracle - mysql - - - - - - - - -]]> - -

    - 提示 自 1.3.0 版本开始,新增的 configuration 属性能够在没有对应的 MyBatis XML 配置文件的情况下,直接设置 Configuration 实例。例如: -

    - - - - - - - - -]]> - -
    -
    - -
    diff --git a/src/site/zh/xdoc/getting-started.xml.vm b/src/site/zh/xdoc/getting-started.xml.vm deleted file mode 100644 index 7ced8e3011..0000000000 --- a/src/site/zh/xdoc/getting-started.xml.vm +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - MyBatis-Spring | 入门 - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    -

    - 本章将会以简略的步骤告诉你如何安装和配置 MyBatis-Spring,并构建一个简单的具备事务管理功能的数据访问应用程序。 -

    - - -

    - 要使用 MyBatis-Spring 模块,只需要在类路径下包含 mybatis-spring-${project.version}.jar 文件和相关依赖即可。 -

    -

    - 如果使用 Maven 作为构建工具,仅需要在 pom.xml 中加入以下代码即可: -

    - - org.mybatis - mybatis-spring - ${project.version} -]]> -
    - - -

    - 要和 Spring 一起使用 MyBatis,需要在 Spring 应用上下文中定义至少两样东西:一个 SqlSessionFactory 和至少一个数据映射器类。 -

    - -

    - 在 MyBatis-Spring 中,可使用 SqlSessionFactoryBean来创建 SqlSessionFactory。 - 要配置这个工厂 bean,只需要把下面代码放在 Spring 的 XML 配置文件中: -

    - - - -]]> - - - -

    - 注意:SqlSessionFactory 需要一个 DataSource(数据源)。 - 这可以是任意的 DataSource,只需要和配置其它 Spring 数据库连接一样配置它就可以了。 -

    - -

    - 假设你定义了一个如下的 mapper 接口: -

    - - -

    - 那么可以通过 MapperFactoryBean 将接口加入到 Spring 中: -

    - - - - -]]> - -

    - 需要注意的是:所指定的映射器类必须是一个接口,而不是具体的实现类。在这个示例中,通过注解来指定 SQL 语句,但是也可以使用 MyBatis 映射器的 XML 配置文件。 -

    - -

    - 配置好之后,你就可以像 Spring 中普通的 bean 注入方法那样,将映射器注入到你的业务或服务对象中。MapperFactoryBean 将会负责 SqlSession 的创建和关闭。如果使用了 Spring 的事务功能,那么当事务完成时,session 将会被提交或回滚。最终任何异常都会被转换成 Spring 的 DataAccessException 异常。 -

    - -

    - 使用 Java 代码来配置的方式如下: -

    - - -

    - 要调用 MyBatis 的数据方法,只需一行代码: -

    - -
    -
    - -
    diff --git a/src/site/zh/xdoc/index.xml b/src/site/zh/xdoc/index.xml deleted file mode 100644 index 8f25bf170e..0000000000 --- a/src/site/zh/xdoc/index.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - MyBatis-Spring | 简介 - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    - -

    - MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中。它将允许 MyBatis 参与到 Spring 的事务管理之中,创建映射器 mapper 和 SqlSession 并注入到 bean 中,以及将 Mybatis 的异常转换为 Spring 的 DataAccessException。最终,可以做到应用代码不依赖于 MyBatis,Spring 或 MyBatis-Spring。 -

    -
    - - -

    - Spring 2.0 只支持 iBatis 2.0。那么,我们就想将 MyBatis3 的支持添加到 Spring 3.0 中(参见 Spring Jira 中的问题)。不幸的是,Spring 3.0 的开发在 MyBatis 3.0 官方发布前就结束了。由于 Spring 开发团队不想发布一个基于未发布版的 MyBatis 的整合支持,如果要获得 Spring 官方的支持,只能等待下一次的发布了。基于在 Spring 中对 MyBatis 提供支持的兴趣,MyBatis 社区认为,应该开始召集有兴趣参与其中的贡献者们,将对 Spring 的集成作为 MyBatis 的一个社区子项目。 -

    -
    - - -

    - 在开始使用 MyBatis-Spring 之前,你需要先熟悉 Spring 和 MyBatis 这两个框架和有关它们的术语。这很重要——因为本手册中不会提供二者的基本内容,安装和配置教程。 -

    -

    - MyBatis-Spring 需要以下版本: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - MyBatis-Spring - - MyBatis - - Spring 框架 - - Spring Batch - - Java -
    - 2.0 - - 3.5+ - - 5.0+ - - 4.0+ - - Java 8+ -
    - 1.3 - - 3.4+ - - 3.2.2+ - - 2.1+ - - Java 6+ -
    -
    - - -

    - 特别感谢那些使本项目变为现实的人们(按字母顺序排序): Eduardo Macarron, Hunter Presnall 和 Putthiphong Boonphong 负责本项目的代码实现,测试和编写文档工作;Andrius Juozapaitis, Giovanni Cuccu, Raj Nagappan 和 Tomas Pinos 的贡献;而 Simone Tripodi 发现了这些人并邀请他们参与到这一个 MyBatis 子项目之中。没有他们的努力,这个项目只能沦为空谈。 -

    -
    - - -

    - 如果你发现文档有任何的缺失,或者缺少某一个功能点的说明,最好的解决办法是先自己学习,并且为缺失的部份补上相应的文档。 -

    -

    - 手册的 xdoc 出自项目的 Git 仓库。Fork 仓库,更新它并提交 Pull Request 吧。 -

    -

    - 还有其它像你一样的人都需要阅读这份文档,而你,就是这份文档最好的作者。 -

    -
    - -

    可以阅读以下 MyBatis-Spring 文档的翻译版本:

    - -

    想用自己的母语阅读这篇文档吗?那就用你的母语翻译它吧!

    -
    - -
    - - -
    diff --git a/src/site/zh/xdoc/mappers.xml b/src/site/zh/xdoc/mappers.xml deleted file mode 100644 index ee61574e14..0000000000 --- a/src/site/zh/xdoc/mappers.xml +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - MyBatis-Spring | 注入映射器 - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    -

    - 与其在数据访问对象(DAO)中手工编写使用 SqlSessionDaoSupportSqlSessionTemplate 的代码,还不如让 Mybatis-Spring 为你创建一个线程安全的映射器,这样你就可以直接注入到其它的 bean 中了: -

    - - - -]]> - -

    - 注入完毕后,映射器就可以在你的应用逻辑代码中使用了: -

    - -

    - 注意代码中并没有任何的对 SqlSession 或 MyBatis 的引用。你也不需要担心创建、打开、关闭 session,MyBatis-Spring 将为你打理好一切。 -

    - - -

    - 注册映射器的方法根据你的配置方法,即经典的 XML 配置或新的 3.0 以上版本的 Java 配置(也就是常说的 @Configuration),而有所不同。 -

    - -

    XML 配置

    - -

    - 在你的 XML 中加入 MapperFactoryBean 以便将映射器注册到 Spring 中。就像下面一样: -

    - - - -]]> - -

    - 如果映射器接口 UserMapper 在相同的类路径下有对应的 MyBatis XML 映射器配置文件,将会被 MapperFactoryBean 自动解析。不需要在 MyBatis 配置文件中显式配置映射器,除非映射器配置文件与接口类不在同一个类路径下。参考 SqlSessionFactoryBeanconfigLocation 属性以获取更多信息。 -

    - -

    - 注意 MapperFactoryBean 需要配置一个 SqlSessionFactorySqlSessionTemplate。它们可以分别通过 sqlSessionFactorysqlSessionTemplate 属性来进行设置。如果两者都被设置,SqlSessionFactory 将被忽略。由于 SqlSessionTemplate 已经设置了一个 session 工厂,MapperFactoryBean 将使用那个工厂。 -

    - -

    Java 配置

    - - userMapper() throws Exception { - MapperFactoryBean factoryBean = new MapperFactoryBean<>(UserMapper.class); - factoryBean.setSqlSessionFactory(sqlSessionFactory()); - return factoryBean; -}]]> - -
    - - -

    - 不需要一个个地注册你的所有映射器。你可以让 MyBatis-Spring 对类路径进行扫描来发现它们。 -

    - -

    - 有几种办法来发现映射器: -

    -
      -
    • 使用 <mybatis:scan/> 元素
    • -
    • 使用 @MapperScan 注解
    • -
    • 在经典 Spring XML 配置文件中注册一个 MapperScannerConfigurer
    • -
    - -

    <mybatis:scan/>@MapperScan 都在 MyBatis-Spring 1.2.0 中被引入。@MapperScan 需要你使用 Spring 3.1+。

    - -

    - Since 2.0.2, mapper scanning feature support a option (lazy-initialization) - that control lazy initialization enabled/disabled of mapper bean. - The motivation for adding this option is supporting a lazy initialization control feature supported by Spring Boot 2.2. - The default of this option is false (= not use lazy initialization). - If developer want to use lazy initialization for mapper bean, it should be set to the true expressly. -

    -

    - IMPORTANT If use the lazy initialization feature, - the developer need to understand following limitations. If any of following conditions are matches, - usually the lazy initialization feature cannot use on your application. -

    -
      -
    • When refers to the statement of other mapper using ]]>(@One) and ]]>(@Many)
    • -
    • When includes to the fragment of other mapper using ]]>
    • -
    • When refers to the cache of other mapper using ]]>(@CacheNamespaceRef)
    • -
    • When refers to the result mapping of other mapper using ]]>(@ResultMap)
    • -
    - -

    - NOTE However, It become possible to use it by simultaneously initializing dependent beans using @DependsOn(Spring's feature) as follow: -

    - - - -

    - Since 2.0.6, the develop become can specified scope of mapper using mapper scanning feature option(default-scope) - and scope annotation(@Scope, @RefreshScope, etc ...). - The motivation for adding this option is supporting the refresh scope provided by the Spring Cloud. - The default of this option is empty (= equiv to specify the singleton scope). - The default-scope apply to the mapper bean(MapperFactoryBean) when scope of scanned bean definition - is singleton(default scope) and create a scoped proxy bean for scanned mapper when final scope is not singleton. -

    - -

    <mybatis:scan/>

    - -

    - <mybatis:scan/> 元素会发现映射器,它发现映射器的方法与 Spring 内建的 <context:component-scan/> 发现 bean 的方法非常类似。 -

    - -

    下面是一个 XML 配置样例:

    - - - - - - - -]]> - -

    - base-package 属性允许你设置映射器接口文件的基础包。通过使用逗号或分号分隔,你可以设置多个包。并且会在你所指定的包中递归搜索映射器。 -

    - -

    - 注意,不需要为 <mybatis:scan/> 指定 SqlSessionFactorySqlSessionTemplate,这是因为它将使用能够被自动注入的 MapperFactoryBean。但如果你正在使用多个数据源(DataSource),自动注入可能不适合你。在这种情况下,你可以使用 factory-reftemplate-ref 属性指定你想使用的 bean 名称。 -

    - -

    - <mybatis:scan/> 支持基于标记接口或注解的过滤操作。在 annotation 属性中,可以指定映射器应该具有的特定注解。而在 marker-interface 属性中,可以指定映射器应该继承的父接口。当这两个属性都被设置的时候,被发现的映射器会满足这两个条件。默认情况下,这两个属性为空,因此在基础包中的所有接口都会被作为映射器被发现。 -

    - -

    - 被发现的映射器会按照 Spring 对自动发现组件的默认命名策略进行命名(参考 the Spring reference document(Core Technologies -Naming autodetected components-))。也就是说,如果没有使用注解显式指定名称,将会使用映射器的首字母小写非全限定类名作为名称。但如果发现映射器具有 @Component 或 JSR-330 标准中 @Named 注解,会使用注解中的名称作为名称。提醒一下,你可以设置 annotation 属性为你自定义的注解,然后在你的注解上设置 org.springframework.stereotype.Componentjavax.inject.Named(需要使用 Java SE 6 以上)注解,这样你的注解既可以作为标记,也可以作为一个名字提供器来使用了。 -

    - -

    - 提示 <context:component-scan/> 无法发现并注册映射器。映射器的本质是接口,为了将它们注册到 Spring 中,发现器必须知道如何为找到的每个接口创建一个 MapperFactoryBean。 -

    - -

    @MapperScan

    - -

    - 当你正在使用 Spring 的基于 Java 的配置时(也就是 @Configuration),相比于使用 <mybatis:scan/>,你会更喜欢用 @MapperScan。 -

    - -

    @MapperScan 注解的使用方法如下:

    - - - -

    - 这个注解具有与之前见过的 <mybatis:scan/> 元素一样的工作方式。它也可以通过 markerInterfaceannotationClass 属性设置标记接口或注解类。通过配置 sqlSessionFactorysqlSessionTemplate 属性,你还能指定一个 SqlSessionFactorySqlSessionTemplate。 -

    - -

    - NOTE Since 2.0.4, If basePackageClasses or basePackages are not defined, scanning will occur from the package of the class that declares this annotation. -

    - -

    MapperScannerConfigurer

    - -

    - MapperScannerConfigurer 是一个 BeanDefinitionRegistryPostProcessor,这样就可以作为一个 bean,包含在经典的 XML 应用上下文中。为了配置 MapperScannerConfigurer,使用下面的 Spring 配置: -

    - - -]]> - -

    - 如果你需要指定 sqlSessionFactorysqlSessionTemplate,那你应该要指定的是 bean 名而不是 bean 的引用,因此要使用 value 属性而不是通常的 ref 属性: -

    - ]]> - -

    - 提示 在 MyBatis-Spring 1.0.2 之前,sqlSessionFactoryBean 和 - sqlSessionTemplateBean 属性是唯一可用的属性。但由于 MapperScannerConfigurer 在启动过程中比 PropertyPlaceholderConfigurer 运行得更早,经常会产生错误。基于这个原因,上述的属性已被废弃,现在建议使用 sqlSessionFactoryBeanNamesqlSessionTemplateBeanName 属性。 -

    -
    -
    - -
    diff --git a/src/site/zh/xdoc/sample.xml b/src/site/zh/xdoc/sample.xml deleted file mode 100644 index ba69cc0abf..0000000000 --- a/src/site/zh/xdoc/sample.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - MyBatis-Spring | 示例代码 - Eduardo Macarron - - - -
    - -

    - 提示 - 查看 JPetstore 6 demo 了解如何在完整的 Web 应用服务器上使用 Spring。 -

    - -

    - 您可以在 MyBatis-Spring 的代码仓库 中查看示例代码: -

    -

    - 所有示例都能在 JUnit 5 下运行。 -

    -

    - 示例代码演示了事务服务从数据访问层获取域对象的典型设计。 -

    -

    - FooService.java 作为服务: -

    - -

    - 它是一个事务 bean,所以当调用它的任何方法时,事务被启动,在方法结束且没有抛出任何未经检查的异常的时候事务将会被提交。注意,事务的行为可以通过 @Transactional 的属性进行配置。这不是必需的;你可以使用 Spring 提供的任何其他方式来划分你的事务范围。 -

    -

    - 此服务调用使用 MyBatis 构建的数据访问层.。该层只包含一个接口,UserMapper.java,这将被 MyBatis 构建的动态代理使用,在运行时通过 Spring 注入到服务之中。 -

    - -

    - 注意,为了简单起见,我们使用了接口 UserMapper.java。在使用 DAO 的场景中,一个 DAO 类应该分为一个接口和一个实现类。回到这个例子里,准确来说,这个接口应该叫 UserDao.java 。 -

    -

    - 我们将看到不同的方法来发现映射器接口,将其注册到 Spring 并将其注入到服务 bean 中: -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    测试场景
    样例测试描述
    - SampleMapperTest.java - - 演示基于 MapperFactoryBean 的基本配置,这将动态构建 UserMapper 的一个实现。 -
    - SampleScannerTest.java - - 演示如何使用 MapperScannerConfigurer 来自动发现项目中所有的映射器。 -
    - SampleSqlSessionTest.java - - 演示如何基于 Spring 管理的 SqlSession 手动编写 DAO,并在 UserDaoImpl.java 中提供你自己的实现。 -
    - SampleEnableTest - - 演示如何使用 Spring 的 @Configuration@MapperScann 注解来自动发现 mappers. -
    - SampleNamespaceTest - - 演示如何使用自定义 MyBatis XML 命名空间. -
    - SampleJavaConfigTest.java - - 演示如何基于 Spring 的 @Configuration 来手工创建 MyBatis 的 bean。 -
    - SampleJobJavaConfigTest.java - - 演示如何在 Java 配置中使用 Spring Batch 中的 ItemReaderItemWriter。 -
    - SampleJobXmlConfigTest.java - - 演示如何在 XML 配置中使用 Spring Batch 中的 ItemReaderItemWriter。 -
    -

    - 查看不同的 applicationContext.xml 文件以了解 MyBatis-Spring 在实践中是如何运用的。 -

    - -
    - -
    - diff --git a/src/site/zh/xdoc/sqlsession.xml b/src/site/zh/xdoc/sqlsession.xml deleted file mode 100644 index 475a96a935..0000000000 --- a/src/site/zh/xdoc/sqlsession.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - MyBatis-Spring | 使用 SqlSession - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    -

    - 在 MyBatis 中,你可以使用 SqlSessionFactory 来创建 SqlSession。一旦你获得一个 session 之后,你可以使用它来执行映射了的语句,提交或回滚连接,最后,当不再需要它的时候,你可以关闭 session。使用 MyBatis-Spring 之后,你不再需要直接使用 SqlSessionFactory 了,因为你的 bean 可以被注入一个线程安全的 SqlSession,它能基于 Spring 的事务配置来自动提交、回滚、关闭 session。 -

    - - -

    - SqlSessionTemplate 是 MyBatis-Spring 的核心。作为 SqlSession 的一个实现,这意味着可以使用它无缝代替你代码中已经在使用的 SqlSessionSqlSessionTemplate 是线程安全的,可以被多个 DAO 或映射器所共享使用。 -

    - -

    - 当调用 SQL 方法时(包括由 getMapper() 方法返回的映射器中的方法),SqlSessionTemplate 将会保证使用的 SqlSession 与当前 Spring 的事务相关。此外,它管理 session 的生命周期,包含必要的关闭、提交或回滚操作。另外,它也负责将 MyBatis 的异常翻译成 Spring 中的 DataAccessExceptions。 -

    - -

    - 由于模板可以参与到 Spring 的事务管理中,并且由于其是线程安全的,可以供多个映射器类使用,你应该总是SqlSessionTemplate 来替换 MyBatis 默认的 DefaultSqlSession 实现。在同一应用程序中的不同类之间混杂使用可能会引起数据一致性的问题。 -

    - -

    - 可以使用 SqlSessionFactory 作为构造方法的参数来创建 SqlSessionTemplate 对象。 -

    - - -]]> - - - -

    - 现在,这个 bean 就可以直接注入到你的 DAO bean 中了。你需要在你的 bean 中添加一个 SqlSession 属性,就像下面这样: -

    - -

    - 按下面这样,注入 SqlSessionTemplate: -

    - - -]]> - -

    - SqlSessionTemplate 还有一个接收 ExecutorType 参数的构造方法。这允许你使用如下 Spring 配置来批量创建对象,例如批量创建一些 SqlSession: -

    - - - -]]> - - - -

    - 现在所有的映射语句可以进行批量操作了,可以在 DAO 中编写如下的代码 -

    - users) { - for (User user : users) { - sqlSession.insert("org.mybatis.spring.sample.mapper.UserMapper.insertUser", user); - } -}]]> - -

    - 注意,只需要在希望语句执行的方法与 SqlSessionTemplate 中的默认设置不同时使用这种配置。 -

    - -

    - 这种配置的弊端在于,当调用这个方法时,不能存在使用不同 ExecutorType 的进行中的事务。要么确保对不同 ExecutorTypeSqlSessionTemplate 的调用处在不同的事务中,要么完全不使用事务。 -

    -
    - - -

    - SqlSessionDaoSupport 是一个抽象的支持类,用来为你提供 SqlSession。调用 getSqlSession() 方法你会得到一个 SqlSessionTemplate,之后可以用于执行 SQL 方法,就像下面这样: -

    - -

    - 在这个类里面,通常更倾向于使用 MapperFactoryBean,因为它不需要额外的代码。但是,如果你需要在 DAO 中做其它非 MyBatis 的工作或需要一个非抽象的实现类,那么这个类就很有用了。 -

    - -

    - SqlSessionDaoSupport 需要通过属性设置一个 sqlSessionFactorySqlSessionTemplate。如果两个属性都被设置了,那么 SqlSessionFactory 将被忽略。 -

    - -

    - 假设类 UserMapperImplSqlSessionDaoSupport 的子类,可以编写如下的 Spring 配置来执行设置: -

    - - -]]> -
    -
    - -
    diff --git a/src/site/zh/xdoc/transactions.xml b/src/site/zh/xdoc/transactions.xml deleted file mode 100644 index 95d801251a..0000000000 --- a/src/site/zh/xdoc/transactions.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - MyBatis-Spring | 事务 - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    -

    - 一个使用 MyBatis-Spring 的其中一个主要原因是它允许 MyBatis 参与到 Spring 的事务管理中。而不是给 MyBatis 创建一个新的专用事务管理器,MyBatis-Spring 借助了 Spring 中的 DataSourceTransactionManager 来实现事务管理。 -

    -

    - 一旦配置好了 Spring 的事务管理器,你就可以在 Spring 中按你平时的方式来配置事务。并且支持 @Transactional 注解和 AOP 风格的配置。在事务处理期间,一个单独的 SqlSession 对象将会被创建和使用。当事务完成时,这个 session 会以合适的方式提交或回滚。 -

    -

    - 事务配置好了以后,MyBatis-Spring 将会透明地管理事务。这样在你的 DAO 类中就不需要额外的代码了。 -

    - - -

    - 要开启 Spring 的事务处理功能,在 Spring 的配置文件中创建一个 DataSourceTransactionManager 对象: -

    - - -]]> - - - -

    - 传入的 DataSource 可以是任何能够与 Spring 兼容的 JDBC DataSource。包括连接池和通过 JNDI 查找获得的 DataSource。 -

    -

    - 注意:为事务管理器指定的 DataSource 必须和用来创建 SqlSessionFactoryBean 的是同一个数据源,否则事务管理器就无法工作了。 -

    -
    - - -

    - 如果你正使用一个 JEE 容器而且想让 Spring 参与到容器管理事务(Container managed transactions,CMT)的过程中,那么 Spring 应该被设置为使用 JtaTransactionManager 或由容器指定的一个子类作为事务管理器。最简单的方式是使用 Spring 的事务命名空间或使用 JtaTransactionManagerFactoryBean: -

    - ]]> - - - -

    - 在这个配置中,MyBatis 将会和其它由容器管理事务配置的 Spring 事务资源一样。Spring 会自动使用任何一个存在的容器事务管理器,并注入一个 SqlSession。如果没有正在进行的事务,而基于事务配置需要一个新的事务的时候,Spring 会开启一个新的由容器管理的事务。 -

    -

    - 注意,如果你想使用由容器管理的事务,而不想使用 Spring 的事务管理,你就不能配置任何的 Spring 事务管理器。并必须配置 SqlSessionFactoryBean 以使用基本的 MyBatis 的 ManagedTransactionFactory: -

    - - - - - -]]> - - - -
    - - -

    - MyBatis 的 SqlSession 提供几个方法来在代码中处理事务。但是当使用 MyBatis-Spring 时,你的 bean 将会注入由 Spring 管理的 SqlSession 或映射器。也就是说,Spring 总是为你处理了事务。 -

    -

    - 你不能在 Spring 管理的 SqlSession 上调用 SqlSession.commit()SqlSession.rollback()SqlSession.close() 方法。如果这样做了,就会抛出 UnsupportedOperationException 异常。在使用注入的映射器时,这些方法也不会暴露出来。 -

    -

    - 无论 JDBC 连接是否设置为自动提交,调用 SqlSession 数据方法或在 Spring 事务之外调用任何在映射器中方法,事务都将会自动被提交。 -

    -

    - 如果你想编程式地控制事务,请参考 the Spring reference document(Data Access -Programmatic transaction management-)。下面的代码展示了如何使用 PlatformTransactionManager 手工管理事务。 -

    - - -

    - 在使用 TransactionTemplate 的时候,可以省略对 commitrollback 方法的调用。 -

    - - { - userMapper.insertUser(user); - return null; -});]]> - -

    - 注意:虽然这段代码使用的是一个映射器,但换成 SqlSession 也是可以工作的。 -

    -
    -
    - -
    diff --git a/src/site/zh/xdoc/using-api.xml b/src/site/zh/xdoc/using-api.xml deleted file mode 100644 index f8b2f025e1..0000000000 --- a/src/site/zh/xdoc/using-api.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - MyBatis-Spring | 使用 MyBatis API - Hunter Presnall - Eduardo Macarron - Nan Lei - - - -
    -

    - 使用 MyBatis-Spring,你可以继续直接使用 MyBatis 的 API。只需简单地使用 SqlSessionFactoryBean 在 Spring 中创建一个 SqlSessionFactory,然后按你的方式在代码中使用工厂即可。 -

    - - -

    - 小心使用此选项,错误地使用会产生运行时错误,更糟糕地,会产生数据一致性的问题。直接使用 API 时,注意以下弊端: -

    -
      -
    • -

      - 它不会参与到 Spring 的事务管理之中。 -

      -
    • -
    • -

      - 如果 SqlSession 使用与 Spring 事务管理器使用的相同 DataSource,并且有进行中的事务,代码会抛出异常。 -

      -
    • -
    • -

      - MyBatis 的 DefaultSqlSession 是线程不安全的。如果在 bean 中注入了它,会发生错误。 -

      -
    • -
    • -

      - 使用 DefaultSqlSession 创建的映射器也不是线程安全的。如果你将它们注入到 bean 中,会发生错误。 -

      -
    • -
    • -

      - 你必须确保总是在 finally 块中来关闭 SqlSession。 -

      -
    • -
    -
    - -
    From 6398406ae592655d4b2344ed18617548e6cee0f4 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 25 Jun 2020 01:08:41 +0900 Subject: [PATCH 229/933] Update README.md Add link snapshot document(Using GitHub rendering for markdown) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c9998ae095..52aee0b493 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,5 @@ Supported Versions Essentials ---------- -* [See the docs](http://mybatis.github.io/spring/) +* [See the published docs](http://mybatis.github.io/spring/) +* [See the snapshot docs](src/site/markdown) (Note: may contain explanation of unreleased features) From 4ec91f4fb2780c9fae630422802fba00c06efb0a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 25 Jun 2020 01:21:26 +0900 Subject: [PATCH 230/933] Change explanation for document format on index.md --- src/site/es/markdown/index.md | 2 +- src/site/ko/markdown/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/es/markdown/index.md b/src/site/es/markdown/index.md index ed37f9ad8c..fc743e6986 100644 --- a/src/site/es/markdown/index.md +++ b/src/site/es/markdown/index.md @@ -36,7 +36,7 @@ y a Simone Tripodi por encontrarlos a todos y traerlos al proyecto MyBatis ;) Si Si ves que hay alguna carencia en esta documentación, o que falta alguna característica por documentar, te animamos a que lo investigues y la documentes tu mismo! -Las fuentes de este manual están disponibles en formato xdoc en el [Git del proyecto](https://github.com/mybatis/mybatis-3/tree/master/src/site). Haz un fork, cambialas y envía un pull request. +Las fuentes de este manual están disponibles en formato markdown en el [Git del proyecto](https://github.com/mybatis/mybatis-3/tree/master/src/site). Haz un fork, cambialas y envía un pull request. Eres el mejor candidato para documentar porque los lectores de esta documentación son gente como tú! diff --git a/src/site/ko/markdown/index.md b/src/site/ko/markdown/index.md index 393eec171f..398187680a 100644 --- a/src/site/ko/markdown/index.md +++ b/src/site/ko/markdown/index.md @@ -35,7 +35,7 @@ MyBatis-Spring requires following versions: 만약에 어떤 방법으로든 이 문서의 취약점이 발견되거나 기능에 대한 문서화가 빠진 부분이 보인다면, 가장 좋은 방법은 먼저 공부해서 자신만의 문서를 작성하는 것이다. -이 문서의 원본은 xdoc포맷이며 [프로젝트의 Git](https://github.com/mybatis/spring/tree/master/src/site)에서 찾을 수 있다. repository 를 fork 하고, 업데이트하고 pull request 를 보내주십시오. +이 문서의 원본은 markdown 포맷이며 [프로젝트의 Git](https://github.com/mybatis/spring/tree/master/src/site)에서 찾을 수 있다. repository 를 fork 하고, 업데이트하고 pull request 를 보내주십시오. 당신처럼 이 문서를 읽는 사람들에게 이 문서의 최고의 저자가 될수 있다! From 19b6267eb41458b32e7f1edda36371d97f43159f Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 27 Jun 2020 09:41:59 +0900 Subject: [PATCH 231/933] Add openjdk15 on .travis.yml because openjdk-ea becomed alias of openjdk16 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d8110f766a..a325b9e719 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: java jdk: - openjdk-ea + - openjdk15 - openjdk14 - openjdk11 - openjdk8 From 8dc5241342a8a967c77576ef7eafb1b3e582bb03 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 29 Jun 2020 07:07:06 +0000 Subject: [PATCH 232/933] Bump hsqldb from 2.5.0 to 2.5.1 Bumps hsqldb from 2.5.0 to 2.5.1. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71e1e52794..05e562dffc 100644 --- a/pom.xml +++ b/pom.xml @@ -210,7 +210,7 @@ org.hsqldb hsqldb - 2.5.0 + 2.5.1 test From 7264301b0efe64afb286aeb3e5248fe0ecddc180 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2020 06:41:45 +0000 Subject: [PATCH 233/933] Bump transactions-jdbc from 5.0.6 to 5.0.7 Bumps transactions-jdbc from 5.0.6 to 5.0.7. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05e562dffc..e79203567c 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ com.atomikos transactions-jdbc - 5.0.6 + 5.0.7 test From ffdf16f7a1cc8736200ede5330dbddc1a766917c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 4 Jul 2020 23:57:00 +0000 Subject: [PATCH 234/933] Create Dependabot config file --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..2de9eee4c5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: org.apache.derby:derby + versions: + - "> 10.14.2.0" From 899d7a02f655da032b3900a0f8ee7ee2366bd72c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2020 05:16:46 +0000 Subject: [PATCH 235/933] Bump transactions-jdbc from 5.0.7 to 5.0.8 Bumps transactions-jdbc from 5.0.7 to 5.0.8. Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e79203567c..07ded3d60e 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ com.atomikos transactions-jdbc - 5.0.7 + 5.0.8 test From 5c723b0fce02c90cd917a381203bc6bf6a66ffa3 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sat, 11 Jul 2020 13:58:07 +0900 Subject: [PATCH 236/933] Set attribute that helps MockitoPostProcessor replace a MyBatis mapper bean with a mock https://github.com/mybatis/spring-boot-starter/issues/475 https://github.com/spring-projects/spring-boot/commit/f4985abf3cd299f0842d9f474942c418f177eb13 --- .../org/mybatis/spring/mapper/ClassPathMapperScanner.java | 7 +++++++ .../spring/mapper/MapperScannerConfigurerTest.java | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 983b36ae20..208b579eb3 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -57,6 +57,9 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { private static final Logger LOGGER = LoggerFactory.getLogger(ClassPathMapperScanner.class); + // Copy of FactoryBean#OBJECT_TYPE_ATTRIBUTE which was added in Spring 5.2 + static final String FACTORY_BEAN_OBJECT_TYPE = "factoryBeanObjectType"; + private boolean addToConfig = true; private boolean lazyInitialization; @@ -234,6 +237,10 @@ private void processBeanDefinitions(Set beanDefinitions) { definition.getPropertyValues().add("addToConfig", this.addToConfig); + // Attribute for MockitoPostProcessor + // https://github.com/mybatis/spring-boot-starter/issues/475 + definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClassName); + boolean explicitFactoryUsed = false; if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) { definition.getPropertyValues().add("sqlSessionFactory", diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index 05e453aa2e..d62d1af27a 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -385,6 +385,14 @@ void testScanWithMapperFactoryBeanClass() { assertTrue(DummyMapperFactoryBean.getMapperCount() > 0); } + @Test + void testMapperBeanAttribute() { + startContext(); + + assertThat(applicationContext.getBeanDefinition("annotatedMapper").getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)) + .isEqualTo(AnnotatedMapper.class.getName()); + } + private void setupSqlSessionFactory(String name) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); From c39c39a7176511c86cc729786eea5ed1fcd681a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2020 06:10:32 +0000 Subject: [PATCH 237/933] Bump mockito-core from 3.3.3 to 3.4.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.3.3 to 3.4.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.3.3...v3.4.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 07ded3d60e..20af597311 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.3.3 + 3.4.0 test From 34467d74e509445d9478c9ed1b78620ad1730326 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2020 05:18:27 +0000 Subject: [PATCH 238/933] Bump mockito-core from 3.4.0 to 3.4.2 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.0 to 3.4.2. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.4.0...v3.4.2) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 20af597311..3f435a7034 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.4.0 + 3.4.2 test From e2c5e2bbb9daecbf594571acd2ea07b6e74e68f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2020 06:00:06 +0000 Subject: [PATCH 239/933] Bump mockito-core from 3.4.2 to 3.4.4 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.2 to 3.4.4. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.4.2...v3.4.4) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f435a7034..724d4ec779 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.4.2 + 3.4.4 test From 8f01cf209c9351306f5dbd25964144276745ea83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2020 05:57:43 +0000 Subject: [PATCH 240/933] Bump byteman-bmunit from 4.0.11 to 4.0.12 Bumps byteman-bmunit from 4.0.11 to 4.0.12. Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 724d4ec779..8a247f5acb 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.jboss.byteman byteman-bmunit - 4.0.11 + 4.0.12 test From 62c6cf3de03a13826ce273047f13a96084c19144 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2020 06:05:02 +0000 Subject: [PATCH 241/933] Bump spring.version from 5.2.7.RELEASE to 5.2.8.RELEASE Bumps `spring.version` from 5.2.7.RELEASE to 5.2.8.RELEASE. Updates `spring-context` from 5.2.7.RELEASE to 5.2.8.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.7.RELEASE...v5.2.8.RELEASE) Updates `spring-jdbc` from 5.2.7.RELEASE to 5.2.8.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.7.RELEASE...v5.2.8.RELEASE) Updates `spring-test` from 5.2.7.RELEASE to 5.2.8.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.7.RELEASE...v5.2.8.RELEASE) Updates `spring-web` from 5.2.7.RELEASE to 5.2.8.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.7.RELEASE...v5.2.8.RELEASE) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8a247f5acb..dc29dfae70 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.5 - 5.2.7.RELEASE + 5.2.8.RELEASE 4.2.4.RELEASE org.mybatis.spring From 87c39bfed18b6b37890d1291feefe50c23d715c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2020 05:28:59 +0000 Subject: [PATCH 242/933] Bump mockito-core from 3.4.4 to 3.4.6 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.4 to 3.4.6. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.4.4...v3.4.6) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc29dfae70..db19fa5858 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.4.4 + 3.4.6 test From 9a6c8793ed31812a9cd9450de47b84454738d780 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2020 05:41:08 +0000 Subject: [PATCH 243/933] Bump byteman-bmunit from 4.0.12 to 4.0.13 Bumps byteman-bmunit from 4.0.12 to 4.0.13. Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index db19fa5858..0bda931f15 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.jboss.byteman byteman-bmunit - 4.0.12 + 4.0.13 test From f2a709b6ca2bb0166657bad27967a82f3914ce0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2020 05:37:49 +0000 Subject: [PATCH 244/933] Bump mockito-core from 3.4.6 to 3.5.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.6 to 3.5.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.4.6...v3.5.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0bda931f15..97d2169f46 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.4.6 + 3.5.0 test From 73abf976075fab9fcf7a7a17eeb330ca8b7e5232 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2020 05:38:52 +0000 Subject: [PATCH 245/933] Bump mockito-core from 3.5.0 to 3.5.2 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.0...v3.5.2) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 97d2169f46..c06cb7631c 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.0 + 3.5.2 test From 8b94577138e6bb961ccff702fa26bd30c0f2490b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2020 05:49:06 +0000 Subject: [PATCH 246/933] Bump assertj-core from 3.16.1 to 3.17.0 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.16.1 to 3.17.0. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.16.1...assertj-core-3.17.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c06cb7631c..812f33e434 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.16.1 + 3.17.0 test From c0f3afe78d0054935af15f35f14e0b0306f60fb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2020 05:42:03 +0000 Subject: [PATCH 247/933] Bump mockito-core from 3.5.2 to 3.5.6 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.2 to 3.5.6. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.2...v3.5.6) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c06cb7631c..a65244246b 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.2 + 3.5.6 test From 7fa406a583227f9c60bde855164c78da2dd70acb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 05:42:35 +0000 Subject: [PATCH 248/933] Bump mockito-core from 3.5.6 to 3.5.7 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.6 to 3.5.7. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.6...v3.5.7) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a65244246b..a69f576942 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.6 + 3.5.7 test From 9a06a0ad7a1728172b01ab2ab4d90f35892a54f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2020 05:37:07 +0000 Subject: [PATCH 249/933] Bump assertj-core from 3.17.0 to 3.17.1 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.17.0 to 3.17.1. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.17.0...assertj-core-3.17.1) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3096588589..89315af258 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.17.0 + 3.17.1 test From 62c49ad2d46eb27f176a93af08ad4a96a001426d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Sep 2020 05:38:29 +0000 Subject: [PATCH 250/933] Bump mockito-core from 3.5.7 to 3.5.9 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.7 to 3.5.9. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.7...v3.5.9) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89315af258..ec40ad52db 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.7 + 3.5.9 test From e5b70c2412904a35ddbf230f1439e014345f2e1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2020 05:17:30 +0000 Subject: [PATCH 251/933] Bump mockito-core from 3.5.9 to 3.5.10 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.9 to 3.5.10. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.9...v3.5.10) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec40ad52db..7da4a5cd1d 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.9 + 3.5.10 test From da2093f0c20bb00cc9ba2f6384d8ca5d0bf90f0b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Sep 2020 05:18:59 +0000 Subject: [PATCH 252/933] Bump assertj-core from 3.17.1 to 3.17.2 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.17.1 to 3.17.2. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.17.1...assertj-core-3.17.2) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7da4a5cd1d..d6b09be829 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.17.1 + 3.17.2 test From ca9c5e1caf365ba4ac1a9a37dbca45d664a30106 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Sep 2020 05:41:48 +0000 Subject: [PATCH 253/933] Bump junit-jupiter-engine from 5.6.2 to 5.7.0 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.6.2 to 5.7.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.6.2...r5.7.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d6b09be829..e32c06917a 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.2.4.RELEASE org.mybatis.spring - 5.6.2 + 5.7.0 From c633ef66e811c80438337d85350fa8813a69c975 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2020 05:21:55 +0000 Subject: [PATCH 254/933] Bump spring.version from 5.2.8.RELEASE to 5.2.9.RELEASE Bumps `spring.version` from 5.2.8.RELEASE to 5.2.9.RELEASE. Updates `spring-context` from 5.2.8.RELEASE to 5.2.9.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.8.RELEASE...v5.2.9.RELEASE) Updates `spring-jdbc` from 5.2.8.RELEASE to 5.2.9.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.8.RELEASE...v5.2.9.RELEASE) Updates `spring-test` from 5.2.8.RELEASE to 5.2.9.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.8.RELEASE...v5.2.9.RELEASE) Updates `spring-web` from 5.2.8.RELEASE to 5.2.9.RELEASE - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.8.RELEASE...v5.2.9.RELEASE) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e32c06917a..97794777d1 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.5 - 5.2.8.RELEASE + 5.2.9.RELEASE 4.2.4.RELEASE org.mybatis.spring From 46f2a729ca3a9675e11210777bb525975f80efee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Sep 2020 05:22:58 +0000 Subject: [PATCH 255/933] Bump mockito-core from 3.5.10 to 3.5.11 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.10 to 3.5.11. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.10...v3.5.11) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 97794777d1..eeb49dcc73 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.10 + 3.5.11 test From d2bb7d63923eb7c873551abb7ef651b2981c1ba4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2020 06:15:57 +0000 Subject: [PATCH 256/933] Bump mybatis-parent from 32-SNAPSHOT to 32 Bumps [mybatis-parent](https://github.com/mybatis/parent) from 32-SNAPSHOT to 32. - [Release notes](https://github.com/mybatis/parent/releases) - [Commits](https://github.com/mybatis/parent/commits) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eeb49dcc73..f5ccaf6527 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 32-SNAPSHOT + 32 From 42fb1138855c9d760477c939137c73ffa8112f59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Sep 2020 05:39:17 +0000 Subject: [PATCH 257/933] Bump mockito-core from 3.5.11 to 3.5.13 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.11 to 3.5.13. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.11...v3.5.13) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f5ccaf6527..b656fdc8ba 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.11 + 3.5.13 test From afd9853f8b411dfb211f051c88702b24f9ac1941 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2020 06:21:59 +0000 Subject: [PATCH 258/933] Bump mockrunner-ejb from 2.0.4 to 2.0.6 Bumps [mockrunner-ejb](https://github.com/mockrunner/mockrunner) from 2.0.4 to 2.0.6. - [Release notes](https://github.com/mockrunner/mockrunner/releases) - [Changelog](https://github.com/mockrunner/mockrunner/blob/master/releasenotes.txt) - [Commits](https://github.com/mockrunner/mockrunner/compare/mockrunner-2.0.4...mockrunner-2.0.6) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b656fdc8ba..84d2adf847 100644 --- a/pom.xml +++ b/pom.xml @@ -266,7 +266,7 @@ com.mockrunner mockrunner-ejb - 2.0.4 + 2.0.6 test From 87e5a1ad0790332c1030284c256d7334504d5ba2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2020 06:22:01 +0000 Subject: [PATCH 259/933] Bump mockrunner-core from 2.0.4 to 2.0.6 Bumps [mockrunner-core](https://github.com/mockrunner/mockrunner) from 2.0.4 to 2.0.6. - [Release notes](https://github.com/mockrunner/mockrunner/releases) - [Changelog](https://github.com/mockrunner/mockrunner/blob/master/releasenotes.txt) - [Commits](https://github.com/mockrunner/mockrunner/compare/mockrunner-2.0.4...mockrunner-2.0.6) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b656fdc8ba..36fdadd651 100644 --- a/pom.xml +++ b/pom.xml @@ -238,7 +238,7 @@ com.mockrunner mockrunner-core - 2.0.4 + 2.0.6 test From ff5cd251f76a96fb2d9b9f281eb241f62c707054 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2020 06:22:05 +0000 Subject: [PATCH 260/933] Bump mockrunner-jdbc from 2.0.4 to 2.0.6 Bumps [mockrunner-jdbc](https://github.com/mockrunner/mockrunner) from 2.0.4 to 2.0.6. - [Release notes](https://github.com/mockrunner/mockrunner/releases) - [Changelog](https://github.com/mockrunner/mockrunner/blob/master/releasenotes.txt) - [Commits](https://github.com/mockrunner/mockrunner/compare/mockrunner-2.0.4...mockrunner-2.0.6) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b656fdc8ba..a0d999f33b 100644 --- a/pom.xml +++ b/pom.xml @@ -282,7 +282,7 @@ com.mockrunner mockrunner-jdbc - 2.0.4 + 2.0.6 test From 1c89e3ffd91b056f9eec0fad4b6e51e8645d868d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2020 05:42:33 +0000 Subject: [PATCH 261/933] Bump mybatis from 3.5.5 to 3.5.6 Bumps [mybatis](https://github.com/mybatis/mybatis-3) from 3.5.5 to 3.5.6. - [Release notes](https://github.com/mybatis/mybatis-3/releases) - [Commits](https://github.com/mybatis/mybatis-3/compare/mybatis-3.5.5...mybatis-3.5.6) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14ca364431..336deffbe4 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.5 + 3.5.6 5.2.9.RELEASE 4.2.4.RELEASE org.mybatis.spring From 7f3c870c76f356bb870852d0eded327536548f3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2020 05:11:42 +0000 Subject: [PATCH 262/933] Bump mockito-core from 3.5.13 to 3.5.15 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.13 to 3.5.15. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.13...v3.5.15) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 336deffbe4..e3f65f81c4 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.13 + 3.5.15 test From 9463ca3ee55b6aba30414693e4901cfc78f1e592 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2020 06:29:18 +0000 Subject: [PATCH 263/933] Bump assertj-core from 3.17.2 to 3.18.0 Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.17.2 to 3.18.0. - [Release notes](https://github.com/assertj/assertj-core/releases) - [Commits](https://github.com/assertj/assertj-core/compare/assertj-core-3.17.2...assertj-core-3.18.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e3f65f81c4..d506b2eb7e 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.17.2 + 3.18.0 test From 9fed43496822321b9444a3632f91d86f819022d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2020 05:49:08 +0000 Subject: [PATCH 264/933] Bump mockito-core from 3.5.15 to 3.6.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.5.15 to 3.6.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.5.15...v3.6.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d506b2eb7e..40f3efb3cf 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.5.15 + 3.6.0 test From caaf056fd194d30006ab4eea4dab286805f45546 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2020 05:45:07 +0000 Subject: [PATCH 265/933] Bump spring-batch.version from 4.2.4.RELEASE to 4.3.0 Bumps `spring-batch.version` from 4.2.4.RELEASE to 4.3.0. Updates `spring-batch-infrastructure` from 4.2.4.RELEASE to 4.3.0 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.2.4.RELEASE...4.3.0) Updates `spring-batch-core` from 4.2.4.RELEASE to 4.3.0 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.2.4.RELEASE...4.3.0) Updates `spring-batch-test` from 4.2.4.RELEASE to 4.3.0 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.2.4.RELEASE...4.3.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40f3efb3cf..518d2296e9 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.6 5.2.9.RELEASE - 4.2.4.RELEASE + 4.3.0 org.mybatis.spring 5.7.0 From 409f54e14497beb471a423051b518c14d4eb1725 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 9 Nov 2020 00:28:21 +0900 Subject: [PATCH 266/933] Support Spring 5.3 Fixes gh-540 --- pom.xml | 2 +- .../java/org/mybatis/spring/MyBatisExceptionTranslator.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 518d2296e9..4959166aea 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.6 - 5.2.9.RELEASE + 5.3.0 4.3.0 org.mybatis.spring diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index 1f917ff535..178f2b4b70 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -23,6 +23,7 @@ import org.apache.ibatis.exceptions.PersistenceException; import org.springframework.dao.DataAccessException; import org.springframework.dao.support.PersistenceExceptionTranslator; +import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator; import org.springframework.jdbc.support.SQLExceptionTranslator; import org.springframework.transaction.TransactionException; @@ -85,7 +86,10 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { } if (e.getCause() instanceof SQLException) { this.initExceptionTranslator(); - return this.exceptionTranslator.translate(e.getMessage() + "\n", null, (SQLException) e.getCause()); + String task = e.getMessage() + "\n"; + SQLException se = (SQLException) e.getCause(); + DataAccessException dae = this.exceptionTranslator.translate(task, null, se); + return dae != null ? dae : new UncategorizedSQLException(task, null, se); } else if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } From 8989a0125b274f6fe378a08d76384aed467f3342 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 9 Nov 2020 09:12:00 +0900 Subject: [PATCH 267/933] Drop openjdk14 on Travis CI Fixes gh-542 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a325b9e719..5db1abbe78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: java jdk: - openjdk-ea - openjdk15 - - openjdk14 - openjdk11 - openjdk8 From d01f178781985ed01ead159425c44a2492531f6f Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 9 Nov 2020 09:17:31 +0900 Subject: [PATCH 268/933] Support CI with spring 5.2 and spring-batch 4.2 Fixes gh-543 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5db1abbe78..20eab5b845 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ jdk: script: - ./mvnw clean verify + - ./mvnw clean verify -Dspring.version=$(./travis/get_latest_version.sh spring-core 5.2) -Dspring-batch.version=$(./travis/get_latest_version.sh batch/spring-batch-core 4.2) - ./mvnw clean verify -Dspring.version=$(./travis/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./travis/get_latest_version.sh batch/spring-batch-core 4.1) after_success: From 72dc137897ef9afa6cef2dc966edc6265e19951a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2020 05:44:12 +0000 Subject: [PATCH 269/933] Bump spring.version from 5.3.0 to 5.3.1 Bumps `spring.version` from 5.3.0 to 5.3.1. Updates `spring-context` from 5.3.0 to 5.3.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.0...v5.3.1) Updates `spring-jdbc` from 5.3.0 to 5.3.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.0...v5.3.1) Updates `spring-test` from 5.3.0 to 5.3.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.0...v5.3.1) Updates `spring-web` from 5.3.0 to 5.3.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.0...v5.3.1) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4959166aea..271e5869d4 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.6 - 5.3.0 + 5.3.1 4.3.0 org.mybatis.spring From 0196ef6ca0f3171a11d53b4b958103b4a02f5c40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2020 05:44:23 +0000 Subject: [PATCH 270/933] Bump assertj-core from 3.18.0 to 3.18.1 Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.18.0 to 3.18.1. - [Release notes](https://github.com/assertj/assertj-core/releases) - [Commits](https://github.com/assertj/assertj-core/compare/assertj-core-3.18.0...assertj-core-3.18.1) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4959166aea..e3e9c7fecf 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.18.0 + 3.18.1 test From 1d0ae0564f549c77e95446c967e8944e229101fe Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 13 Sep 2020 18:43:26 -0400 Subject: [PATCH 271/933] [travis] Drop jdk ea --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 20eab5b845..fb747eb81b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: java jdk: - - openjdk-ea - openjdk15 - openjdk11 - openjdk8 From 21eb422682aa701ce36809d7a8e346fa2e7efc94 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 20 Sep 2020 21:50:31 -0400 Subject: [PATCH 272/933] [travis] Drop jdk 14 / add jdk 16 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fb747eb81b..523742bf69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: java jdk: + - openjdk16 - openjdk15 - openjdk11 - openjdk8 From 5ebc3d58c9d334d4966383d642ff49f044747b80 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 20 Sep 2020 21:50:41 -0400 Subject: [PATCH 273/933] [ci] Add license header to dependabot yml --- .github/dependabot.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2de9eee4c5..fab7b7fb71 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,19 @@ +# +# Copyright 2010-2020 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + version: 2 updates: - package-ecosystem: maven From db52f7d13a1693a30bc3a7f47cbbaafca21739a9 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sat, 14 Nov 2020 23:27:49 +0900 Subject: [PATCH 274/933] Non-logical changes made by maven plugins --- .../java/org/mybatis/spring/MyBatisExceptionTranslator.java | 2 +- .../mybatis/spring/mapper/MapperScannerConfigurerTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index 178f2b4b70..bf4b58386a 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -1,5 +1,5 @@ /** - * Copyright 2010-2019 the original author or authors. + * Copyright 2010-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index d62d1af27a..da455ea1a1 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -389,8 +389,8 @@ void testScanWithMapperFactoryBeanClass() { void testMapperBeanAttribute() { startContext(); - assertThat(applicationContext.getBeanDefinition("annotatedMapper").getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)) - .isEqualTo(AnnotatedMapper.class.getName()); + assertThat(applicationContext.getBeanDefinition("annotatedMapper") + .getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class.getName()); } private void setupSqlSessionFactory(String name) { From c3ea5411add0716154c223a5ccdbb57d35395a38 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sat, 14 Nov 2020 23:37:54 +0900 Subject: [PATCH 275/933] [maven-release-plugin] prepare release mybatis-spring-2.0.6 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 32011a3f44..ccec8af41d 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.6-SNAPSHOT + 2.0.6 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-2.0.6 GitHub Issue Management From b3701fe41c0ac58d58c58c7307513dfac09c4786 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sat, 14 Nov 2020 23:38:04 +0900 Subject: [PATCH 276/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ccec8af41d..22b0398d50 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.6 + 2.0.7-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-2.0.6 + HEAD GitHub Issue Management From a1ee9dd4847398fd1dab63aa68cc5a6548a840a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2020 05:12:30 +0000 Subject: [PATCH 277/933] Bump mockito-core from 3.6.0 to 3.6.28 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.6.0 to 3.6.28. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.6.0...v3.6.28) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 22b0398d50..c8577e14c3 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.6.0 + 3.6.28 test From 1da56ac43df83dfdc4f7f26232a60e85e827b370 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Dec 2020 05:41:50 +0000 Subject: [PATCH 278/933] Bump spring-batch.version from 4.3.0 to 4.3.1 Bumps `spring-batch.version` from 4.3.0 to 4.3.1. Updates `spring-batch-infrastructure` from 4.3.0 to 4.3.1 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.0...4.3.1) Updates `spring-batch-core` from 4.3.0 to 4.3.1 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.0...4.3.1) Updates `spring-batch-test` from 4.3.0 to 4.3.1 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.0...4.3.1) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c8577e14c3..40e91f316e 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.6 5.3.1 - 4.3.0 + 4.3.1 org.mybatis.spring 5.7.0 From 739d5abbd6f41118efe98c807e34e7151c012e1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Dec 2020 17:00:53 +0000 Subject: [PATCH 279/933] Bump spring.version from 5.3.1 to 5.3.2 Bumps `spring.version` from 5.3.1 to 5.3.2. Updates `spring-context` from 5.3.1 to 5.3.2 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.1...v5.3.2) Updates `spring-jdbc` from 5.3.1 to 5.3.2 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.1...v5.3.2) Updates `spring-test` from 5.3.1 to 5.3.2 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.1...v5.3.2) Updates `spring-web` from 5.3.1 to 5.3.2 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.1...v5.3.2) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40e91f316e..dcf6cf36dc 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.6 - 5.3.1 + 5.3.2 4.3.1 org.mybatis.spring From 603b293d25da76932e68ee4b9c0a80a17082f3aa Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 2 Dec 2020 09:49:49 -0500 Subject: [PATCH 280/933] [actions] Board github actions --- .github/dependabot.yml | 20 ++++++++-------- .github/workflows/ci.yaml | 39 +++++++++++++++++++++++++++++++ .github/workflows/sonar.yaml | 41 +++++++++++++++++++++++++++++++++ .github/workflows/sonatype.yaml | 38 ++++++++++++++++++++++++++++++ .mvn/extensions.xml | 25 ++++++++++++++++++++ {travis => .mvn}/settings.xml | 9 +++++--- travis/after_success.sh | 26 ++++++++------------- 7 files changed, 168 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/sonar.yaml create mode 100644 .github/workflows/sonatype.yaml create mode 100644 .mvn/extensions.xml rename {travis => .mvn}/settings.xml (83%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fab7b7fb71..89e6bd13e1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,17 +1,17 @@ # -# Copyright 2010-2020 the original author or authors. +# Copyright 2010-2020 the original author or authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # version: 2 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..a0978afc8e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,39 @@ +# +# Copyright 2010-2020 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: Java CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + java: [8, 11, 15, 16-ea] + fail-fast: false + max-parallel: 4 + name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Test with Maven + run: ./mvnw test -B -D"license.skip=true" diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml new file mode 100644 index 0000000000..b50607d729 --- /dev/null +++ b/.github/workflows/sonar.yaml @@ -0,0 +1,41 @@ +# +# Copyright 2010-2020 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: SonarCloud + +on: + push: + branches: + - master + +jobs: + build: + if: github.repository_owner == 'mybatis' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Analyze with SonarCloud + run: ./mvnw verify sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml new file mode 100644 index 0000000000..1ad95b8bf9 --- /dev/null +++ b/.github/workflows/sonatype.yaml @@ -0,0 +1,38 @@ +# +# Copyright 2010-2020 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: Sonatype + +on: + push: + branches: + - master + +jobs: + build: + if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Deploy to Sonatype + run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true + env: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 0000000000..80ed986bd5 --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,25 @@ + + + + + fr.jcgay.maven + maven-profiler + 3.0 + + diff --git a/travis/settings.xml b/.mvn/settings.xml similarity index 83% rename from travis/settings.xml rename to .mvn/settings.xml index cf46cedc9c..24b1b8f79e 100644 --- a/travis/settings.xml +++ b/.mvn/settings.xml @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - From 6a0073f95a342057b35fa5fb7553d36d9dee214c Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:01:33 -0400 Subject: [PATCH 309/933] [dependabot] Ignore libs we cannot use --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fab7b7fb71..fa3016f97d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -25,3 +25,9 @@ updates: - dependency-name: org.apache.derby:derby versions: - "> 10.14.2.0" + - dependency-name: org.hsqldb:hsqldb + versions: + - ">= 2.6.0" + - dependency-name: jakarta.servlet:jakarta.servlet-api + versions: + - ">= 5.0.0" From a7a01e497a5c203442611004b0bb6903e7ca6134 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:01:41 -0400 Subject: [PATCH 310/933] [pom] Bump hsqldb to 2.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f3b8608c07..d40836fcc0 100644 --- a/pom.xml +++ b/pom.xml @@ -210,7 +210,7 @@ org.hsqldb hsqldb - 2.5.1 + 2.5.2 test From d39df6812ad1695d03bd3e140e218a078d738e68 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:11:16 -0400 Subject: [PATCH 311/933] [actions] Add in separate process to run script --- .github/workflows/support.yaml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index dc590b7ccf..95e261c8e2 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -14,7 +14,7 @@ # limitations under the License. # -name: Java CI +name: Spring/Spring Batch Support on: [push, pull_request] @@ -37,7 +37,27 @@ jobs: with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - - name: Test with Maven Spring 5.2 support - run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.2) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2) - - name: Test with Maven Spring 5.1 support - run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1) + - uses: actions/github-script@v4 + id: spring51 + with: + script: ./scripts/get_latest_version.sh spring-core 5.1 + result-encoding: string + - uses: actions/github-script@v4 + id: springbatch41 + with: + script: ./scripts/get_latest_version.sh batch/spring-batch-core 4.1 + result-encoding: string + - uses: actions/github-script@v4 + id: spring52 + with: + script: ./scripts/get_latest_version.sh spring-core 5.2 + result-encoding: string + - uses: actions/github-script@v4 + id: springbatch42 + with: + script: ./scripts/get_latest_version.sh batch/spring-batch-core 4.2 + result-encoding: string + - name: Test with Spring 5.2 / Spring Batch 4.2 support + run: ./mvnw test -Dspring.version=${{steps.spring52.outputs.result}} -Dspring-batch.version=${{steps.springbatch42.outputs.result}} + - name: Test with Spring 5.1 / Spring Batch 4.1 support + run: ./mvnw test -Dspring.version=${{steps.spring51.outputs.result}} -Dspring-batch.version=${{steps.springbatch41.outputs.result}} From c2040b36ccb791f64afd1b1ceb914a67a8e0e01f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:12:26 -0400 Subject: [PATCH 312/933] [actions] Remove ./ in front of script runs --- .github/workflows/support.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index 95e261c8e2..b93ae7a48c 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -40,22 +40,22 @@ jobs: - uses: actions/github-script@v4 id: spring51 with: - script: ./scripts/get_latest_version.sh spring-core 5.1 + script: scripts/get_latest_version.sh spring-core 5.1 result-encoding: string - uses: actions/github-script@v4 id: springbatch41 with: - script: ./scripts/get_latest_version.sh batch/spring-batch-core 4.1 + script: scripts/get_latest_version.sh batch/spring-batch-core 4.1 result-encoding: string - uses: actions/github-script@v4 id: spring52 with: - script: ./scripts/get_latest_version.sh spring-core 5.2 + script: scripts/get_latest_version.sh spring-core 5.2 result-encoding: string - uses: actions/github-script@v4 id: springbatch42 with: - script: ./scripts/get_latest_version.sh batch/spring-batch-core 4.2 + script: scripts/get_latest_version.sh batch/spring-batch-core 4.2 result-encoding: string - name: Test with Spring 5.2 / Spring Batch 4.2 support run: ./mvnw test -Dspring.version=${{steps.spring52.outputs.result}} -Dspring-batch.version=${{steps.springbatch42.outputs.result}} From 2ecfbe049e9e80bb57ef23a2b506fcb60db0ca7e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:23:05 -0400 Subject: [PATCH 313/933] [actions] Reworking how to run script --- .github/workflows/support.yaml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index b93ae7a48c..9b02ddcd81 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -38,26 +38,34 @@ jobs: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - uses: actions/github-script@v4 - id: spring51 + id: set-result with: script: scripts/get_latest_version.sh spring-core 5.1 result-encoding: string + - name: Get result + run: echo "spring51=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - uses: actions/github-script@v4 - id: springbatch41 + id: set-result with: script: scripts/get_latest_version.sh batch/spring-batch-core 4.1 result-encoding: string + - name: Get result + run: echo "springbatch41=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - uses: actions/github-script@v4 - id: spring52 + id: set-result with: script: scripts/get_latest_version.sh spring-core 5.2 result-encoding: string + - name: Get result + run: echo "spring52=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - uses: actions/github-script@v4 - id: springbatch42 + id: set-result with: script: scripts/get_latest_version.sh batch/spring-batch-core 4.2 result-encoding: string + - name: Get result + run: echo "springbatch42=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - name: Test with Spring 5.2 / Spring Batch 4.2 support - run: ./mvnw test -Dspring.version=${{steps.spring52.outputs.result}} -Dspring-batch.version=${{steps.springbatch42.outputs.result}} + run: ./mvnw test -Dspring.version=${{ env.spring52 }} -Dspring-batch.version=${{ env.springbatch42 }} - name: Test with Spring 5.1 / Spring Batch 4.1 support - run: ./mvnw test -Dspring.version=${{steps.spring51.outputs.result}} -Dspring-batch.version=${{steps.springbatch41.outputs.result}} + run: ./mvnw test -Dspring.version=${{ env.spring51 }} -Dspring-batch.version=${{ env.springbatch41 }} From bd8b04266df1b7417130688b106285fd17f0d091 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:38:26 -0400 Subject: [PATCH 314/933] [actions] Rework the workflow for support spring items --- .github/workflows/support.yaml | 47 ++++++++++++---------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index 9b02ddcd81..83a3b4c24e 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -37,35 +37,22 @@ jobs: with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - - uses: actions/github-script@v4 - id: set-result - with: - script: scripts/get_latest_version.sh spring-core 5.1 - result-encoding: string - - name: Get result - run: echo "spring51=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - - uses: actions/github-script@v4 - id: set-result - with: - script: scripts/get_latest_version.sh batch/spring-batch-core 4.1 - result-encoding: string - - name: Get result - run: echo "springbatch41=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - - uses: actions/github-script@v4 - id: set-result - with: - script: scripts/get_latest_version.sh spring-core 5.2 - result-encoding: string - - name: Get result - run: echo "spring52=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV - - uses: actions/github-script@v4 - id: set-result - with: - script: scripts/get_latest_version.sh batch/spring-batch-core 4.2 - result-encoding: string - - name: Get result - run: echo "springbatch42=${{steps.set-result.outputs.result}}" >> $GITHUB_ENV + + - name: Set spring core 5.2 + id: spring52 + run: echo "::set-output name=version::$(./scripts/get_latest_version.sh spring-core 5.2)" + - name: Set spring batch 4.2 + id: springbatch42 + run: echo "::set-output name=version::$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2)" + + - name: Set spring core 5.1 + id: spring51 + run: echo "::set-output name=version::$(./scripts/get_latest_version.sh spring-core 5.1)" + - name: Set spring batch 4.1 + id: springbatch41 + run: echo "::set-output name=version::$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1)" + - name: Test with Spring 5.2 / Spring Batch 4.2 support - run: ./mvnw test -Dspring.version=${{ env.spring52 }} -Dspring-batch.version=${{ env.springbatch42 }} + run: ./mvnw test -Dspring.version=${{steps.spring52.outputs.version}} -Dspring-batch.version=${{steps.springbatch42.outputs.version}} - name: Test with Spring 5.1 / Spring Batch 4.1 support - run: ./mvnw test -Dspring.version=${{ env.spring51 }} -Dspring-batch.version=${{ env.springbatch41 }} + run: ./mvnw test -Dspring.version=${{steps.spring51.outputs.version}} -Dspring-batch.version=${{steps.springbatch41.outputs.version}} From 8099f2b29d918be3b844930216de2e7b21e291ca Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:41:07 -0400 Subject: [PATCH 315/933] [ci] Move the scripts --- .github/{workflows => }/scripts/get_latest_version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => }/scripts/get_latest_version.sh (100%) mode change 100755 => 100644 diff --git a/.github/workflows/scripts/get_latest_version.sh b/.github/scripts/get_latest_version.sh old mode 100755 new mode 100644 similarity index 100% rename from .github/workflows/scripts/get_latest_version.sh rename to .github/scripts/get_latest_version.sh From d6db4cc88e268f6abe8ac43561fd3ca137e4afb2 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:41:10 -0400 Subject: [PATCH 316/933] [chmod] Add executable permission --- .github/scripts/get_latest_version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/scripts/get_latest_version.sh diff --git a/.github/scripts/get_latest_version.sh b/.github/scripts/get_latest_version.sh old mode 100644 new mode 100755 From 35b98ad5451fe98ecb0e16a83f05d6d61332089f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:42:43 -0400 Subject: [PATCH 317/933] [ci] Move scripts again to root --- {.github/scripts => scripts}/get_latest_version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.github/scripts => scripts}/get_latest_version.sh (100%) mode change 100755 => 100644 diff --git a/.github/scripts/get_latest_version.sh b/scripts/get_latest_version.sh old mode 100755 new mode 100644 similarity index 100% rename from .github/scripts/get_latest_version.sh rename to scripts/get_latest_version.sh From b17eb81e868ccd78058ffebcba36db13aab89a03 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:42:46 -0400 Subject: [PATCH 318/933] [chmod] Add executable permission --- scripts/get_latest_version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/get_latest_version.sh diff --git a/scripts/get_latest_version.sh b/scripts/get_latest_version.sh old mode 100644 new mode 100755 From 41f147c972098986b30058057aa583576272176c Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:44:46 -0400 Subject: [PATCH 319/933] [ci] Clean it up as originally setup --- .github/workflows/support.yaml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index 83a3b4c24e..e008fb8e81 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -37,22 +37,7 @@ jobs: with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - - - name: Set spring core 5.2 - id: spring52 - run: echo "::set-output name=version::$(./scripts/get_latest_version.sh spring-core 5.2)" - - name: Set spring batch 4.2 - id: springbatch42 - run: echo "::set-output name=version::$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2)" - - - name: Set spring core 5.1 - id: spring51 - run: echo "::set-output name=version::$(./scripts/get_latest_version.sh spring-core 5.1)" - - name: Set spring batch 4.1 - id: springbatch41 - run: echo "::set-output name=version::$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1)" - - name: Test with Spring 5.2 / Spring Batch 4.2 support - run: ./mvnw test -Dspring.version=${{steps.spring52.outputs.version}} -Dspring-batch.version=${{steps.springbatch42.outputs.version}} + run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.2) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2) - name: Test with Spring 5.1 / Spring Batch 4.1 support - run: ./mvnw test -Dspring.version=${{steps.spring51.outputs.version}} -Dspring-batch.version=${{steps.springbatch41.outputs.version}} + run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1) From 7dbf5d737147c8f921b2e1df9d92163d06b5f3a9 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:47:14 -0400 Subject: [PATCH 320/933] [actions] Fix support for windows --- .github/workflows/support.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index e008fb8e81..de81aa154f 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -38,6 +38,6 @@ jobs: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - name: Test with Spring 5.2 / Spring Batch 4.2 support - run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.2) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2) + run: ./mvnw test -D"spring.version=$(./scripts/get_latest_version.sh spring-core 5.2)" -Dspring-batch.version="$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2)" - name: Test with Spring 5.1 / Spring Batch 4.1 support - run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1) + run: ./mvnw test -D"spring.version=$(./scripts/get_latest_version.sh spring-core 5.1)" -Dspring-batch.version="$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1)" From b5e18924a83a34775bf25bbca869e9692e68005d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:52:58 -0400 Subject: [PATCH 321/933] [support] Remove windows from support builds scripts under the hood are bash so those don't work on windows. --- .github/workflows/support.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index de81aa154f..960d46410d 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -23,7 +23,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [ubuntu-latest, macOS-latest] java: [8] distribution: ['adopt'] fail-fast: false @@ -38,6 +38,6 @@ jobs: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - name: Test with Spring 5.2 / Spring Batch 4.2 support - run: ./mvnw test -D"spring.version=$(./scripts/get_latest_version.sh spring-core 5.2)" -Dspring-batch.version="$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2)" + run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.2) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2) - name: Test with Spring 5.1 / Spring Batch 4.1 support - run: ./mvnw test -D"spring.version=$(./scripts/get_latest_version.sh spring-core 5.1)" -Dspring-batch.version="$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1)" + run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1) From 2f1bc9947791decca5025ebe676553887ad21a67 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 8 May 2021 17:57:35 -0400 Subject: [PATCH 322/933] [dependabot] Add transaction api for jakarta renames to ignored --- .github/dependabot.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fa3016f97d..da6989d28b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -31,3 +31,6 @@ updates: - dependency-name: jakarta.servlet:jakarta.servlet-api versions: - ">= 5.0.0" + - dependency-name: jakarta.transaction:jakarta.transaction-api + versions: + - ">= 2.0.0" From 6039072b54434141008b67e6cbcf4e37bec3f17a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 05:04:21 +0000 Subject: [PATCH 323/933] Bump byteman-bmunit from 4.0.14 to 4.0.15 Bumps byteman-bmunit from 4.0.14 to 4.0.15. Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d40836fcc0..d393121b79 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.jboss.byteman byteman-bmunit - 4.0.14 + 4.0.15 test From 7e54428229243603dd0af2a8c2c7f43fd9dc360d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 May 2021 05:21:51 +0000 Subject: [PATCH 324/933] Bump spring.version from 5.3.6 to 5.3.7 Bumps `spring.version` from 5.3.6 to 5.3.7. Updates `spring-context` from 5.3.6 to 5.3.7 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.6...v5.3.7) Updates `spring-jdbc` from 5.3.6 to 5.3.7 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.6...v5.3.7) Updates `spring-test` from 5.3.6 to 5.3.7 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.6...v5.3.7) Updates `spring-web` from 5.3.6 to 5.3.7 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.6...v5.3.7) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d393121b79..ae85222708 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.6 + 5.3.7 4.3.2 org.mybatis.spring From cc69b9bde8435b5c9aca3256ec9ef37ceddb2e16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 May 2021 05:22:00 +0000 Subject: [PATCH 325/933] Bump mockito-core from 3.9.0 to 3.10.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.9.0 to 3.10.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.9.0...v3.10.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d393121b79..5aaddc8461 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.9.0 + 3.10.0 test From f3d6557911051ffb6afa7419c73bc5b9a5515453 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 May 2021 05:47:06 +0000 Subject: [PATCH 326/933] Bump junit-jupiter-engine from 5.7.1 to 5.7.2 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.7.1...r5.7.2) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6318f40e8..d48982c831 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.3.2 org.mybatis.spring - 5.7.1 + 5.7.2 From 68a8ec963aaf72e74528807eca1994a856ace6e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 05:13:57 +0000 Subject: [PATCH 327/933] Bump spring-batch.version from 4.3.2 to 4.3.3 Bumps `spring-batch.version` from 4.3.2 to 4.3.3. Updates `spring-batch-infrastructure` from 4.3.2 to 4.3.3 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.2...4.3.3) Updates `spring-batch-core` from 4.3.2 to 4.3.3 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.2...4.3.3) Updates `spring-batch-test` from 4.3.2 to 4.3.3 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.2...4.3.3) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d48982c831..3207249542 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.7 5.3.7 - 4.3.2 + 4.3.3 org.mybatis.spring 5.7.2 From 686fb0667b4f3c158fb9650161f2b5a1cac10384 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Jun 2021 05:27:39 +0000 Subject: [PATCH 328/933] Bump mockito-core from 3.10.0 to 3.11.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.10.0 to 3.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.10.0...v3.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3207249542..8a9358ca8c 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.10.0 + 3.11.0 test From 6ce56ebb08ad717e131d5b50cc0dd95e98449bb5 Mon Sep 17 00:00:00 2001 From: Runrioter Wung Date: Tue, 8 Jun 2021 18:44:16 +0400 Subject: [PATCH 329/933] fix markdown link fix markdown link --- src/site/markdown/mappers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/markdown/mappers.md b/src/site/markdown/mappers.md index 7153f7385d..b6cfec037d 100644 --- a/src/site/markdown/mappers.md +++ b/src/site/markdown/mappers.md @@ -45,7 +45,7 @@ A mapper is registered to Spring by including a `MapperFactoryBean` in your XML ``` If the UserMapper has a corresponding MyBatis XML mapper file in the same classpath location as the mapper interface, it will be parsed automatically by the `MapperFactoryBean`. -There is no need to specify the mapper in a MyBatis configuration file unless the mapper XML files are in a different classpath location. See the `SqlSessionFactoryBean`'s `[configLocation](factorybean.html)` property for more information. +There is no need to specify the mapper in a MyBatis configuration file unless the mapper XML files are in a different classpath location. See the `SqlSessionFactoryBean`'s [`configLocation`](factorybean.html) property for more information. Note that `MapperFactoryBean` requires either an `SqlSessionFactory` or an `SqlSessionTemplate`. These can be set through the respective `sqlSessionFactory` and `sqlSessionTemplate` properties. If both properties are set, the `SqlSessionFactory` is ignored. Since the `SqlSessionTemplate` is required to have a session factory set, that factory will be used by `MapperFactoryBean`. From f55fbf6a5b189a0e85b9c4dde2b6db3da47e6fd5 Mon Sep 17 00:00:00 2001 From: wangshuai Date: Tue, 8 Jun 2021 19:57:43 +0400 Subject: [PATCH 330/933] fix: typo --- src/site/es/markdown/sample.md | 2 +- src/site/ja/markdown/sample.md | 2 +- src/site/ko/markdown/sample.md | 2 +- src/site/markdown/sample.md | 2 +- src/site/zh/markdown/sample.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/site/es/markdown/sample.md b/src/site/es/markdown/sample.md index 2f01bab236..077d525b77 100644 --- a/src/site/es/markdown/sample.md +++ b/src/site/es/markdown/sample.md @@ -52,7 +52,7 @@ We will see different ways to find the mapper interface, register it to Spring a | Sample test | Description | | --- | --- | | `SampleMapperTest.java` | Shows you the base configuration based on a `MapperFactoryBean` that will dynamically build an implementation for `UserMapper` | -| `ampleScannerTest.java` | Shows how to use the `MapperScannerConfigurer` so all the mappers in a project are autodiscovered. | +| `SampleScannerTest.java` | Shows how to use the `MapperScannerConfigurer` so all the mappers in a project are autodiscovered. | | `SampleSqlSessionTest.java` | Shows how to hand code a DAO using a Spring managed `SqlSession` and providing your own implementation `UserDaoImpl.java`. | | `SampleEnableTest.java` | Shows how to use Spring's `@Configuration` with the `@MapperScann` annotation so mappers are autodiscovered. | | `SampleNamespaceTest.java` | Shows how to use the custom MyBatis XML namespace. | diff --git a/src/site/ja/markdown/sample.md b/src/site/ja/markdown/sample.md index 2f01bab236..077d525b77 100644 --- a/src/site/ja/markdown/sample.md +++ b/src/site/ja/markdown/sample.md @@ -52,7 +52,7 @@ We will see different ways to find the mapper interface, register it to Spring a | Sample test | Description | | --- | --- | | `SampleMapperTest.java` | Shows you the base configuration based on a `MapperFactoryBean` that will dynamically build an implementation for `UserMapper` | -| `ampleScannerTest.java` | Shows how to use the `MapperScannerConfigurer` so all the mappers in a project are autodiscovered. | +| `SampleScannerTest.java` | Shows how to use the `MapperScannerConfigurer` so all the mappers in a project are autodiscovered. | | `SampleSqlSessionTest.java` | Shows how to hand code a DAO using a Spring managed `SqlSession` and providing your own implementation `UserDaoImpl.java`. | | `SampleEnableTest.java` | Shows how to use Spring's `@Configuration` with the `@MapperScann` annotation so mappers are autodiscovered. | | `SampleNamespaceTest.java` | Shows how to use the custom MyBatis XML namespace. | diff --git a/src/site/ko/markdown/sample.md b/src/site/ko/markdown/sample.md index 0b426bfd6d..be4ae7a1c0 100644 --- a/src/site/ko/markdown/sample.md +++ b/src/site/ko/markdown/sample.md @@ -51,7 +51,7 @@ public interface UserMapper { | 샘플 테스트 | 설명 | | --- | --- | | `SampleMapperTest.java` | `UserMapper` 구현체를 동적으로 빌드 할 `MapperFactoryBean`에 기반한 기본 구성을 보여준다. | -| `ampleScannerTest.java` | `MapperScannerConfigurer` 를 사용하여 어떻게 프로젝트의 모든 매퍼들을 자동으로 검색되도록 하는 방법을 보여준다. | +| `SampleScannerTest.java` | `MapperScannerConfigurer` 를 사용하여 어떻게 프로젝트의 모든 매퍼들을 자동으로 검색되도록 하는 방법을 보여준다. | | `SampleSqlSessionTest.java` | Spring에서 관리하는 `SqlSession`을 사용하여 DAO를 코딩하고 자체적인 구현체인 `UserDaoImpl.java` 를 제공하는 방법을 보여준다. | | `SampleEnableTest.java` | 스프링의 `@Configuration`과 `@MapperScann` annotation을 함께 사용하여 매퍼를 자동으로 검색하는 방법을 보여준다. | | `SampleNamespaceTest.java` | 커스텀 MyBatis XML 네임스페이스를 사용하는 방법을 보여준다. | diff --git a/src/site/markdown/sample.md b/src/site/markdown/sample.md index 2cf2703019..698948e146 100644 --- a/src/site/markdown/sample.md +++ b/src/site/markdown/sample.md @@ -52,7 +52,7 @@ We will see different ways to find the mapper interface, register it to Spring a | Sample test | Description | | --- | --- | | `SampleMapperTest.java` | Shows you the base configuration based on a `MapperFactoryBean` that will dynamically build an implementation for `UserMapper` | -| `ampleScannerTest.java` | Shows how to use the `MapperScannerConfigurer` so all the mappers in a project are autodiscovered. | +| `SampleScannerTest.java` | Shows how to use the `MapperScannerConfigurer` so all the mappers in a project are autodiscovered. | | `SampleSqlSessionTest.java` | Shows how to hand code a DAO using a Spring managed `SqlSession` and providing your own implementation `UserDaoImpl.java`. | | `SampleEnableTest.java` | Shows how to use Spring's `@Configuration` with the `@MapperScann` annotation so mappers are autodiscovered. | | `SampleNamespaceTest.java` | Shows how to use the custom MyBatis XML namespace. | diff --git a/src/site/zh/markdown/sample.md b/src/site/zh/markdown/sample.md index 0a2e9f2691..0c2a65b1d2 100644 --- a/src/site/zh/markdown/sample.md +++ b/src/site/zh/markdown/sample.md @@ -50,7 +50,7 @@ public interface UserMapper { | 样例测试 | 描述 | | --- | --- | | `SampleMapperTest.java` | 演示基于 `MapperFactoryBean` 的基本配置,这将动态构建 `UserMapper` 的一个实现。 | -| `ampleScannerTest.java` | 演示如何使用 `MapperScannerConfigurer` 来自动发现项目中所有的映射器。 | +| `SampleScannerTest.java` | 演示如何使用 `MapperScannerConfigurer` 来自动发现项目中所有的映射器。 | | `SampleSqlSessionTest.java` | 演示如何基于 Spring 管理的 `SqlSession` 手动编写 DAO,并在 `UserDaoImpl.java` 中提供你自己的实现。 | | `SampleEnableTest.java` | 演示如何使用 Spring 的 `@Configuration` 和 `@MapperScann` 注解来自动发现 mappers. | | `SampleNamespaceTest.java` | 演示如何使用自定义 MyBatis XML 命名空间. | From 26ca0000676effd395fe8e3c475fb8f34860b2c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Jun 2021 05:04:15 +0000 Subject: [PATCH 331/933] Bump spring.version from 5.3.7 to 5.3.8 Bumps `spring.version` from 5.3.7 to 5.3.8. Updates `spring-context` from 5.3.7 to 5.3.8 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.7...v5.3.8) Updates `spring-jdbc` from 5.3.7 to 5.3.8 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.7...v5.3.8) Updates `spring-test` from 5.3.7 to 5.3.8 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.7...v5.3.8) Updates `spring-web` from 5.3.7 to 5.3.8 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.7...v5.3.8) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8a9358ca8c..e3a81d6f55 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.7 + 5.3.8 4.3.3 org.mybatis.spring From 46b413450d41a608091e98d7f723ca8ad8748bf4 Mon Sep 17 00:00:00 2001 From: 4423 Date: Fri, 11 Jun 2021 18:35:55 +0900 Subject: [PATCH 332/933] Fix typo --- src/site/ja/markdown/factorybean.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/ja/markdown/factorybean.md b/src/site/ja/markdown/factorybean.md index f1fef7443c..4a4022ba52 100644 --- a/src/site/ja/markdown/factorybean.md +++ b/src/site/ja/markdown/factorybean.md @@ -38,7 +38,7 @@ public class MyBatisConfig { `SqlSessionFactory` で必須のプロパティは JDBC の `DataSource` のみです。 どのような `DataSource` でも構いません。Spring でデータベース接続を定義する通常の手順で定義してください。 `configLocation` は、MyBatis の XML 設定ファイルの場所を指定する際に使用します。これは、例えば基になる MyBatis の設定の一部を変更したい場合などに必要となります。 -よくあるのは `>settings>` や `` などの設定です。 +よくあるのは `` や `` などの設定です。 ここで指定する設定ファイルは、完全な MyBatis 設定ファイルである必要はありません。 環境、データソース、MyBatis のトランザクションマネージャーに関する設定は**無視されます**。 `SqlSessionFactoryBean` は、独自にカスタマイズした MyBatis `Environment` を生成し、必要に応じてこれらの値を設定するようになっています。 From 6e268583ce770a2dd54d49ae0ed4a9d6c52b8368 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 05:59:33 +0000 Subject: [PATCH 333/933] Bump mockito-core from 3.11.0 to 3.11.1 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.11.0 to 3.11.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.11.0...v3.11.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e3a81d6f55..89850b324d 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.11.0 + 3.11.1 test From 09222e7fbceaee9ba45950b6765ce05eaedc983d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Jun 2021 07:01:22 +0000 Subject: [PATCH 334/933] Bump byteman-bmunit from 4.0.15 to 4.0.16 Bumps byteman-bmunit from 4.0.15 to 4.0.16. --- updated-dependencies: - dependency-name: org.jboss.byteman:byteman-bmunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89850b324d..9974f1e5f1 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.jboss.byteman byteman-bmunit - 4.0.15 + 4.0.16 test From 968ea4cc0ba458228030e121f727eb40ef9a5542 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Jun 2021 07:01:25 +0000 Subject: [PATCH 335/933] Bump assertj-core from 3.19.0 to 3.20.1 Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.19.0 to 3.20.1. - [Release notes](https://github.com/assertj/assertj-core/releases) - [Commits](https://github.com/assertj/assertj-core/compare/assertj-core-3.19.0...assertj-core-3.20.1) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89850b324d..39040a9ca3 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.19.0 + 3.20.1 test From bcef2b1aec6cc75bf3aab8bb7f314fccf8fc4852 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Jun 2021 07:01:16 +0000 Subject: [PATCH 336/933] Bump slf4j-simple from 1.7.30 to 1.7.31 Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 1.7.30 to 1.7.31. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/commits) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89850b324d..431dcb3418 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ org.slf4j slf4j-simple - 1.7.30 + 1.7.31 test From 10b0fdd16c7bf42d7137b599765b3111166e5c54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Jun 2021 07:01:46 +0000 Subject: [PATCH 337/933] Bump assertj-core from 3.20.1 to 3.20.2 Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.20.1 to 3.20.2. - [Release notes](https://github.com/assertj/assertj-core/releases) - [Commits](https://github.com/assertj/assertj-core/compare/assertj-core-3.20.1...assertj-core-3.20.2) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 708d6a2b10..fd8ed8afb1 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.20.1 + 3.20.2 test From 180ddd5d6705f440766d139d68df132e69eac924 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Jun 2021 07:01:22 +0000 Subject: [PATCH 338/933] Bump mockito-core from 3.11.1 to 3.11.2 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.11.1 to 3.11.2. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.11.1...v3.11.2) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd8ed8afb1..905ce5c46d 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.11.1 + 3.11.2 test From fbbf5b45529baf194a8110d6603ac70311208fa3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jul 2021 07:01:30 +0000 Subject: [PATCH 339/933] Bump spring.version from 5.3.8 to 5.3.9 Bumps `spring.version` from 5.3.8 to 5.3.9. Updates `spring-context` from 5.3.8 to 5.3.9 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.8...v5.3.9) Updates `spring-jdbc` from 5.3.8 to 5.3.9 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.8...v5.3.9) Updates `spring-test` from 5.3.8 to 5.3.9 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.8...v5.3.9) Updates `spring-web` from 5.3.8 to 5.3.9 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.8...v5.3.9) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 905ce5c46d..a5adb6188d 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.8 + 5.3.9 4.3.3 org.mybatis.spring From f0a0ae8ddf306d1cde133ef13a19ebcffd2a6266 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jul 2021 07:01:21 +0000 Subject: [PATCH 340/933] Bump slf4j-simple from 1.7.31 to 1.7.32 Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 1.7.31 to 1.7.32. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/commits) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a5adb6188d..df476f1c84 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ org.slf4j slf4j-simple - 1.7.31 + 1.7.32 test From 37c05230173c6124a2ec160e082225150c0e2d30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Aug 2021 07:01:34 +0000 Subject: [PATCH 341/933] Bump mockito-core from 3.11.2 to 3.12.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.11.2 to 3.12.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.11.2...v3.12.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index df476f1c84..9213925106 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.11.2 + 3.12.0 test From 9acdb8df0d6c1fce2f056210d0474609f9adab50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Aug 2021 07:01:36 +0000 Subject: [PATCH 342/933] Bump maven-profiler from 3.0 to 3.1.1 Bumps [maven-profiler](https://github.com/jcgay/maven-profiler) from 3.0 to 3.1.1. - [Release notes](https://github.com/jcgay/maven-profiler/releases) - [Changelog](https://github.com/jcgay/maven-profiler/blob/master/CHANGELOG.md) - [Commits](https://github.com/jcgay/maven-profiler/compare/v3.0...v3.1.1) --- updated-dependencies: - dependency-name: fr.jcgay.maven:maven-profiler dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .mvn/extensions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 80ed986bd5..60074e2013 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -20,6 +20,6 @@ fr.jcgay.maven maven-profiler - 3.0 + 3.1.1 From bf4602416a680fa4a69621d59af5f4d08ee53eda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Aug 2021 07:01:39 +0000 Subject: [PATCH 343/933] Bump mockito-core from 3.12.0 to 3.12.1 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.0 to 3.12.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.0...v3.12.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9213925106..47b9598cdd 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.12.0 + 3.12.1 test From a871313398f78a6d51f065594ca849f10015aad9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Aug 2021 07:01:59 +0000 Subject: [PATCH 344/933] Bump mockito-core from 3.12.1 to 3.12.3 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.1 to 3.12.3. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.1...v3.12.3) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47b9598cdd..8299397b93 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.12.1 + 3.12.3 test From dc67e553878bbbe7313602c990cf2be9d432bd45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Aug 2021 07:01:23 +0000 Subject: [PATCH 345/933] Bump mockito-core from 3.12.3 to 3.12.4 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.3 to 3.12.4. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.3...v3.12.4) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8299397b93..8946846eb4 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.12.3 + 3.12.4 test From f7283ad78a8dc52aa46abc6525652ba6b9316042 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Sep 2021 07:01:50 +0000 Subject: [PATCH 346/933] Bump byteman-bmunit from 4.0.16 to 4.0.17 Bumps byteman-bmunit from 4.0.16 to 4.0.17. --- updated-dependencies: - dependency-name: org.jboss.byteman:byteman-bmunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8946846eb4..21c9bbd9f4 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.jboss.byteman byteman-bmunit - 4.0.16 + 4.0.17 test From 6b0c69aa633fa2e42da050259dff1e415221c051 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 07:01:46 +0000 Subject: [PATCH 347/933] Bump junit-jupiter-engine from 5.7.2 to 5.8.0 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.7.2 to 5.8.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.7.2...r5.8.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 21c9bbd9f4..a71734650f 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.3.3 org.mybatis.spring - 5.7.2 + 5.8.0 From 6bd851818456ed9bed9f825a4911deaf98c33beb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Sep 2021 07:01:35 +0000 Subject: [PATCH 348/933] Bump spring.version from 5.3.9 to 5.3.10 Bumps `spring.version` from 5.3.9 to 5.3.10. Updates `spring-context` from 5.3.9 to 5.3.10 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.9...v5.3.10) Updates `spring-jdbc` from 5.3.9 to 5.3.10 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.9...v5.3.10) Updates `spring-test` from 5.3.9 to 5.3.10 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.9...v5.3.10) Updates `spring-web` from 5.3.9 to 5.3.10 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.9...v5.3.10) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a71734650f..ceaad75571 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.9 + 5.3.10 4.3.3 org.mybatis.spring From a0b4cfc973a615e99ef32797addc4f925050aa90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Sep 2021 07:02:00 +0000 Subject: [PATCH 349/933] Bump assertj-core from 3.20.2 to 3.21.0 Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.20.2 to 3.21.0. - [Release notes](https://github.com/assertj/assertj-core/releases) - [Commits](https://github.com/assertj/assertj-core/compare/assertj-core-3.20.2...assertj-core-3.21.0) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ceaad75571..cd02fb7b81 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.20.2 + 3.21.0 test From 5a12ab827284658a738ac3d1f58020a68fc956a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 07:01:44 +0000 Subject: [PATCH 350/933] Bump junit-jupiter-engine from 5.8.0 to 5.8.1 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.8.0 to 5.8.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.0...r5.8.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cd02fb7b81..ac4d8919d7 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.3.3 org.mybatis.spring - 5.8.0 + 5.8.1 From 67ecfc865ea649f1b1c12c58fa45d15e9f468016 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 07:02:11 +0000 Subject: [PATCH 351/933] Bump mockito-core from 3.12.4 to 4.0.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.4 to 4.0.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.4...v4.0.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ac4d8919d7..487aa3ec94 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 3.12.4 + 4.0.0 test From 8b94d36dfd6d21cfd0cc2f20f8008ab4bc8674b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Oct 2021 07:01:48 +0000 Subject: [PATCH 352/933] Bump spring.version from 5.3.10 to 5.3.11 Bumps `spring.version` from 5.3.10 to 5.3.11. Updates `spring-context` from 5.3.10 to 5.3.11 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.10...v5.3.11) Updates `spring-jdbc` from 5.3.10 to 5.3.11 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.10...v5.3.11) Updates `spring-test` from 5.3.10 to 5.3.11 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.10...v5.3.11) Updates `spring-web` from 5.3.10 to 5.3.11 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.10...v5.3.11) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 487aa3ec94..07545ce7a4 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.10 + 5.3.11 4.3.3 org.mybatis.spring From b41379f57bf25877f9f2c8a69d11f4b9159d8be3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Oct 2021 07:01:45 +0000 Subject: [PATCH 353/933] Bump spring.version from 5.3.11 to 5.3.12 Bumps `spring.version` from 5.3.11 to 5.3.12. Updates `spring-context` from 5.3.11 to 5.3.12 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.11...v5.3.12) Updates `spring-jdbc` from 5.3.11 to 5.3.12 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.11...v5.3.12) Updates `spring-test` from 5.3.11 to 5.3.12 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.11...v5.3.12) Updates `spring-web` from 5.3.11 to 5.3.12 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.11...v5.3.12) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 07545ce7a4..08c7ef4ed4 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.11 + 5.3.12 4.3.3 org.mybatis.spring From 7e93fdcf4b6bd8dbfffa494a1faaff68a0b773ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Nov 2021 07:01:44 +0000 Subject: [PATCH 354/933] Bump spring.version from 5.3.12 to 5.3.13 Bumps `spring.version` from 5.3.12 to 5.3.13. Updates `spring-context` from 5.3.12 to 5.3.13 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.12...v5.3.13) Updates `spring-jdbc` from 5.3.12 to 5.3.13 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.12...v5.3.13) Updates `spring-test` from 5.3.12 to 5.3.13 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.12...v5.3.13) Updates `spring-web` from 5.3.12 to 5.3.13 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.12...v5.3.13) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 08c7ef4ed4..0d287e7eca 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.7 - 5.3.12 + 5.3.13 4.3.3 org.mybatis.spring From bffc5b9d7c017f1d5ac7ae5f8e949fc4873f42e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Nov 2021 07:01:21 +0000 Subject: [PATCH 355/933] Bump spring-batch.version from 4.3.3 to 4.3.4 Bumps `spring-batch.version` from 4.3.3 to 4.3.4. Updates `spring-batch-infrastructure` from 4.3.3 to 4.3.4 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.3...4.3.4) Updates `spring-batch-core` from 4.3.3 to 4.3.4 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.3...4.3.4) Updates `spring-batch-test` from 4.3.3 to 4.3.4 - [Release notes](https://github.com/spring-projects/spring-batch/releases) - [Commits](https://github.com/spring-projects/spring-batch/compare/4.3.3...4.3.4) --- updated-dependencies: - dependency-name: org.springframework.batch:spring-batch-infrastructure dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework.batch:spring-batch-core dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework.batch:spring-batch-test dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d287e7eca..4af16eb089 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.7 5.3.13 - 4.3.3 + 4.3.4 org.mybatis.spring 5.8.1 From 0ddf3b0bd78c7c7464603c2f3cfdfc235bfe2e5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Nov 2021 07:01:39 +0000 Subject: [PATCH 356/933] Bump mockito-core from 4.0.0 to 4.1.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.0.0 to 4.1.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.0.0...v4.1.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4af16eb089..223bdeaf99 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 4.0.0 + 4.1.0 test From 1aceed5c2fea20dc46b2b3edca71ded0e0f3bd4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Nov 2021 07:01:38 +0000 Subject: [PATCH 357/933] Bump byteman-bmunit from 4.0.17 to 4.0.18 Bumps byteman-bmunit from 4.0.17 to 4.0.18. --- updated-dependencies: - dependency-name: org.jboss.byteman:byteman-bmunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 223bdeaf99..0db54afbeb 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ org.jboss.byteman byteman-bmunit - 4.0.17 + 4.0.18 test From 2d72d7e4837f9ceee254a2614cb613c3c641cad8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Nov 2021 07:02:15 +0000 Subject: [PATCH 358/933] Bump junit-jupiter-engine from 5.8.1 to 5.8.2 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.8.1 to 5.8.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.1...r5.8.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0db54afbeb..0b066b56d4 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.3.4 org.mybatis.spring - 5.8.1 + 5.8.2 From 7cc024c929bd122cf1a8eb954fcacb36e9ccb153 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Dec 2021 07:02:14 +0000 Subject: [PATCH 359/933] Bump mybatis from 3.5.7 to 3.5.8 Bumps [mybatis](https://github.com/mybatis/mybatis-3) from 3.5.7 to 3.5.8. - [Release notes](https://github.com/mybatis/mybatis-3/releases) - [Commits](https://github.com/mybatis/mybatis-3/compare/mybatis-3.5.7...mybatis-3.5.8) --- updated-dependencies: - dependency-name: org.mybatis:mybatis dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b066b56d4..c0ce09f550 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.7 + 3.5.8 5.3.13 4.3.4 org.mybatis.spring From bc90069054e3bbeb2b0a1438a9db6fdbca595807 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Dec 2021 07:01:47 +0000 Subject: [PATCH 360/933] Bump spring.version from 5.3.13 to 5.3.14 Bumps `spring.version` from 5.3.13 to 5.3.14. Updates `spring-context` from 5.3.13 to 5.3.14 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.13...v5.3.14) Updates `spring-jdbc` from 5.3.13 to 5.3.14 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.13...v5.3.14) Updates `spring-test` from 5.3.13 to 5.3.14 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.13...v5.3.14) Updates `spring-web` from 5.3.13 to 5.3.14 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.13...v5.3.14) --- updated-dependencies: - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.springframework:spring-web dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c0ce09f550..bb23e44e63 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.8 - 5.3.13 + 5.3.14 4.3.4 org.mybatis.spring From 3e660bf254493161ffee80bf334e7a49f9359deb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Dec 2021 07:01:53 +0000 Subject: [PATCH 361/933] Bump mockito-core from 4.1.0 to 4.2.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.1.0 to 4.2.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.1.0...v4.2.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c0ce09f550..12b341d045 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 4.1.0 + 4.2.0 test From d476e517068135c0b4b1a5db3fc9e4f6296a4bd0 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 19 Dec 2021 22:05:57 +0900 Subject: [PATCH 362/933] Modify standard CI setting for ignoring on compatibility-check-spring6 branch See gh-634 --- .github/workflows/ci.yaml | 6 +++++- .github/workflows/coveralls.yaml | 6 +++++- .github/workflows/support.yaml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 05f33179d6..2f90dfb9d0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,11 @@ name: Java CI -on: [push, pull_request] +on: + push: + branches-ignore: + - 'compatibility-check-spring6' + pull_request: jobs: test: diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index dc298ee01b..8e04d00721 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -16,7 +16,11 @@ name: Coveralls -on: [push, pull_request] +on: + push: + branches-ignore: + - 'compatibility-check-spring6' + pull_request: jobs: build: diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index 960d46410d..70b48a51a5 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -16,7 +16,11 @@ name: Spring/Spring Batch Support -on: [push, pull_request] +on: + push: + branches-ignore: + - 'compatibility-check-spring6' + pull_request: jobs: test: From ca96e638afa239a4a8cfc9516feb6dafaeefb192 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 19 Dec 2021 23:31:12 +0900 Subject: [PATCH 363/933] Add the new GitHub workflow for checking compatibility with Spring 6 and Spring Batch 5 See gh-634 --- .../compatibility-check-spring6.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/compatibility-check-spring6.yaml diff --git a/.github/workflows/compatibility-check-spring6.yaml b/.github/workflows/compatibility-check-spring6.yaml new file mode 100644 index 0000000000..88bc08289a --- /dev/null +++ b/.github/workflows/compatibility-check-spring6.yaml @@ -0,0 +1,57 @@ +# +# Copyright 2010-2021 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name: Compatibility with Spring 6/Spring Batch 5 + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + java: [17, 18-ea] + distribution: ['zulu'] + fail-fast: false + max-parallel: 2 + name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: ${{ matrix.distribution }} + - name: Git config + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + - name: Checkout to local + run: git checkout -b compatibility-check-spring6-head + - name: Checkout compatibility check brach + run: git checkout compatibility-check-spring6 + - name: Merge to compatibility check brach + run: git merge --no-edit compatibility-check-spring6-head + - name: Test with Spring 6 / Spring Batch 5 support + run: ./mvnw -U test -D"license.skip=true" -D"animal.sniffer.skip=true" -D"spring.version=6.0.0-SNAPSHOT" -D"spring-batch.version=5.0.0-SNAPSHOT" From 46b47d57556738d067d9ba9ab32e57e9138d272f Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 26 Dec 2021 22:12:39 +0900 Subject: [PATCH 364/933] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52aee0b493..bef9e2869f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ MyBatis Spring Adapter ====================== -[![Build Status](https://travis-ci.org/mybatis/spring.svg?branch=master)](https://travis-ci.org/mybatis/spring) +[![Java CI](https://github.com/mybatis/spring/actions/workflows/ci.yaml/badge.svg)](https://github.com/mybatis/spring/actions/workflows/ci.yaml) [![Coverage Status](https://coveralls.io/repos/mybatis/spring/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/spring?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring/) From b6ba581de199bfbc3ef78fa90201ffd148cdb017 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Dec 2021 07:01:36 +0000 Subject: [PATCH 365/933] Bump mybatis from 3.5.8 to 3.5.9 Bumps [mybatis](https://github.com/mybatis/mybatis-3) from 3.5.8 to 3.5.9. - [Release notes](https://github.com/mybatis/mybatis-3/releases) - [Commits](https://github.com/mybatis/mybatis-3/compare/mybatis-3.5.8...mybatis-3.5.9) --- updated-dependencies: - dependency-name: org.mybatis:mybatis dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bded5f71bc..340da7de32 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.8 + 3.5.9 5.3.14 4.3.4 org.mybatis.spring From ce1c3f3219b06aa4fefc536a3e8dbb785709b175 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jan 2022 07:01:18 +0000 Subject: [PATCH 366/933] Bump assertj-core from 3.21.0 to 3.22.0 Bumps [assertj-core](https://github.com/assertj/assertj-core) from 3.21.0 to 3.22.0. - [Release notes](https://github.com/assertj/assertj-core/releases) - [Commits](https://github.com/assertj/assertj-core/compare/assertj-core-3.21.0...assertj-core-3.22.0) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 340da7de32..d9a3817621 100644 --- a/pom.xml +++ b/pom.xml @@ -231,7 +231,7 @@ org.assertj assertj-core - 3.21.0 + 3.22.0 test From a4eca3b0dfa36eae943d0247355edd734e8616ef Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 4 Jan 2022 21:51:21 +0900 Subject: [PATCH 367/933] Update license year --- .mvn/extensions.xml | 2 +- pom.xml | 2 +- scripts/get_latest_version.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 60074e2013..bb32721e8f 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -1,7 +1,7 @@ - + 4.0.0 From 6912f55949469c5419a2c87caf79a8471227c61f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 5 Sep 2022 19:06:10 -0400 Subject: [PATCH 421/933] [pom] Bump mybatis parent to 36 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0e0e45800..d3b0468ed5 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 34 + 36 From 008f716f34416a6f47fdc09bac3d14dd575b6036 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 5 Sep 2022 19:06:26 -0400 Subject: [PATCH 422/933] [pom] Move ci management from travis to github actions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d3b0468ed5..c0dbdcbada 100644 --- a/pom.xml +++ b/pom.xml @@ -87,8 +87,8 @@ https://github.com/mybatis/spring/issues - Travis CI - https://travis-ci.org/mybatis/spring + GitHub Actions + https://github.com/mybatis/spring/actions From 41746d94aace10f588ee5fc7e408f1789de2782d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 5 Sep 2022 19:07:09 -0400 Subject: [PATCH 423/933] [secure] Use secure img shields io site --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 439c253fc6..b9be2d3db8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ MyBatis Spring Adapter [![Coverage Status](https://coveralls.io/repos/mybatis/spring/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/spring?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring/) -[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) +[![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) ![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png) From 2f928e24b2c696bb68afbf8c80394f929075102f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 5 Sep 2022 19:19:24 -0400 Subject: [PATCH 424/933] [secure] Use secure license site and formatting --- .editorconfig | 4 +- .mvn/extensions.xml | 2 +- .mvn/settings.xml | 4 +- LICENSE_HEADER | 2 +- format.xml | 4 +- pom.xml | 2 +- scripts/get_latest_version.sh | 2 +- src/changes/changes.xml | 4 +- src/main/java/org/mybatis/logging/Logger.java | 4 +- .../org/mybatis/logging/LoggerFactory.java | 4 +- .../spring/MyBatisExceptionTranslator.java | 7 ++-- .../spring/MyBatisSystemException.java | 6 +-- .../mybatis/spring/SqlSessionFactoryBean.java | 38 ++++++++++--------- .../org/mybatis/spring/SqlSessionHolder.java | 4 +- .../mybatis/spring/SqlSessionTemplate.java | 6 +-- .../org/mybatis/spring/SqlSessionUtils.java | 12 ++++-- .../mybatis/spring/annotation/MapperScan.java | 9 ++--- .../annotation/MapperScannerRegistrar.java | 3 +- .../spring/annotation/MapperScans.java | 7 ++-- .../spring/annotation/package-info.java | 4 +- .../spring/batch/MyBatisBatchItemWriter.java | 5 ++- .../spring/batch/MyBatisCursorItemReader.java | 4 +- .../spring/batch/MyBatisPagingItemReader.java | 4 +- .../MyBatisBatchItemWriterBuilder.java | 16 +++++++- .../MyBatisCursorItemReaderBuilder.java | 16 +++++++- .../MyBatisPagingItemReaderBuilder.java | 18 ++++++++- .../spring/batch/builder/package-info.java | 4 +- .../mybatis/spring/batch/package-info.java | 4 +- .../MapperScannerBeanDefinitionParser.java | 3 +- .../spring/config/NamespaceHandler.java | 5 ++- .../mybatis/spring/config/package-info.java | 4 +- .../spring/mapper/ClassPathMapperScanner.java | 6 ++- .../spring/mapper/MapperFactoryBean.java | 4 +- .../mapper/MapperScannerConfigurer.java | 10 ++++- .../mybatis/spring/mapper/package-info.java | 4 +- .../java/org/mybatis/spring/package-info.java | 4 +- .../spring/support/SqlSessionDaoSupport.java | 7 +++- .../mybatis/spring/support/package-info.java | 4 +- .../transaction/SpringManagedTransaction.java | 4 +- .../SpringManagedTransactionFactory.java | 4 +- .../spring/transaction/package-info.java | 4 +- .../mybatis/spring/config/mybatis-spring.xsd | 4 +- src/site/resources/css/site.css | 4 +- src/site/resources/es/css/site.css | 4 +- src/site/resources/ja/css/site.css | 4 +- src/site/resources/ko/css/site.css | 4 +- src/site/resources/zh/css/site.css | 4 +- src/site/site.xml | 4 +- src/site/site_es.xml | 4 +- src/site/site_ja.xml | 4 +- src/site/site_ko.xml | 4 +- src/site/site_zh.xml | 4 +- .../jdk/type/AtomicNumberTypeHandler.java | 4 +- .../spring/AbstractMyBatisSpringTest.java | 4 +- .../mybatis/spring/ExecutorInterceptor.java | 6 +-- .../org/mybatis/spring/MyBatisSpringTest.java | 4 +- .../mybatis/spring/PooledMockDataSource.java | 4 +- .../spring/SqlSessionFactoryBeanTest.java | 2 +- .../spring/SqlSessionTemplateTest.java | 4 +- .../java/org/mybatis/spring/TestMapper.java | 4 +- .../java/org/mybatis/spring/TestMapper.xml | 4 +- .../spring/annotation/MapperScanTest.java | 2 +- .../annotation/factory/SimpleFactoryBean.java | 4 +- ...pConfigWithDefaultMapperScanAndRepeat.java | 4 +- .../ds1/AppConfigWithDefaultMapperScans.java | 4 +- .../annotation/mapper/ds1/Ds1Mapper.java | 4 +- .../annotation/mapper/ds2/Ds2Mapper.java | 4 +- .../mybatis/spring/annotation/scan.properties | 4 +- .../AsyncAfterCompletionHelper.java | 6 +-- ...ssionTemplateAsyncAfterCompletionTest.java | 6 +-- .../batch/MyBatisBatchItemWriterTest.java | 4 +- .../batch/MyBatisCursorItemReaderTest.java | 4 +- .../mybatis/spring/batch/SpringBatchTest.java | 4 +- .../spring/batch/applicationContext.xml | 4 +- .../MyBatisBatchItemWriterBuilderTest.java | 5 ++- .../MyBatisCursorItemReaderBuilderTest.java | 5 ++- .../MyBatisPagingItemReaderBuilderTest.java | 5 ++- .../spring/batch/dao/EmployeeMapper.xml | 4 +- .../spring/batch/db/database-schema.sql | 4 +- .../spring/batch/db/database-test-data.sql | 4 +- .../mybatis/spring/batch/domain/Employee.java | 4 +- .../mybatis/spring/config/NamespaceTest.java | 2 +- .../org/mybatis/spring/config/annotation.xml | 4 +- .../mybatis/spring/config/base-package.xml | 4 +- .../spring/config/default-scope.properties | 4 +- .../mybatis/spring/config/default-scope.xml | 4 +- .../org/mybatis/spring/config/factory-ref.xml | 4 +- .../org/mybatis/spring/config/lazy.properties | 4 +- .../java/org/mybatis/spring/config/lazy.xml | 4 +- .../config/mapper-factory-bean-class.xml | 4 +- .../spring/config/marker-and-annotation.xml | 4 +- .../spring/config/marker-interface.xml | 4 +- .../mybatis/spring/config/name-generator.xml | 4 +- .../mybatis/spring/config/template-ref.xml | 4 +- .../spring/mapper/AnnotatedMapper.java | 4 +- .../mapper/AnnotatedMapperZeroMethods.java | 4 +- .../AppConfigWithDefaultPackageScan.java | 4 +- .../mybatis/spring/mapper/MapperClass.java | 4 +- .../spring/mapper/MapperFactoryBeanTest.java | 4 +- .../spring/mapper/MapperImplementation.java | 4 +- .../spring/mapper/MapperInterface.java | 4 +- .../mapper/MapperScannerConfigurerTest.java | 2 +- .../spring/mapper/MapperSubinterface.java | 4 +- .../spring/mapper/ScopedProxyMapper.java | 4 +- .../mapper/child/MapperChildInterface.java | 4 +- .../org/mybatis/spring/mybatis-config.xml | 4 +- .../spring/sample/AbstractSampleJobTest.java | 4 +- .../spring/sample/AbstractSampleTest.java | 4 +- .../spring/sample/SampleBatchTest.java | 4 +- .../spring/sample/SampleEnableTest.java | 4 +- .../spring/sample/SampleJavaConfigTest.java | 4 +- .../sample/SampleJobJavaConfigTest.java | 4 +- .../spring/sample/SampleJobXmlConfigTest.java | 4 +- .../spring/sample/SampleMapperTest.java | 4 +- .../spring/sample/SampleNamespaceTest.java | 4 +- .../spring/sample/SampleScannerTest.java | 4 +- .../spring/sample/SampleSqlSessionTest.java | 4 +- .../batch/UserToPersonItemProcessor.java | 4 +- .../spring/sample/config/SampleConfig.java | 4 +- .../spring/sample/config/SampleJobConfig.java | 4 +- .../config/applicationContext-batch.xml | 4 +- .../applicationContext-infrastructure.xml | 4 +- .../sample/config/applicationContext-job.xml | 4 +- .../config/applicationContext-mapper.xml | 4 +- .../config/applicationContext-namespace.xml | 4 +- .../config/applicationContext-scanner.xml | 4 +- .../config/applicationContext-sqlsession.xml | 4 +- .../mybatis/spring/sample/dao/UserDao.java | 4 +- .../spring/sample/dao/UserDaoImpl.java | 4 +- .../spring/sample/db/database-schema.sql | 4 +- .../spring/sample/db/database-test-data.sql | 4 +- .../mybatis/spring/sample/domain/Person.java | 4 +- .../mybatis/spring/sample/domain/User.java | 4 +- .../spring/sample/mapper/PersonMapper.xml | 4 +- .../spring/sample/mapper/UserMapper.java | 4 +- .../spring/sample/mapper/UserMapper.xml | 4 +- .../spring/sample/mapper/package-info.java | 4 +- .../mybatis/spring/sample/package-info.java | 4 +- .../spring/sample/service/BarService.java | 4 +- .../spring/sample/service/FooService.java | 4 +- .../mybatis/spring/scan/ScanAnnotation.java | 4 +- .../org/mybatis/spring/scan/ScanClass1.java | 4 +- .../org/mybatis/spring/scan/ScanClass2.java | 4 +- .../org/mybatis/spring/scan/ScanEnum.java | 4 +- .../mybatis/spring/scan/ScanInterface.java | 4 +- .../org/mybatis/spring/scan/package-info.java | 4 +- .../submitted/autowire/AutowireTest.java | 4 +- .../spring/submitted/autowire/BarMapper.java | 4 +- .../spring/submitted/autowire/BarMapper.xml | 4 +- .../spring/submitted/autowire/FooMapper.java | 4 +- .../spring/submitted/autowire/FooMapper.xml | 4 +- .../spring/submitted/autowire/IBar.java | 4 +- .../spring/submitted/autowire/IFoo.java | 4 +- .../autowire/database-schema-bar.sql | 4 +- .../autowire/database-schema-foo.sql | 4 +- .../spring/submitted/autowire/spring.xml | 4 +- .../submitted/webapp_placeholder/Mapper.java | 4 +- .../WebappPlaceholderTest.java | 4 +- .../webapp_placeholder/conf.properties | 4 +- .../submitted/webapp_placeholder/spring.xml | 4 +- .../org/mybatis/spring/submitted/xa/User.java | 4 +- .../spring/submitted/xa/UserMapper.java | 4 +- .../spring/submitted/xa/UserService.java | 4 +- .../spring/submitted/xa/UserServiceImpl.java | 4 +- .../spring/submitted/xa/UserServiceTest.java | 4 +- .../submitted/xa/applicationContext.xml | 4 +- .../spring/submitted/xa/database-schema.sql | 4 +- .../support/SqlSessionDaoSupportTest.java | 4 +- .../SpringTransactionManagerTest.java | 4 +- .../spring/type/DummyMapperFactoryBean.java | 4 +- .../mybatis/spring/type/DummyTypeAlias.java | 4 +- .../mybatis/spring/type/DummyTypeAlias2.java | 4 +- .../mybatis/spring/type/DummyTypeHandler.java | 4 +- .../spring/type/DummyTypeHandler2.java | 4 +- .../org/mybatis/spring/type/SuperType.java | 4 +- .../spring/type/TypeHandlerFactory.java | 4 +- .../org/mybatis/spring/type/package-info.java | 4 +- 177 files changed, 434 insertions(+), 373 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7cd8a144e3..8e7bc9ae72 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,11 @@ # -# Copyright 2010-2019 the original author or authors. +# Copyright 2010-2022 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 17735c046f..4d4c487d2e 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -7,7 +7,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/.mvn/settings.xml b/.mvn/settings.xml index 24b1b8f79e..f4c4a4728d 100644 --- a/.mvn/settings.xml +++ b/.mvn/settings.xml @@ -1,13 +1,13 @@ - + ossrh diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..732313c431 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.PasswordAuthentication; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; +import java.util.Properties; + +public final class MavenWrapperDownloader +{ + private static final String WRAPPER_VERSION = "3.1.1"; + + private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) ); + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/" + WRAPPER_VERSION + + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the + * default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main( String[] args ) + { + if ( args.length == 0 ) + { + System.err.println( " - ERROR projectBasedir parameter missing" ); + System.exit( 1 ); + } + + log( " - Downloader started" ); + final String dir = args[0].replace( "..", "" ); // Sanitize path + final Path projectBasedir = Paths.get( dir ).toAbsolutePath().normalize(); + if ( !Files.isDirectory( projectBasedir, LinkOption.NOFOLLOW_LINKS ) ) + { + System.err.println( " - ERROR projectBasedir not exists: " + projectBasedir ); + System.exit( 1 ); + } + + log( " - Using base directory: " + projectBasedir ); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + Path mavenWrapperPropertyFile = projectBasedir.resolve( MAVEN_WRAPPER_PROPERTIES_PATH ); + String url = readWrapperUrl( mavenWrapperPropertyFile ); + + try + { + Path outputFile = projectBasedir.resolve( MAVEN_WRAPPER_JAR_PATH ); + createDirectories( outputFile.getParent() ); + downloadFileFromURL( url, outputFile ); + log( "Done" ); + System.exit( 0 ); + } + catch ( IOException e ) + { + System.err.println( "- Error downloading" ); + e.printStackTrace(); + System.exit( 1 ); + } + } + + private static void downloadFileFromURL( String urlString, Path destination ) throws IOException + { + log( " - Downloading to: " + destination ); + if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null ) + { + final String username = System.getenv( "MVNW_USERNAME" ); + final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray(); + Authenticator.setDefault( new Authenticator() + { + @Override + protected PasswordAuthentication getPasswordAuthentication() + { + return new PasswordAuthentication( username, password ); + } + } ); + } + URL website = new URL( urlString ); + try ( InputStream inStream = website.openStream() ) { + Files.copy( inStream, destination, StandardCopyOption.REPLACE_EXISTING ); + } + log( " - Downloader complete" ); + } + + private static void createDirectories(Path outputPath) throws IOException + { + if ( !Files.isDirectory( outputPath, LinkOption.NOFOLLOW_LINKS ) ) { + Path createDirectories = Files.createDirectories( outputPath ); + log( " - Directories created: " + createDirectories ); + } + } + + private static String readWrapperUrl( Path mavenWrapperPropertyFile ) + { + String url = DEFAULT_DOWNLOAD_URL; + if ( Files.exists( mavenWrapperPropertyFile, LinkOption.NOFOLLOW_LINKS ) ) + { + log( " - Reading property file: " + mavenWrapperPropertyFile ); + try ( InputStream in = Files.newInputStream( mavenWrapperPropertyFile, StandardOpenOption.READ ) ) + { + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load( in ); + url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, DEFAULT_DOWNLOAD_URL ); + } + catch ( IOException e ) + { + System.err.println( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" ); + } + } + log( " - Downloading from: " + url ); + return url; + } + + private static void log( String msg ) + { + if ( VERBOSE ) + { + System.out.println( msg ); + } + } + +} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 8c79a83ae4..dc3affce3d 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# +# +# https://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar From 3824d6cfa01a15eabb40cbbbac2ecf4bbeb93b31 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Sep 2022 02:20:24 +0000 Subject: [PATCH 426/933] Update dependency org.hsqldb:hsqldb to v2.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a22404f1a5..12f2735fa8 100644 --- a/pom.xml +++ b/pom.xml @@ -210,7 +210,7 @@ org.hsqldb hsqldb - 2.5.2 + 2.7.0 test From 4a2d25680af75445ad7a348caf0ba0334afea894 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 18:49:11 +0000 Subject: [PATCH 427/933] Update dependency org.mockito:mockito-core to v4.8.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a22404f1a5..2b8496debd 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ org.mockito mockito-core - 4.7.0 + 4.8.0 test From 63de30dc5e3bea4d0868ded9fe8e9bced6c822ca Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Tue, 6 Sep 2022 21:06:34 -0400 Subject: [PATCH 428/933] [secure] Use mybatis.org directly for secure https --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9be2d3db8..6b126157b5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ MyBatis Spring Adapter [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring/) [![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) -![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png) +![mybatis-spring](https://mybatis.org/images/mybatis-logo.png) MyBatis-Spring adapter is an easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -21,5 +21,5 @@ Supported Versions Essentials ---------- -* [See the published docs](http://mybatis.github.io/spring/) +* [See the published docs](https://mybatis.org/spring/) * [See the snapshot docs](src/site/markdown) (Note: may contain explanation of unreleased features) From 8802271c5ef619be78d29974d97abbc7a3db9536 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Tue, 6 Sep 2022 21:06:45 -0400 Subject: [PATCH 429/933] [secure] Use https for printable world flags --- src/site/resources/css/site.css | 2 +- src/site/resources/es/css/site.css | 2 +- src/site/resources/ja/css/site.css | 2 +- src/site/resources/ko/css/site.css | 2 +- src/site/resources/zh/css/site.css | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/site/resources/css/site.css b/src/site/resources/css/site.css index a2232332e6..844c21ae32 100644 --- a/src/site/resources/css/site.css +++ b/src/site/resources/css/site.css @@ -16,7 +16,7 @@ /* * when new flags are needed, take them from * - * http://www.printableworldflags.com/flag-icon + * https://www.printableworldflags.com/flag-icon * * that are free for any kind of usage */ diff --git a/src/site/resources/es/css/site.css b/src/site/resources/es/css/site.css index 19d57827a3..b3f440195c 100644 --- a/src/site/resources/es/css/site.css +++ b/src/site/resources/es/css/site.css @@ -16,7 +16,7 @@ /* * when new flags are needed, take them from * - * http://www.printableworldflags.com/flag-icon + * https://www.printableworldflags.com/flag-icon * * that are free for any kind of usage */ diff --git a/src/site/resources/ja/css/site.css b/src/site/resources/ja/css/site.css index 19d57827a3..b3f440195c 100644 --- a/src/site/resources/ja/css/site.css +++ b/src/site/resources/ja/css/site.css @@ -16,7 +16,7 @@ /* * when new flags are needed, take them from * - * http://www.printableworldflags.com/flag-icon + * https://www.printableworldflags.com/flag-icon * * that are free for any kind of usage */ diff --git a/src/site/resources/ko/css/site.css b/src/site/resources/ko/css/site.css index 19d57827a3..b3f440195c 100644 --- a/src/site/resources/ko/css/site.css +++ b/src/site/resources/ko/css/site.css @@ -16,7 +16,7 @@ /* * when new flags are needed, take them from * - * http://www.printableworldflags.com/flag-icon + * https://www.printableworldflags.com/flag-icon * * that are free for any kind of usage */ diff --git a/src/site/resources/zh/css/site.css b/src/site/resources/zh/css/site.css index 19d57827a3..b3f440195c 100644 --- a/src/site/resources/zh/css/site.css +++ b/src/site/resources/zh/css/site.css @@ -16,7 +16,7 @@ /* * when new flags are needed, take them from * - * http://www.printableworldflags.com/flag-icon + * https://www.printableworldflags.com/flag-icon * * that are free for any kind of usage */ From 5847bb0259f2cf6684e49c4ebd40249b71e92fd5 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 16:56:42 +0900 Subject: [PATCH 430/933] Update version to 3.0.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6ff4397539..4bed180cf9 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.1.0-SNAPSHOT + 3.0.0-SNAPSHOT jar mybatis-spring From 7e37765876ac421540d5d5f7a859a536b74bebcb Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 17:47:13 +0900 Subject: [PATCH 431/933] Apply Spring 6, Spring Batch 5 and more * Change MyBatisBatchItemWriter * Apply jakarta.transaction-api 2.0.1 * Apply jakarta.servlet-api 6.0.0 * Fix error on tests Fixes gh-715 gh-716 --- pom.xml | 42 +++++++++++++++++-- .../spring/batch/MyBatisBatchItemWriter.java | 7 ++-- .../org/mybatis/spring/MyBatisSpringTest.java | 8 ++-- .../batch/MyBatisBatchItemWriterTest.java | 13 +++--- .../mybatis/spring/batch/SpringBatchTest.java | 12 +++--- .../MyBatisBatchItemWriterBuilderTest.java | 37 ++++++++-------- .../spring/sample/AbstractSampleJobTest.java | 7 +++- .../spring/sample/config/SampleJobConfig.java | 2 +- .../spring/submitted/xa/UserServiceTest.java | 6 ++- 9 files changed, 87 insertions(+), 47 deletions(-) diff --git a/pom.xml b/pom.xml index 4bed180cf9..544b3c0d2d 100644 --- a/pom.xml +++ b/pom.xml @@ -106,8 +106,8 @@ * 3.5.10 - 5.3.22 - 4.3.6 + 6.0.0-SNAPSHOT + 5.0.0-SNAPSHOT org.mybatis.spring 5.9.0 @@ -295,13 +295,13 @@ jakarta.transaction jakarta.transaction-api - 1.3.3 + 2.0.1 test jakarta.servlet jakarta.servlet-api - 4.0.4 + 6.0.0 test @@ -371,6 +371,40 @@ Sonatype OSS Snapshots Repository https://oss.sonatype.org/content/repositories/snapshots + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + false + + + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + false + + + + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + false + + + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + false + + + diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index 8eeca0d7a8..42118df358 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -27,6 +27,7 @@ import org.mybatis.logging.Logger; import org.mybatis.logging.LoggerFactory; import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.convert.converter.Converter; @@ -136,7 +137,7 @@ public void afterPropertiesSet() { * {@inheritDoc} */ @Override - public void write(final List items) { + public void write(final Chunk items) { if (!items.isEmpty()) { LOGGER.debug(() -> "Executing batch with " + items.size() + " items."); @@ -158,8 +159,8 @@ public void write(final List items) { for (int i = 0; i < updateCounts.length; i++) { int value = updateCounts[i]; if (value == 0) { - throw new EmptyResultDataAccessException( - "Item " + i + " of " + updateCounts.length + " did not update any rows: [" + items.get(i) + "]", 1); + throw new EmptyResultDataAccessException("Item " + i + " of " + updateCounts.length + + " did not update any rows: [" + items.getItems().get(i) + "]", 1); } } } diff --git a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java index b43bd579f0..2b5f43f5d5 100644 --- a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; -import com.mockrunner.mock.ejb.MockUserTransaction; import com.mockrunner.mock.jdbc.MockConnection; import com.mockrunner.mock.jdbc.MockDataSource; import com.mockrunner.mock.jdbc.MockPreparedStatement; @@ -32,12 +31,15 @@ import org.apache.ibatis.transaction.managed.ManagedTransactionFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.springframework.dao.DataAccessException; import org.springframework.dao.TransientDataAccessResourceException; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.support.DefaultTransactionDefinition; +import jakarta.transaction.UserTransaction; + class MyBatisSpringTest extends AbstractMyBatisSpringTest { private SqlSession session; @@ -275,7 +277,7 @@ void testChangeExecutorTypeInTxRequiresNew() throws Exception { @Test void testWithJtaTxManager() { - JtaTransactionManager jtaManager = new JtaTransactionManager(new MockUserTransaction()); + JtaTransactionManager jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class)); DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); @@ -304,7 +306,7 @@ void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException { Environment nonSpring = new Environment("non-spring", new ManagedTransactionFactory(), mockDataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); - JtaTransactionManager jtaManager = new JtaTransactionManager(new MockUserTransaction()); + JtaTransactionManager jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class)); DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index a3a5366f33..ad11afbc09 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -22,7 +22,6 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -30,7 +29,6 @@ import org.apache.ibatis.executor.BatchResult; import org.apache.ibatis.session.ExecutorType; -import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; @@ -39,6 +37,7 @@ import org.mockito.MockitoAnnotations; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.batch.domain.Employee; +import org.springframework.batch.item.Chunk; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.InvalidDataAccessResourceUsageException; @@ -60,8 +59,8 @@ void setUp() { @Test void testZeroBatchResultShouldThrowException() { - List employees = Arrays.asList(new Employee(), new Employee()); - List batchResults = Lists.emptyList(); + Chunk employees = Chunk.of(new Employee(), new Employee()); + List batchResults = Collections.emptyList(); given(mockSqlSessionTemplate.flushStatements()).willReturn(batchResults); @@ -70,7 +69,7 @@ void testZeroBatchResultShouldThrowException() { @Test void testZeroUpdateCountShouldThrowException() { - List employees = Arrays.asList(new Employee(), new Employee()); + Chunk employees = Chunk.of(new Employee(), new Employee()); BatchResult batchResult = new BatchResult(null, null); batchResult.setUpdateCounts(new int[] { 1, 0 }); @@ -87,7 +86,7 @@ void testItemToParameterConverterIsDefault() { this.writer.setStatementId("updateEmployee"); Employee employee = new Employee(); - List employees = Collections.singletonList(employee); + Chunk employees = Chunk.of(employee); writer.write(employees); Mockito.verify(this.mockSqlSessionTemplate).update("updateEmployee", employee); @@ -105,7 +104,7 @@ void testSetItemToParameterConverter() { }); Employee employee = new Employee(); - List employees = Collections.singletonList(employee); + Chunk employees = Chunk.of(employee); writer.write(employees); Map parameter = new HashMap<>(); diff --git a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java index 5096c84623..c934a9b5d8 100644 --- a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java +++ b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java @@ -17,12 +17,10 @@ import static org.assertj.core.api.Assertions.*; -import java.util.ArrayList; -import java.util.List; - import org.apache.ibatis.session.SqlSession; import org.junit.jupiter.api.Test; import org.mybatis.spring.batch.domain.Employee; +import org.springframework.batch.item.Chunk; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -56,7 +54,7 @@ class SpringBatchTest { @Test @Transactional void shouldDuplicateSalaryOfAllEmployees() throws Exception { - List employees = new ArrayList<>(); + Chunk employees = new Chunk<>(); Employee employee = pagingNoNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); @@ -73,7 +71,7 @@ void shouldDuplicateSalaryOfAllEmployees() throws Exception { @Transactional void checkPagingReadingWithNestedInResultMap() throws Exception { // This test is here to show that PagingReader can return wrong result in case of nested result maps - List employees = new ArrayList<>(); + Chunk employees = new Chunk<>(); Employee employee = pagingNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); @@ -91,7 +89,7 @@ void checkPagingReadingWithNestedInResultMap() throws Exception { void checkCursorReadingWithoutNestedInResultMap() throws Exception { cursorNoNestedItemReader.doOpen(); try { - List employees = new ArrayList<>(); + Chunk employees = new Chunk<>(); Employee employee = cursorNoNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); @@ -112,7 +110,7 @@ void checkCursorReadingWithoutNestedInResultMap() throws Exception { void checkCursorReadingWithNestedInResultMap() throws Exception { cursorNestedItemReader.doOpen(); try { - List employees = new ArrayList<>(); + Chunk employees = new Chunk<>(); Employee employee = cursorNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index f36c8678c4..e410c88931 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -37,6 +37,7 @@ import org.mockito.MockitoAnnotations; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.batch.MyBatisBatchItemWriter; +import org.springframework.batch.item.Chunk; /** * Tests for {@link MyBatisBatchItemWriterBuilder}. @@ -84,13 +85,13 @@ void testConfigurationUsingSqlSessionFactory() { // @formatter:on itemWriter.afterPropertiesSet(); - List foos = getFoos(); + Chunk foos = getFoos(); itemWriter.write(foos); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(0)); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(1)); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(2)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(0)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(1)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(2)); } @@ -105,13 +106,13 @@ void testConfigurationUsingSqlSessionTemplate() { // @formatter:on itemWriter.afterPropertiesSet(); - List foos = getFoos(); + Chunk foos = getFoos(); itemWriter.write(foos); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(0)); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(1)); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(2)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(0)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(1)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(2)); } @@ -129,13 +130,13 @@ void testConfigurationAssertUpdatesIsFalse() { // @formatter:on itemWriter.afterPropertiesSet(); - List foos = getFoos(); + Chunk foos = getFoos(); itemWriter.write(foos); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(0)); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(1)); - Mockito.verify(this.sqlSession).update("updateFoo", foos.get(2)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(0)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(1)); + Mockito.verify(this.sqlSession).update("updateFoo", foos.getItems().get(2)); } @@ -156,22 +157,22 @@ void testConfigurationSetItemToParameterConverter() { // @formatter:on itemWriter.afterPropertiesSet(); - List foos = getFoos(); + Chunk foos = getFoos(); itemWriter.write(foos); Map parameter = new HashMap<>(); parameter.put("now", LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); - parameter.put("item", foos.get(0)); + parameter.put("item", foos.getItems().get(0)); Mockito.verify(this.sqlSession).update("updateFoo", parameter); - parameter.put("item", foos.get(1)); + parameter.put("item", foos.getItems().get(1)); Mockito.verify(this.sqlSession).update("updateFoo", parameter); - parameter.put("item", foos.get(2)); + parameter.put("item", foos.getItems().get(2)); Mockito.verify(this.sqlSession).update("updateFoo", parameter); } - private List getFoos() { - return Arrays.asList(new Foo("foo1"), new Foo("foo2"), new Foo("foo3")); + private Chunk getFoos() { + return Chunk.of(new Foo("foo1"), new Foo("foo2"), new Foo("foo3")); } private static class Foo { diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java index 389d0a6ede..8f17d16183 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java @@ -22,6 +22,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -97,8 +98,10 @@ void testJob() throws Exception { @Configuration static class LocalContext { @Bean - JobLauncherTestUtils jobLauncherTestUtils() { - return new JobLauncherTestUtils(); + JobLauncherTestUtils jobLauncherTestUtils(Job job) { + JobLauncherTestUtils utils = new JobLauncherTestUtils(); + utils.setJob(job); + return utils; } @Bean diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java index 282c034c57..4a0e26e386 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java @@ -133,11 +133,11 @@ public Job importUserJob() throws Exception { public Step step1() throws Exception { // @formatter:off return stepBuilderFactory.get("step1") - .transactionManager(transactionalManager()) .chunk(10) .reader(reader()) .processor(processor()) .writer(writer()) + .transactionManager(transactionalManager()) .build(); // @formatter:on } diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java index 06e7c6e1f2..0aeeac48b7 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java @@ -17,14 +17,16 @@ import static org.assertj.core.api.Assertions.assertThat; -import javax.transaction.UserTransaction; - +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import jakarta.transaction.UserTransaction; + +@Disabled("Yet not found OSS implementation that supported Jakarta EE 9+ APIs") @ExtendWith(SpringExtension.class) @SpringJUnitConfig(locations = "classpath:org/mybatis/spring/submitted/xa/applicationContext.xml") class UserServiceTest { From a193c0388d13b25c547a28897276fc672f5054d3 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 18:15:10 +0900 Subject: [PATCH 432/933] Ignore Maven Enforcer Plugin on 3.x See gh-715 gh-716 --- .github/workflows/ci.yaml | 4 +- .../compatibility-check-spring6.yaml | 57 ------------------- .github/workflows/coveralls.yaml | 6 +- .github/workflows/sonar.yaml | 4 +- .github/workflows/sonatype.yaml | 4 +- .github/workflows/support.yaml | 47 --------------- 6 files changed, 7 insertions(+), 115 deletions(-) delete mode 100644 .github/workflows/compatibility-check-spring6.yaml delete mode 100644 .github/workflows/support.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 243038d58c..6d607a022f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,8 +18,6 @@ name: Java CI on: push: - branches-ignore: - - 'compatibility-check-spring6' pull_request: jobs: @@ -42,4 +40,4 @@ jobs: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - name: Test with Maven - run: ./mvnw test -B -D"license.skip=true" + run: ./mvnw test -B -D"license.skip=true" -D"enforcer.skip=true" diff --git a/.github/workflows/compatibility-check-spring6.yaml b/.github/workflows/compatibility-check-spring6.yaml deleted file mode 100644 index 028729f0d6..0000000000 --- a/.github/workflows/compatibility-check-spring6.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -name: Compatibility with Spring 6/Spring Batch 5 - -on: - push: - pull_request: - schedule: - - cron: "0 0 * * *" - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - java: [17, 18, 19-ea] - distribution: ['zulu'] - fail-fast: false - max-parallel: 3 - name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: ${{ matrix.distribution }} - - name: Git config - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - name: Checkout to local - run: git checkout -b compatibility-check-spring6-head - - name: Checkout compatibility check brach - run: git checkout compatibility-check-spring6 - - name: Merge to compatibility check brach - run: git merge --no-edit compatibility-check-spring6-head - - name: Test with Spring 6 / Spring Batch 5 support - run: ./mvnw -U test -D"license.skip=true" -D"animal.sniffer.skip=true" -D"spring.version=6.0.0-SNAPSHOT" -D"spring-batch.version=5.0.0-SNAPSHOT" diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index b898488c1f..9e9cc59df5 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -18,8 +18,6 @@ name: Coveralls on: push: - branches-ignore: - - 'compatibility-check-spring6' pull_request: jobs: @@ -35,12 +33,12 @@ jobs: distribution: zulu - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER + run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -Denforcer.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} - name: Report Coverage to Coveralls for General Push if: github.event_name == 'push' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github + run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -Denforcer.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index eda5f33114..40c6300f32 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -19,7 +19,7 @@ name: SonarCloud on: push: branches: - - master + - 3.x jobs: build: @@ -36,7 +36,7 @@ jobs: java-version: 17 distribution: zulu - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true + run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true -Denforcer.skip=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 008954a7f3..88bcd02e70 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -19,7 +19,7 @@ name: Sonatype on: push: branches: - - master + - 3.x jobs: build: @@ -33,7 +33,7 @@ jobs: java-version: 17 distribution: zulu - name: Deploy to Sonatype - run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true + run: ./mvnw deploy -DskipTests -Denforcer.skip=true -B --settings ./.mvn/settings.xml -Dlicense.skip=true env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml deleted file mode 100644 index 5be3956bd3..0000000000 --- a/.github/workflows/support.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -name: Spring/Spring Batch Support - -on: - push: - branches-ignore: - - 'compatibility-check-spring6' - pull_request: - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macOS-latest] - java: [11] - distribution: ['zulu'] - fail-fast: false - max-parallel: 2 - name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: ${{ matrix.distribution }} - - name: Test with Spring 5.2 / Spring Batch 4.2 support - run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.2) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.2) - - name: Test with Spring 5.1 / Spring Batch 4.1 support - run: ./mvnw test -Dspring.version=$(./scripts/get_latest_version.sh spring-core 5.1) -Dspring-batch.version=$(./scripts/get_latest_version.sh batch/spring-batch-core 4.1) From 5e6cb83ddf13fbed05f8b43da0f1110a57568ea3 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 18:35:12 +0900 Subject: [PATCH 433/933] Change supporing Java version on 3.x CI See gh-715 gh-716 --- .github/workflows/ci.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- pom.xml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6d607a022f..1966d99a75 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - java: [11, 17, 18, 19-ea] + java: [17, 18, 19-ea] distribution: ['zulu'] fail-fast: false max-parallel: 5 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 9e9cc59df5..df3ec31ab0 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -29,7 +29,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: zulu - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' diff --git a/pom.xml b/pom.xml index 544b3c0d2d..b2886d76db 100644 --- a/pom.xml +++ b/pom.xml @@ -112,6 +112,7 @@ 5.9.0 1645112687 + From 8ac17151220a7a5f87cc7418509cf77437422307 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 18:48:51 +0900 Subject: [PATCH 434/933] Delete compatibility-check-spring6.yaml --- .../compatibility-check-spring6.yaml | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/compatibility-check-spring6.yaml diff --git a/.github/workflows/compatibility-check-spring6.yaml b/.github/workflows/compatibility-check-spring6.yaml deleted file mode 100644 index 028729f0d6..0000000000 --- a/.github/workflows/compatibility-check-spring6.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -name: Compatibility with Spring 6/Spring Batch 5 - -on: - push: - pull_request: - schedule: - - cron: "0 0 * * *" - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - java: [17, 18, 19-ea] - distribution: ['zulu'] - fail-fast: false - max-parallel: 3 - name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: ${{ matrix.distribution }} - - name: Git config - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - name: Checkout to local - run: git checkout -b compatibility-check-spring6-head - - name: Checkout compatibility check brach - run: git checkout compatibility-check-spring6 - - name: Merge to compatibility check brach - run: git merge --no-edit compatibility-check-spring6-head - - name: Test with Spring 6 / Spring Batch 5 support - run: ./mvnw -U test -D"license.skip=true" -D"animal.sniffer.skip=true" -D"spring.version=6.0.0-SNAPSHOT" -D"spring-batch.version=5.0.0-SNAPSHOT" From 46ced34268545fdb4a9492b024dab0e06ad1b084 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 18:50:59 +0900 Subject: [PATCH 435/933] Support cron job for Java CI on 3.x --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1966d99a75..dba82c0e24 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,8 @@ name: Java CI on: push: pull_request: + schedule: + - cron: "0 0 * * *" jobs: test: From 6e24c3f428af26e3335ba355e62776326b25de41 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 11 Sep 2022 19:16:12 +0900 Subject: [PATCH 436/933] Add descriotion for 3.x See gh-716 --- README.md | 3 ++- src/site/es/markdown/index.md | 3 ++- src/site/ja/markdown/index.md | 3 ++- src/site/ko/markdown/index.md | 3 ++- src/site/markdown/index.md | 11 ++++++----- src/site/zh/markdown/index.md | 3 ++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6b126157b5..f6df7c6962 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ MyBatis-Spring adapter is an easy-to-use Spring bridge for MyBatis sql mapping f Supported Versions ------------------ -- master (2.1.x) - Support Spring 6(keep backward compatibility for Spring 5) +- 3.x - Support for Spring 6 and Spring Batch 5 (**not release yet**) +- master (2.1.x) - Enhance and maintenance for Spring 5 and Spring Batch 4 (**not release yet**) - 2.0.x - Support for Java 8, Spring 5, and Junit 5 plus other java 8 requirements - 1.3.x - Continued support for Java 6 and 7 diff --git a/src/site/es/markdown/index.md b/src/site/es/markdown/index.md index 58fef0e1a6..b79bcb62ff 100644 --- a/src/site/es/markdown/index.md +++ b/src/site/es/markdown/index.md @@ -22,7 +22,8 @@ MyBatis-Spring requires following versions: | MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | |----------------| --- |------------------|--------------| --- | -| **2.1** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | +| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | | **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | | **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | diff --git a/src/site/ja/markdown/index.md b/src/site/ja/markdown/index.md index d9e5594e2a..3a11e460d9 100644 --- a/src/site/ja/markdown/index.md +++ b/src/site/ja/markdown/index.md @@ -17,7 +17,8 @@ MyBatis-Spring は以下のバージョンを必要とします。 | MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | |----------------| --- |------------------|--------------| --- | -| **2.1** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | +| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | | **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | | **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | diff --git a/src/site/ko/markdown/index.md b/src/site/ko/markdown/index.md index 4f9e4617d8..210c2becd9 100644 --- a/src/site/ko/markdown/index.md +++ b/src/site/ko/markdown/index.md @@ -20,7 +20,8 @@ MyBatis-Spring requires following versions: | MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | |----------------| --- |------------------|--------------| --- | -| **2.1** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | +| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | | **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | | **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 283daa5729..2826d01602 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -19,11 +19,12 @@ This document does not attempt to provide background information or basic setup MyBatis-Spring requires following versions: -| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | -|----------------| --- |------------------|--------------| --- | -| **2.1** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | -| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | -| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +|----------------| --- |------------------|--------------|----------| +| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | +| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | +| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | +| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | ## Acknowledgements diff --git a/src/site/zh/markdown/index.md b/src/site/zh/markdown/index.md index c74bc3d474..3239fe84ce 100644 --- a/src/site/zh/markdown/index.md +++ b/src/site/zh/markdown/index.md @@ -19,7 +19,8 @@ MyBatis-Spring 需要以下版本: | MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | |----------------| --- |------------------|--------------| --- | -| **2.1** | 3.5+ | 5.0+ | 4.0+ | Java 8+ | +| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | +| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | | **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | | **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | From 9c841534282b8687dc0c902ba9ccd663ec3d54d4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 14 Sep 2022 18:35:48 +0000 Subject: [PATCH 437/933] Update dependency org.slf4j:slf4j-simple to v2.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6ff4397539..a8b137bd6b 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ org.slf4j slf4j-simple - 2.0.0 + 2.0.1 test From 31ad9ff44e6fd1b46f07eda93dd92151e1582f44 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Sep 2022 12:20:02 +0000 Subject: [PATCH 438/933] Update spring core to v5.3.23 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8b137bd6b..0aaa66e131 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.10 - 5.3.22 + 5.3.23 4.3.6 org.mybatis.spring From 826ac5e0ab9612c7dd8ee54536bb2da7ddbfbaef Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 17 Sep 2022 13:33:07 -0400 Subject: [PATCH 439/933] [pom] Update project build output timestamp for reproducible builds --- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0aaa66e131..18e8b308e5 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,9 @@ org.mybatis.spring 5.9.0 - 1645112687 + + + 1757561022 From d01cbf95b71ec570df99a14226fd9a79d66dbf5e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 18 Sep 2022 21:50:37 +0000 Subject: [PATCH 440/933] Update dependency org.mybatis:mybatis to v3.5.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18e8b308e5..6b1e80e95d 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.10 + 3.5.11 5.3.23 4.3.6 org.mybatis.spring From f358a125e46bf046e6f9b26d59540f63929c27ed Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Sep 2022 23:00:31 +0000 Subject: [PATCH 441/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.9.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b1e80e95d..74927a4bd1 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 4.3.6 org.mybatis.spring - 5.9.0 + 5.9.1 1757561022 From 92dd17e7349516fc23d54f6ae97eee75bf46e6d3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Sep 2022 23:00:37 +0000 Subject: [PATCH 442/933] Update dependency org.slf4j:slf4j-simple to v2.0.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b1e80e95d..68e709827a 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ org.slf4j slf4j-simple - 2.0.1 + 2.0.2 test From cf4f260f236f64b355c4a0518ed787d17c9d3e31 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 22 Sep 2022 11:26:31 +0000 Subject: [PATCH 443/933] Update spring batch to v4.3.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b1e80e95d..7babeb39aa 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.11 5.3.23 - 4.3.6 + 4.3.7 org.mybatis.spring 5.9.0 From a91ad817c9496f951462a57cf40f09176f8a0b65 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 25 Sep 2022 15:06:33 +0900 Subject: [PATCH 444/933] Apply some specification changes of Spring Batch 5 on 3.x tests --- .../spring/sample/config/SampleJobConfig.java | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java index 4a0e26e386..d951605dc9 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java @@ -34,9 +34,12 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; -import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.batch.core.job.builder.JobBuilder; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.builder.StepBuilder; +import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.ItemWriter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; @@ -50,12 +53,6 @@ @EnableBatchProcessing public class SampleJobConfig { - @Autowired - private JobBuilderFactory jobBuilderFactory; - - @Autowired - private StepBuilderFactory stepBuilderFactory; - @Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL) @@ -66,15 +63,15 @@ public DataSource dataSource() { } @Bean - public PlatformTransactionManager transactionalManager() { - return new DataSourceTransactionManager(dataSource()); + public PlatformTransactionManager transactionManager(DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); } @Bean - public SqlSessionFactory sqlSessionFactory() throws Exception { + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); SqlSessionFactoryBean ss = new SqlSessionFactoryBean(); - ss.setDataSource(dataSource()); + ss.setDataSource(dataSource); ss.setMapperLocations(resourcePatternResolver.getResources("org/mybatis/spring/sample/mapper/*.xml")); org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration(); configuration.setDefaultExecutorType(ExecutorType.BATCH); @@ -83,10 +80,10 @@ public SqlSessionFactory sqlSessionFactory() throws Exception { } @Bean - public MyBatisCursorItemReader reader() throws Exception { + public MyBatisCursorItemReader reader(SqlSessionFactory sqlSessionFactory) { // @formatter:off return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory()) + .sqlSessionFactory(sqlSessionFactory) .queryId("org.mybatis.spring.sample.mapper.UserMapper.getUsers") .build(); // @formatter:on @@ -98,10 +95,10 @@ public UserToPersonItemProcessor processor() { } @Bean - public MyBatisBatchItemWriter writer() throws Exception { + public MyBatisBatchItemWriter writer(SqlSessionFactory sqlSessionFactory) { // @formatter:off return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory()) + .sqlSessionFactory(sqlSessionFactory) .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) .build(); @@ -120,24 +117,24 @@ public static Converter> createItemToParameterMapConv } @Bean - public Job importUserJob() throws Exception { + public Job importUserJob(JobRepository jobRepository, Step step1) { // @formatter:off - return jobBuilderFactory.get("importUserJob") - .flow(step1()) + return new JobBuilder("importUserJob", jobRepository) + .flow(step1) .end() .build(); // @formatter:on } @Bean - public Step step1() throws Exception { + public Step step1(JobRepository jobRepository, PlatformTransactionManager transactionManager, ItemReader reader, + ItemProcessor processor, ItemWriter writer) { // @formatter:off - return stepBuilderFactory.get("step1") - .chunk(10) - .reader(reader()) - .processor(processor()) - .writer(writer()) - .transactionManager(transactionalManager()) + return new StepBuilder("step1", jobRepository) + .chunk(10, transactionManager) + .reader(reader) + .processor(processor) + .writer(writer) .build(); // @formatter:on } From 79cf53af3d8b8d7e3f52f6cdc780585212267631 Mon Sep 17 00:00:00 2001 From: shica Date: Sun, 25 Sep 2022 19:39:58 +0800 Subject: [PATCH 445/933] make MyBatisCursorItemReader & MyBatisPagingItemReader support lazy/dynamic query parameter --- .../spring/batch/MyBatisCursorItemReader.java | 17 +++++++++++++++++ .../spring/batch/MyBatisPagingItemReader.java | 17 +++++++++++++++++ .../MyBatisCursorItemReaderBuilder.java | 18 ++++++++++++++++++ .../MyBatisPagingItemReaderBuilder.java | 18 ++++++++++++++++++ .../MyBatisCursorItemReaderBuilderTest.java | 10 +++++++++- .../MyBatisPagingItemReaderBuilderTest.java | 6 ++++++ 6 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java index 495dcfed54..038646c6fc 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.function.Supplier; import org.apache.ibatis.cursor.Cursor; import org.apache.ibatis.session.ExecutorType; @@ -41,6 +42,7 @@ public class MyBatisCursorItemReader extends AbstractItemCountingItemStreamIt private SqlSession sqlSession; private Map parameterValues; + private Supplier> parameterSupplier; private Cursor cursor; private Iterator cursorIterator; @@ -65,6 +67,11 @@ protected void doOpen() throws Exception { parameters.putAll(parameterValues); } + Map dynamicParameters; + if (parameterSupplier != null && (dynamicParameters = parameterSupplier.get()) != null) { + parameters.putAll(dynamicParameters); + } + sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE); cursor = sqlSession.selectCursor(queryId, parameters); cursorIterator = cursor.iterator(); @@ -121,4 +128,14 @@ public void setQueryId(String queryId) { public void setParameterValues(Map parameterValues) { this.parameterValues = parameterValues; } + + /** + * The parameter supplier used to get parameter values for the query execution. + * + * @param parameterSupplier + * the supplier used to get values keyed by the parameter named used in the query string. + */ + public void setParameterSupplier(Supplier> parameterSupplier) { + this.parameterSupplier = parameterSupplier; + } } diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 924d2fadc3..978b533555 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Supplier; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -47,6 +48,8 @@ public class MyBatisPagingItemReader extends AbstractPagingItemReader { private Map parameterValues; + private Supplier> parameterSupplier; + public MyBatisPagingItemReader() { setName(getShortName(MyBatisPagingItemReader.class)); } @@ -81,6 +84,16 @@ public void setParameterValues(Map parameterValues) { this.parameterValues = parameterValues; } + /** + * The parameter supplier used to get parameter values for the query execution. + * + * @param parameterSupplier + * the supplier used to get values keyed by the parameter named used in the query string. + */ + public void setParameterSupplier(Supplier> parameterSupplier) { + this.parameterSupplier = parameterSupplier; + } + /** * Check mandatory properties. * @@ -102,6 +115,10 @@ protected void doReadPage() { if (parameterValues != null) { parameters.putAll(parameterValues); } + Map dynamicParameters; + if (parameterSupplier != null && (dynamicParameters = parameterSupplier.get()) != null) { + parameters.putAll(dynamicParameters); + } parameters.put("_page", getPage()); parameters.put("_pagesize", getPageSize()); parameters.put("_skiprows", getPage() * getPageSize()); diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java index de7785ba19..98f696a5d5 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Optional; +import java.util.function.Supplier; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.batch.MyBatisCursorItemReader; @@ -35,6 +36,7 @@ public class MyBatisCursorItemReaderBuilder { private SqlSessionFactory sqlSessionFactory; private String queryId; private Map parameterValues; + private Supplier> parameterSupplier; private Boolean saveState; private Integer maxItemCount; @@ -83,6 +85,21 @@ public MyBatisCursorItemReaderBuilder parameterValues(Map par return this; } + /** + * Set the parameter supplier to be used to get parameters for the query execution. + * + * @param parameterSupplier + * the parameter supplier to be used to get parameters for the query execution + * + * @return this instance for method chaining + * + * @see MyBatisCursorItemReader#setParameterSupplier(Supplier) + */ + public MyBatisCursorItemReaderBuilder parameterSupplier(Supplier> parameterSupplier) { + this.parameterSupplier = parameterSupplier; + return this; + } + /** * Configure if the state of the {@link org.springframework.batch.item.ItemStreamSupport} should be persisted within * the {@link org.springframework.batch.item.ExecutionContext} for restart purposes. @@ -124,6 +141,7 @@ public MyBatisCursorItemReader build() { reader.setSqlSessionFactory(this.sqlSessionFactory); reader.setQueryId(this.queryId); reader.setParameterValues(this.parameterValues); + reader.setParameterSupplier(this.parameterSupplier); Optional.ofNullable(this.saveState).ifPresent(reader::setSaveState); Optional.ofNullable(this.maxItemCount).ifPresent(reader::setMaxItemCount); return reader; diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java index 1625bd1676..45b178ed9b 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Optional; +import java.util.function.Supplier; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.batch.MyBatisPagingItemReader; @@ -35,6 +36,7 @@ public class MyBatisPagingItemReaderBuilder { private SqlSessionFactory sqlSessionFactory; private String queryId; private Map parameterValues; + private Supplier> parameterSupplier; private Integer pageSize; private Boolean saveState; private Integer maxItemCount; @@ -84,6 +86,21 @@ public MyBatisPagingItemReaderBuilder parameterValues(Map par return this; } + /** + * Set the parameter supplier to be used to get parameters for the query execution. + * + * @param parameterSupplier + * the parameter supplier to be used to get parameters for the query execution + * + * @return this instance for method chaining + * + * @see MyBatisPagingItemReader#setParameterSupplier(Supplier) + */ + public MyBatisPagingItemReaderBuilder parameterSupplier(Supplier> parameterSupplier) { + this.parameterSupplier = parameterSupplier; + return this; + } + /** * The number of records to request per page/query. Defaults to 10. Must be greater than zero. * @@ -140,6 +157,7 @@ public MyBatisPagingItemReader build() { reader.setSqlSessionFactory(this.sqlSessionFactory); reader.setQueryId(this.queryId); reader.setParameterValues(this.parameterValues); + reader.setParameterSupplier(this.parameterSupplier); Optional.ofNullable(this.pageSize).ifPresent(reader::setPageSize); Optional.ofNullable(this.saveState).ifPresent(reader::setSaveState); Optional.ofNullable(this.maxItemCount).ifPresent(reader::setMaxItemCount); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index e434af0346..78691c2cf7 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -17,7 +17,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.ibatis.cursor.Cursor; import org.apache.ibatis.session.ExecutorType; @@ -56,7 +58,10 @@ void setUp() { Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.SIMPLE)).thenReturn(this.sqlSession); Mockito.when(this.cursor.iterator()).thenReturn(getFoos().iterator()); - Mockito.when(this.sqlSession.selectCursor("selectFoo", Collections.singletonMap("id", 1))).thenReturn(this.cursor); + Map parameters = new HashMap<>(); + parameters.put("id", 1); + parameters.put("name", "Doe"); + Mockito.when(this.sqlSession.selectCursor("selectFoo", parameters)).thenReturn(this.cursor); } @Test @@ -67,6 +72,7 @@ void testConfiguration() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .build(); // @formatter:on itemReader.afterPropertiesSet(); @@ -93,6 +99,7 @@ void testConfigurationSaveStateIsFalse() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .saveState(false) .build(); // @formatter:on @@ -118,6 +125,7 @@ void testConfigurationMaxItemCount() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .maxItemCount(2) .build(); // @formatter:on diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index 4ff74bae8b..324dfe8f45 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -67,6 +67,7 @@ void setUp() { Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.BATCH)).thenReturn(this.sqlSession); Map parameters = new HashMap<>(); parameters.put("id", 1); + parameters.put("name", "Doe"); parameters.put("_page", 0); parameters.put("_pagesize", 10); parameters.put("_skiprows", 0); @@ -80,6 +81,7 @@ void testConfiguration() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .build(); // @formatter:on itemReader.afterPropertiesSet(); @@ -105,6 +107,7 @@ void testConfigurationSaveStateIsFalse() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .saveState(false) .build(); // @formatter:on @@ -128,6 +131,7 @@ void testConfigurationMaxItemCount() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .maxItemCount(2) .build(); // @formatter:on @@ -152,6 +156,7 @@ void testConfigurationPageSize() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) + .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) .pageSize(2) .build(); // @formatter:on @@ -160,6 +165,7 @@ void testConfigurationPageSize() throws Exception { Map parameters = new HashMap<>(); parameters.put("id", 1); parameters.put("_page", 0); + parameters.put("name", "Doe"); parameters.put("_pagesize", 2); parameters.put("_skiprows", 0); Mockito.when(this.sqlSession.selectList("selectFoo", parameters)).thenReturn(getFoos()); From 24b2b759cbadff0c736b3397eb39eea9861c766d Mon Sep 17 00:00:00 2001 From: shica Date: Mon, 26 Sep 2022 20:36:18 +0800 Subject: [PATCH 446/933] refine parameterValuesSupplier --- .../spring/batch/MyBatisCursorItemReader.java | 16 ++++++++-------- .../spring/batch/MyBatisPagingItemReader.java | 16 ++++++++-------- .../builder/MyBatisCursorItemReaderBuilder.java | 15 +++++++++------ .../builder/MyBatisPagingItemReaderBuilder.java | 15 +++++++++------ .../MyBatisCursorItemReaderBuilderTest.java | 6 +++--- .../MyBatisPagingItemReaderBuilderTest.java | 8 ++++---- 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java index 038646c6fc..8bc0b3330c 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Optional; import java.util.function.Supplier; import org.apache.ibatis.cursor.Cursor; @@ -42,7 +43,7 @@ public class MyBatisCursorItemReader extends AbstractItemCountingItemStreamIt private SqlSession sqlSession; private Map parameterValues; - private Supplier> parameterSupplier; + private Supplier> parameterValuesSupplier; private Cursor cursor; private Iterator cursorIterator; @@ -67,10 +68,7 @@ protected void doOpen() throws Exception { parameters.putAll(parameterValues); } - Map dynamicParameters; - if (parameterSupplier != null && (dynamicParameters = parameterSupplier.get()) != null) { - parameters.putAll(dynamicParameters); - } + Optional.ofNullable(parameterValuesSupplier).map(Supplier::get).ifPresent(parameters::putAll); sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE); cursor = sqlSession.selectCursor(queryId, parameters); @@ -132,10 +130,12 @@ public void setParameterValues(Map parameterValues) { /** * The parameter supplier used to get parameter values for the query execution. * - * @param parameterSupplier + * @param parameterValuesSupplier * the supplier used to get values keyed by the parameter named used in the query string. + * + * @since 2.1.0 */ - public void setParameterSupplier(Supplier> parameterSupplier) { - this.parameterSupplier = parameterSupplier; + public void setParameterValuesSupplier(Supplier> parameterValuesSupplier) { + this.parameterValuesSupplier = parameterValuesSupplier; } } diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 978b533555..6c96b345dc 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Supplier; @@ -48,7 +49,7 @@ public class MyBatisPagingItemReader extends AbstractPagingItemReader { private Map parameterValues; - private Supplier> parameterSupplier; + private Supplier> parameterValuesSupplier; public MyBatisPagingItemReader() { setName(getShortName(MyBatisPagingItemReader.class)); @@ -87,11 +88,13 @@ public void setParameterValues(Map parameterValues) { /** * The parameter supplier used to get parameter values for the query execution. * - * @param parameterSupplier + * @param parameterValuesSupplier * the supplier used to get values keyed by the parameter named used in the query string. + * + * @since 2.1.0 */ - public void setParameterSupplier(Supplier> parameterSupplier) { - this.parameterSupplier = parameterSupplier; + public void setParameterValuesSupplier(Supplier> parameterValuesSupplier) { + this.parameterValuesSupplier = parameterValuesSupplier; } /** @@ -115,10 +118,7 @@ protected void doReadPage() { if (parameterValues != null) { parameters.putAll(parameterValues); } - Map dynamicParameters; - if (parameterSupplier != null && (dynamicParameters = parameterSupplier.get()) != null) { - parameters.putAll(dynamicParameters); - } + Optional.ofNullable(parameterValuesSupplier).map(Supplier::get).ifPresent(parameters::putAll); parameters.put("_page", getPage()); parameters.put("_pagesize", getPageSize()); parameters.put("_skiprows", getPage() * getPageSize()); diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java index 98f696a5d5..da81b4e227 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java @@ -36,7 +36,7 @@ public class MyBatisCursorItemReaderBuilder { private SqlSessionFactory sqlSessionFactory; private String queryId; private Map parameterValues; - private Supplier> parameterSupplier; + private Supplier> parameterValuesSupplier; private Boolean saveState; private Integer maxItemCount; @@ -88,15 +88,18 @@ public MyBatisCursorItemReaderBuilder parameterValues(Map par /** * Set the parameter supplier to be used to get parameters for the query execution. * - * @param parameterSupplier + * @param parameterValuesSupplier * the parameter supplier to be used to get parameters for the query execution * * @return this instance for method chaining * - * @see MyBatisCursorItemReader#setParameterSupplier(Supplier) + * @see MyBatisCursorItemReader#setParameterValuesSupplier(Supplier) + * + * @since 2.1.0 */ - public MyBatisCursorItemReaderBuilder parameterSupplier(Supplier> parameterSupplier) { - this.parameterSupplier = parameterSupplier; + public MyBatisCursorItemReaderBuilder parameterValuesSupplier( + Supplier> parameterValuesSupplier) { + this.parameterValuesSupplier = parameterValuesSupplier; return this; } @@ -141,7 +144,7 @@ public MyBatisCursorItemReader build() { reader.setSqlSessionFactory(this.sqlSessionFactory); reader.setQueryId(this.queryId); reader.setParameterValues(this.parameterValues); - reader.setParameterSupplier(this.parameterSupplier); + reader.setParameterValuesSupplier(this.parameterValuesSupplier); Optional.ofNullable(this.saveState).ifPresent(reader::setSaveState); Optional.ofNullable(this.maxItemCount).ifPresent(reader::setMaxItemCount); return reader; diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java index 45b178ed9b..4428318c79 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java @@ -36,7 +36,7 @@ public class MyBatisPagingItemReaderBuilder { private SqlSessionFactory sqlSessionFactory; private String queryId; private Map parameterValues; - private Supplier> parameterSupplier; + private Supplier> parameterValuesSupplier; private Integer pageSize; private Boolean saveState; private Integer maxItemCount; @@ -89,15 +89,18 @@ public MyBatisPagingItemReaderBuilder parameterValues(Map par /** * Set the parameter supplier to be used to get parameters for the query execution. * - * @param parameterSupplier + * @param parameterValuesSupplier * the parameter supplier to be used to get parameters for the query execution * * @return this instance for method chaining * - * @see MyBatisPagingItemReader#setParameterSupplier(Supplier) + * @see MyBatisPagingItemReader#setParameterValuesSupplier(Supplier) + * + * @since 2.1.0 */ - public MyBatisPagingItemReaderBuilder parameterSupplier(Supplier> parameterSupplier) { - this.parameterSupplier = parameterSupplier; + public MyBatisPagingItemReaderBuilder parameterValuesSupplier( + Supplier> parameterValuesSupplier) { + this.parameterValuesSupplier = parameterValuesSupplier; return this; } @@ -157,7 +160,7 @@ public MyBatisPagingItemReader build() { reader.setSqlSessionFactory(this.sqlSessionFactory); reader.setQueryId(this.queryId); reader.setParameterValues(this.parameterValues); - reader.setParameterSupplier(this.parameterSupplier); + reader.setParameterValuesSupplier(this.parameterValuesSupplier); Optional.ofNullable(this.pageSize).ifPresent(reader::setPageSize); Optional.ofNullable(this.saveState).ifPresent(reader::setSaveState); Optional.ofNullable(this.maxItemCount).ifPresent(reader::setMaxItemCount); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index 78691c2cf7..35363172b6 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -72,7 +72,7 @@ void testConfiguration() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .build(); // @formatter:on itemReader.afterPropertiesSet(); @@ -99,7 +99,7 @@ void testConfigurationSaveStateIsFalse() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .saveState(false) .build(); // @formatter:on @@ -125,7 +125,7 @@ void testConfigurationMaxItemCount() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .maxItemCount(2) .build(); // @formatter:on diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index 324dfe8f45..b936ede448 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -81,7 +81,7 @@ void testConfiguration() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .build(); // @formatter:on itemReader.afterPropertiesSet(); @@ -107,7 +107,7 @@ void testConfigurationSaveStateIsFalse() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .saveState(false) .build(); // @formatter:on @@ -131,7 +131,7 @@ void testConfigurationMaxItemCount() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .maxItemCount(2) .build(); // @formatter:on @@ -156,7 +156,7 @@ void testConfigurationPageSize() throws Exception { .sqlSessionFactory(this.sqlSessionFactory) .queryId("selectFoo") .parameterValues(Collections.singletonMap("id", 1)) - .parameterSupplier(() -> Collections.singletonMap("name", "Doe")) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) .pageSize(2) .build(); // @formatter:on From a1a27ba6050c418b6e830288c8f9720c23841bd2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 28 Sep 2022 12:39:31 +0000 Subject: [PATCH 447/933] Update dependency org.slf4j:slf4j-simple to v2.0.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bea90132e1..b8463239fe 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ org.slf4j slf4j-simple - 2.0.2 + 2.0.3 test From 55f21edfdc9a351824b50499a8b7f61b4744c003 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Oct 2022 11:50:25 +0000 Subject: [PATCH 448/933] Update dependency org.jboss.byteman:byteman-bmunit to v4.0.20 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b8463239fe..afce231ee3 100644 --- a/pom.xml +++ b/pom.xml @@ -171,7 +171,7 @@ org.jboss.byteman byteman-bmunit - 4.0.19 + 4.0.20 test From 606b931a974ddeafb163bfaddab2d29f9c2345d8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:28:57 +0000 Subject: [PATCH 449/933] Update dependency org.mockito:mockito-core to v4.8.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index afce231ee3..18163f102b 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.mockito mockito-core - 4.8.0 + 4.8.1 test From 77d8bf2e0f57acbb3b67e680b4edf95ad0ef6bc3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 22 Oct 2022 16:07:56 +0000 Subject: [PATCH 450/933] Update dependency org.hsqldb:hsqldb to v2.7.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18163f102b..c9e0278158 100644 --- a/pom.xml +++ b/pom.xml @@ -212,7 +212,7 @@ org.hsqldb hsqldb - 2.7.0 + 2.7.1 test From 306e72e47f8a2d4aa74199a879099967ed258302 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:58:19 +0000 Subject: [PATCH 451/933] Update dependency org.mockito:mockito-core to v4.9.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c9e0278158..8ba43d3bf2 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.mockito mockito-core - 4.8.1 + 4.9.0 test From 71dccee33a3c7781ccb87cc1c3dd3e2d3f7ece80 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 16 Nov 2022 09:27:49 +0000 Subject: [PATCH 452/933] Update spring core to v5.3.24 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c9e0278158..8e34aad366 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.11 - 5.3.23 + 5.3.24 4.3.7 org.mybatis.spring From c7f546f192ca5c93c45313b45db2bdf44af1620d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 17 Nov 2022 21:20:06 +0000 Subject: [PATCH 453/933] Update dependency org.slf4j:slf4j-simple to v2.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec2d88fec6..9e6bc01253 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ org.slf4j slf4j-simple - 2.0.3 + 2.0.4 test From dc152067598ab7f840efb68482ff8bdcf07207cb Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 23 Nov 2022 11:56:17 +0900 Subject: [PATCH 454/933] Remove doJumpToPage method on MyBatisPagingItemReader Fixes gh-739 --- .../org/mybatis/spring/batch/MyBatisPagingItemReader.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 6c96b345dc..c459c39c59 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -130,9 +130,4 @@ protected void doReadPage() { results.addAll(sqlSessionTemplate.selectList(queryId, parameters)); } - @Override - protected void doJumpToPage(int itemIndex) { - // Not Implemented - } - } From b77435bf4a6160cb550db202f0f5793cd76f878c Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Wed, 23 Nov 2022 11:57:38 +0900 Subject: [PATCH 455/933] Add @SpringBatchTest on spring batch integration tests Fixes gh-740 --- .../java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java | 2 ++ .../java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java index 759d7a2d92..7f6c32c699 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java @@ -16,9 +16,11 @@ package org.mybatis.spring.sample; import org.mybatis.spring.sample.config.SampleJobConfig; +import org.springframework.batch.test.context.SpringBatchTest; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @SpringJUnitConfig({ SampleJobConfig.class, AbstractSampleJobTest.LocalContext.class }) +@SpringBatchTest class SampleJobJavaConfigTest extends AbstractSampleJobTest { @Override protected String getExpectedOperationBy() { diff --git a/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java index 461e9bf3c1..7dfe2f3691 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java @@ -15,11 +15,13 @@ */ package org.mybatis.spring.sample; +import org.springframework.batch.test.context.SpringBatchTest; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @SpringJUnitConfig({ AbstractSampleJobTest.LocalContext.class, SampleJobXmlConfigTest.LocalContext.class }) +@SpringBatchTest class SampleJobXmlConfigTest extends AbstractSampleJobTest { @Override From e915e1f5b33a130e0c862dd786d2336a87f9c2b4 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 24 Nov 2022 02:27:50 +0900 Subject: [PATCH 456/933] Compile with -parameters option Closes gh-742 --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index f0eeec7855..28d1742951 100644 --- a/pom.xml +++ b/pom.xml @@ -311,6 +311,13 @@ + + maven-compiler-plugin + + -parameters + -parameters + + org.apache.maven.plugins maven-surefire-plugin From 39602b1fc25d8ddd3fe0b1dde696f157c928a7e7 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 24 Nov 2022 09:33:58 +0900 Subject: [PATCH 457/933] Change to use maven.compiler.parameters See gh-742 --- pom.xml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 28d1742951..3d3933d147 100644 --- a/pom.xml +++ b/pom.xml @@ -112,6 +112,9 @@ 5.9.1 + + true + 1757561022 @@ -311,13 +314,6 @@ - - maven-compiler-plugin - - -parameters - -parameters - - org.apache.maven.plugins maven-surefire-plugin From 367cd5a3bd6fb34fcb4ea5874e60a6d56b02ac08 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 24 Nov 2022 23:19:06 +0900 Subject: [PATCH 458/933] Update to spring-framework 6.0.1 Closes gh-747 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3d3933d147..529597c411 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ * 3.5.11 - 6.0.0-SNAPSHOT + 6.0.1 5.0.0-SNAPSHOT org.mybatis.spring From 19ce87558eea5ff281130a5c0193c5a909c947bd Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Thu, 24 Nov 2022 23:19:27 +0900 Subject: [PATCH 459/933] Update to spring-batch 5.0.0 Closes gh-747 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 529597c411..60d59e0dbe 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.5.11 6.0.1 - 5.0.0-SNAPSHOT + 5.0.0 org.mybatis.spring 5.9.1 From a1c328de17cd025341f407bbbd6e5fbcb9768df6 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 25 Nov 2022 08:02:09 +0900 Subject: [PATCH 460/933] Add java.version=17 on 3.x --- .github/workflows/ci.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- pom.xml | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dba82c0e24..8a1e48a857 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,4 +42,4 @@ jobs: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - name: Test with Maven - run: ./mvnw test -B -D"license.skip=true" -D"enforcer.skip=true" + run: ./mvnw test -B -D"license.skip=true" diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index df3ec31ab0..92953b4640 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -33,7 +33,7 @@ jobs: distribution: zulu - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -Denforcer.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER + run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 40c6300f32..15d005a80b 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -36,7 +36,7 @@ jobs: java-version: 17 distribution: zulu - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true -Denforcer.skip=true + run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 88bcd02e70..07ba21fde2 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -33,7 +33,7 @@ jobs: java-version: 17 distribution: zulu - name: Deploy to Sonatype - run: ./mvnw deploy -DskipTests -Denforcer.skip=true -B --settings ./.mvn/settings.xml -Dlicense.skip=true + run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} diff --git a/pom.xml b/pom.xml index 60d59e0dbe..d14d7f729e 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,7 @@ Spring org.springframework.batch.*;resolution:=optional,* * + 17 3.5.11 6.0.1 From 74a474b61dc61ec2f0872fbeb07e0439536f66c4 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 25 Nov 2022 08:19:54 +0900 Subject: [PATCH 461/933] Update to spring-framework 6.0.2 Closes gh-750 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d14d7f729e..aa9e9830e5 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 17 3.5.11 - 6.0.1 + 6.0.2 5.0.0 org.mybatis.spring From 0d522e7d66da2586ee933fd6e1f4710d35e8fa2b Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 25 Nov 2022 08:36:37 +0900 Subject: [PATCH 462/933] Drop jdk 18, add 20-ea, and update 19 to ga --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 243038d58c..5502c5b32b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - java: [11, 17, 18, 19-ea] + java: [11, 17, 19, 20-ea] distribution: ['zulu'] fail-fast: false max-parallel: 5 From 0e9d32e68b6566b7227803a96071095a503daa41 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 25 Nov 2022 08:53:20 +0900 Subject: [PATCH 463/933] Drop enforcer.skip --- .github/workflows/coveralls.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 92953b4640..ac387747b0 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -39,6 +39,6 @@ jobs: PR_NUMBER: ${{ github.event.number }} - name: Report Coverage to Coveralls for General Push if: github.event_name == 'push' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -Denforcer.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github + run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 6ce7d21f14d7941fdfcb0099887bf425ebd36cc5 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 25 Nov 2022 12:29:15 +0900 Subject: [PATCH 464/933] Prepare to merge to master for release 3.0.0 --- .github/workflows/ci.yaml | 2 -- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 957480d17f..ed83d5edd7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,8 +19,6 @@ name: Java CI on: push: pull_request: - schedule: - - cron: "0 0 * * *" jobs: test: diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 15d005a80b..eda5f33114 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -19,7 +19,7 @@ name: SonarCloud on: push: branches: - - 3.x + - master jobs: build: diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 07ba21fde2..008954a7f3 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -19,7 +19,7 @@ name: Sonatype on: push: branches: - - 3.x + - master jobs: build: From 3150039ddedfbf0dacd45945b235265a7a232707 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 25 Nov 2022 20:58:58 +0900 Subject: [PATCH 465/933] Update README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f6df7c6962..e4ec694397 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,8 @@ MyBatis-Spring adapter is an easy-to-use Spring bridge for MyBatis sql mapping f Supported Versions ------------------ -- 3.x - Support for Spring 6 and Spring Batch 5 (**not release yet**) -- master (2.1.x) - Enhance and maintenance for Spring 5 and Spring Batch 4 (**not release yet**) -- 2.0.x - Support for Java 8, Spring 5, and Junit 5 plus other java 8 requirements +- master - Support for Spring 6 and Spring Batch 5 +- 2.1.x - Enhance and maintenance for Spring 5 and Spring Batch 4 - 1.3.x - Continued support for Java 6 and 7 Essentials From e357e06e634829c832a515dddc95b219aa8a0972 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Fri, 25 Nov 2022 21:51:15 +0900 Subject: [PATCH 466/933] [maven-release-plugin] prepare release mybatis-spring-3.0.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index aa9e9830e5..58085c6efc 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.0-SNAPSHOT + 3.0.0 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.0 GitHub Issue Management @@ -117,7 +117,7 @@ true - 1757561022 + 1669380647 From 64196e05e4e4fbb830e892f57239633e49076c7a Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Fri, 25 Nov 2022 21:51:20 +0900 Subject: [PATCH 467/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 58085c6efc..1cd8f9eec9 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.0 + 3.0.1-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.0 + HEAD GitHub Issue Management @@ -117,7 +117,7 @@ true - 1669380647 + 1669380680 From c9148ceae772796f52c74d620a8a56bfdaeacd60 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:20:33 +0000 Subject: [PATCH 468/933] Update dependency org.slf4j:slf4j-simple to v2.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1cd8f9eec9..00f15f1118 100644 --- a/pom.xml +++ b/pom.xml @@ -223,7 +223,7 @@ org.slf4j slf4j-simple - 2.0.4 + 2.0.5 test From e6ea1350b1e4e4f0b83e9960a5af1148ebcbb484 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 26 Nov 2022 12:12:48 +0900 Subject: [PATCH 469/933] Fix javadoc error on MyBatisBatchItemWriter --- .../java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index 42118df358..1da81f0547 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -42,7 +42,7 @@ *

    * The user must provide a MyBatis statement id that points to the SQL statement defined in the MyBatis. *

    - * It is expected that {@link #write(List)} is called inside a transaction. If it is not each statement call will be + * It is expected that {@link #write(Chunk)} is called inside a transaction. If it is not each statement call will be * autocommitted and flushStatements will return no results. *

    * The writer is thread safe after its properties are set (normal singleton behavior), so it can be used to write in From 42aad517003d3d5ce9f924068d2338b4dae9adc2 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 27 Nov 2022 19:59:39 +0900 Subject: [PATCH 470/933] MapperScannerConfigurer#includeAnnotationConfig set to false in native image Fixes gh-757 --- .../java/org/mybatis/spring/mapper/ClassPathMapperScanner.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 7268202265..79686eb5b0 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -36,6 +36,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; +import org.springframework.core.NativeDetector; import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.util.StringUtils; @@ -84,6 +85,7 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { public ClassPathMapperScanner(BeanDefinitionRegistry registry) { super(registry, false); + setIncludeAnnotationConfig(!NativeDetector.inNativeImage()); } public void setAddToConfig(boolean addToConfig) { From b4b5ed65e14cc2a04f7d16651c5a019368aab314 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 28 Nov 2022 08:54:35 +0900 Subject: [PATCH 471/933] Add a new option whether print warning log if not found mappers that matches conditions on ClassPathMapperScanner Fixes gh-761 --- .../spring/mapper/ClassPathMapperScanner.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 79686eb5b0..617095f7f8 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -67,6 +67,8 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { private boolean lazyInitialization; + private boolean printWarnLogIfNotFoundMappers = true; + private SqlSessionFactory sqlSessionFactory; private SqlSessionTemplate sqlSessionTemplate; @@ -86,6 +88,7 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { public ClassPathMapperScanner(BeanDefinitionRegistry registry) { super(registry, false); setIncludeAnnotationConfig(!NativeDetector.inNativeImage()); + setPrintWarnLogIfNotFoundMappers(!NativeDetector.inNativeImage()); } public void setAddToConfig(boolean addToConfig) { @@ -111,6 +114,21 @@ public void setLazyInitialization(boolean lazyInitialization) { this.lazyInitialization = lazyInitialization; } + /** + * Set whether print warning log if not found mappers that matches conditions. + *

    + * Default is {@code true}. But {@code false} when running in native image. + *

    + * + * @param printWarnLogIfNotFoundMappers + * Set the @{code true} to print + * + * @since 3.0.1 + */ + public void setPrintWarnLogIfNotFoundMappers(boolean printWarnLogIfNotFoundMappers) { + this.printWarnLogIfNotFoundMappers = printWarnLogIfNotFoundMappers; + } + public void setMarkerInterface(Class markerInterface) { this.markerInterface = markerInterface; } @@ -211,8 +229,10 @@ public Set doScan(String... basePackages) { Set beanDefinitions = super.doScan(basePackages); if (beanDefinitions.isEmpty()) { - LOGGER.warn(() -> "No MyBatis mapper was found in '" + Arrays.toString(basePackages) - + "' package. Please check your configuration."); + if (printWarnLogIfNotFoundMappers) { + LOGGER.warn(() -> "No MyBatis mapper was found in '" + Arrays.toString(basePackages) + + "' package. Please check your configuration."); + } } else { processBeanDefinitions(beanDefinitions); } From 517cabad29e3a972cb24768da60507c96cbba4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 3 Dec 2022 17:47:02 +0100 Subject: [PATCH 472/933] filter site content without hijacking main resources fixes #759 --- pom.xml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 00f15f1118..42512c568e 100644 --- a/pom.xml +++ b/pom.xml @@ -331,14 +331,35 @@
    + + org.apache.maven.plugins + maven-resources-plugin + + + filter-site + pre-site + + copy-resources + + + ${project.build.directory}/site-src + + + src/site + true + + + + + + org.apache.maven.plugins maven-site-plugin en,es,zh_CN,ja,ko - ${project.build.directory}/site-src - +
    @@ -354,12 +375,6 @@ ${project.basedir}/src/main/resources - - - ${project.basedir}/src/site - ${project.build.directory}/site-src - true - From 29b25913b43ca3f207f1bf539b99c1310b09b7a1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 00:16:36 +0000 Subject: [PATCH 473/933] Update dependency org.apache.derby:derby to v10.16.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00f15f1118..f3363daa1e 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ org.apache.derby derby - 10.14.2.0 + 10.16.1.1 test From 9ead0cd78ca1d5c192efc6519be0c117e016f661 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 4 Dec 2022 19:42:33 -0500 Subject: [PATCH 474/933] [pom] Move comment so its not trailing --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d9f32eecef..743518c933 100644 --- a/pom.xml +++ b/pom.xml @@ -331,10 +331,11 @@
    - + org.apache.maven.plugins maven-resources-plugin + filter-site pre-site From 6f6fd1799d06ced6e1ac9f11a58fa9cd5a19efbb Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 5 Dec 2022 08:56:37 -0500 Subject: [PATCH 475/933] [pom] Fix java release version: must be 17 was mixing meta data with source/target at 17 but release at 8, surprising it worked to compile... --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 743518c933..064728939e 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,10 @@ Spring org.springframework.batch.*;resolution:=optional,* * + + 17 + 17 3.5.11 6.0.2 From 5653a6b9fba6590e41912c824f0755cfb8ad95f2 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:30:43 -0500 Subject: [PATCH 476/933] [maven-release-plugin] prepare release mybatis-spring-3.0.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 064728939e..9c5d1d1d96 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.1-SNAPSHOT + 3.0.1 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.1 GitHub Issue Management @@ -120,7 +120,7 @@ true - 1669380680 + 1670545799 From 4879017fca4ef6f5d24ed9a6a29f31f9efcf934b Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:30:46 -0500 Subject: [PATCH 477/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9c5d1d1d96..4138e9e4f6 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.1 + 3.0.2-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.1 + HEAD GitHub Issue Management @@ -120,7 +120,7 @@ true - 1670545799 + 1670545846 From ec9c46b3296ac9c6f6bdcaa9b7434f93001caa3e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:31:31 -0500 Subject: [PATCH 478/933] [git] add release files to ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8a1aa32238..001d888176 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ *.iml /.idea .mvn/wrapper/maven-wrapper.jar +release.properties +*.releaseBackup From a54274266a184efbeb6fdab3282c53ce8b1320af Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:40:31 -0500 Subject: [PATCH 479/933] [pom] Add java.sql to modules for javadocs due to known issue with maven plugin incorrectly determining modular usage, let it be modular there so the build works. --- pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pom.xml b/pom.xml index 4138e9e4f6..4e51983d6b 100644 --- a/pom.xml +++ b/pom.xml @@ -365,6 +365,17 @@ ${project.build.directory}/site-src + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + + +
    From 36154e12d07bec69d3491a973a01b5df5508db9a Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:44:20 -0500 Subject: [PATCH 480/933] [pom] Add java.xml module as well for dom --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 4e51983d6b..dc96a92787 100644 --- a/pom.xml +++ b/pom.xml @@ -373,6 +373,8 @@ + + From 7133b5b71e98b7f436b6aa88f3e94bcadfdd3b25 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:46:01 -0500 Subject: [PATCH 481/933] [maven-release-plugin] prepare release mybatis-spring-3.0.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index dc96a92787..d741dc34c3 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.2-SNAPSHOT + 3.0.1 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.1 GitHub Issue Management @@ -120,7 +120,7 @@ true - 1670545846 + 1670546724 From d5581502d4ac6398929a14adaf0455553748eddc Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 8 Dec 2022 19:46:04 -0500 Subject: [PATCH 482/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d741dc34c3..7127f81eba 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.1 + 3.0.2-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.1 + HEAD GitHub Issue Management @@ -120,7 +120,7 @@ true - 1670546724 + 1670546764 From 3395b1e5fd915958138f08ee4cdcdd65e5b96ef1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Dec 2022 22:18:44 +0000 Subject: [PATCH 483/933] Update dependency org.slf4j:slf4j-simple to v2.0.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7127f81eba..43aa82a863 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.slf4j slf4j-simple - 2.0.5 + 2.0.6 test From b550b1c0110894c292bf27bffd3b5f78db4b4bc9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Dec 2022 10:57:49 +0000 Subject: [PATCH 484/933] Update spring core to v6.0.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 43aa82a863..0edfd0a6d0 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.11 - 6.0.2 + 6.0.3 5.0.0 org.mybatis.spring From 30e62869a3f9e7ffa9b04b5040b97e504e471b52 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 30 Dec 2022 23:27:06 +0000 Subject: [PATCH 485/933] Update dependency org.mybatis:mybatis-parent to v37 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0edfd0a6d0..55bf87666c 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 36 + 37 From 1b8bef021f378b8148c6e7498369cda636780873 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 17:42:38 +0000 Subject: [PATCH 486/933] Update dependency org.assertj:assertj-core to v3.24.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 55bf87666c..972f933562 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ org.assertj assertj-core - 3.23.1 + 3.24.1 test From 9dbdcbbb69a7c05753d47185e9fa055a9247a018 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:42:16 +0000 Subject: [PATCH 487/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.9.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 972f933562..6d1061cb2b 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 5.0.0 org.mybatis.spring - 5.9.1 + 5.9.2 true From 34eee7e5c0f4b38d56581094c69cad5245d29113 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 14:54:12 +0000 Subject: [PATCH 488/933] Update spring core to v6.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6d1061cb2b..24fded18fa 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.11 - 6.0.3 + 6.0.4 5.0.0 org.mybatis.spring From ae8a9baff3392a00bb8f4536af8afca39908ecf2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 00:33:58 +0000 Subject: [PATCH 489/933] Update dependency org.assertj:assertj-core to v3.24.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 24fded18fa..0180f41e9f 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ org.assertj assertj-core - 3.24.1 + 3.24.2 test From b0353f9b5422d2e8a8b4d94e6772578c98c3c6d8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 06:41:26 +0000 Subject: [PATCH 490/933] Update dependency maven to v3.8.7 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index dc3affce3d..ca5ab4bab1 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar From 278e72f036907433a06b8685844fdd23633c4ef6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:08:47 +0000 Subject: [PATCH 491/933] Update dependency maven to v3.9.0 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ca5ab4bab1..6686a643d7 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar From b954be1c76fe03923451545da32c8cab90e7ae48 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 19:20:25 +0000 Subject: [PATCH 492/933] Update spring core to v6.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0180f41e9f..39a4d7403b 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.11 - 6.0.4 + 6.0.5 5.0.0 org.mybatis.spring From a219149de6f3e9bdcfb904f818f32a409076b721 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 00:59:32 +0000 Subject: [PATCH 493/933] Update spring batch to v5.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 39a4d7403b..6bfbe9e929 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 3.5.11 6.0.5 - 5.0.0 + 5.0.1 org.mybatis.spring 5.9.2 From c651766d6ae4348da8687ea187c5b0861b0e0876 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 05:14:15 +0000 Subject: [PATCH 494/933] Update dependency org.mybatis:mybatis to v3.5.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6bfbe9e929..84cd09fc01 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ 17 17 - 3.5.11 + 3.5.12 6.0.5 5.0.1 org.mybatis.spring From 8facc32f4b0dac3273bbeb242a19db71afcfdd73 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Mar 2023 21:09:08 +0000 Subject: [PATCH 495/933] Update spring core to v6.0.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84cd09fc01..f910678b1e 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.12 - 6.0.5 + 6.0.6 5.0.1 org.mybatis.spring From 52916d5c32cd1862277a4e7bbff22ead9cc2480a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 11 Mar 2023 12:01:41 +0000 Subject: [PATCH 496/933] Update dependency org.mybatis:mybatis to v3.5.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f910678b1e..3460880f30 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ 17 17 - 3.5.12 + 3.5.13 6.0.6 5.0.1 org.mybatis.spring From e3a0e56d2ca18fa75701049ea044760c7fc8a095 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 12 Mar 2023 18:03:01 +0000 Subject: [PATCH 497/933] Update dependency maven-wrapper to v3.2.0 --- .mvn/wrapper/maven-wrapper.properties | 4 +- mvnw | 218 +++++++++++++------------- mvnw.cmd | 31 +++- 3 files changed, 131 insertions(+), 122 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 6686a643d7..08ea486aa5 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/mvnw b/mvnw index 5643201c7d..8d937f4c14 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script +# Apache Maven Wrapper startup batch script, version 3.2.0 # # Required ENV vars: # ------------------ @@ -27,7 +27,6 @@ # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -54,7 +53,7 @@ fi cygwin=false; darwin=false; mingw=false -case "`uname`" in +case "$(uname)" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true @@ -62,9 +61,9 @@ case "`uname`" in # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME else - export JAVA_HOME="/Library/Java/Home" + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME fi fi ;; @@ -72,68 +71,38 @@ esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + JAVA_HOME=$(java-config --jre-home) fi fi -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" fi if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" else - javaExecutable="`readlink -f \"$javaExecutable\"`" + javaExecutable="$(readlink -f "\"$javaExecutable\"")" fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') JAVA_HOME="$javaHome" export JAVA_HOME fi @@ -149,7 +118,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="`\\unset -f command; \\command -v java`" + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" fi fi @@ -163,12 +132,9 @@ if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" @@ -184,96 +150,99 @@ find_maven_basedir() { fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + wdir=$(cd "$wdir/.." || exit 1; pwd) fi # end of workaround done - echo "${basedir}" + printf '%s' "$(cd "$basedir" || exit 1; pwd)" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" fi } -BASE_DIR=`find_maven_basedir "$(pwd)"` +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") if [ -z "$BASE_DIR" ]; then exit 1; fi +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. ########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi + log "Couldn't find $wrapperJarPath, downloading it ..." + if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" else - jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") fi if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" fi elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" fi - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" # For Cygwin, switch paths to Windows format before running javac if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" fi fi fi @@ -282,35 +251,58 @@ fi # End of extension ########################################################################################## -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi fi + MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") fi # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +# shellcheck disable=SC2086 # safe args exec "$JAVACMD" \ $MAVEN_OPTS \ $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 8a15b7f311..c4586b564e 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,13 +18,12 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script +@REM Apache Maven Wrapper startup batch script, version 3.2.0 @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @@ -120,10 +119,10 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B ) @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central @@ -134,11 +133,11 @@ if exist %WRAPPER_JAR% ( ) ) else ( if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" ) if "%MVNW_VERBOSE%" == "true" ( echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% + echo Downloading from: %WRAPPER_URL% ) powershell -Command "&{"^ @@ -146,7 +145,7 @@ if exist %WRAPPER_JAR% ( "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ "}" if "%MVNW_VERBOSE%" == "true" ( echo Finished downloading %WRAPPER_JAR% @@ -154,6 +153,24 @@ if exist %WRAPPER_JAR% ( ) @REM End of extension +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + @REM Provide a "standardized" way to retrieve the CLI args that will @REM work with both Windows and non-Windows executions. set MAVEN_CMD_LINE_ARGS=%* From 380055d539d8e754396ea71de2990c01d33acb13 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 21:12:36 +0000 Subject: [PATCH 498/933] Update dependency org.slf4j:slf4j-simple to v2.0.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3460880f30..af80ab8e96 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,7 @@ org.slf4j slf4j-simple - 2.0.6 + 2.0.7 test From 9b273cf6b4545b4850754351f344d7c278f00632 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 18 Mar 2023 11:30:17 +0000 Subject: [PATCH 499/933] Update dependency maven to v3.9.1 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 08ea486aa5..d8b2495a1e 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 100136570bdfa55f90a3620c688a13dad2956d39 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:23:37 +0000 Subject: [PATCH 500/933] Update spring core to v6.0.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index af80ab8e96..951340b102 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.6 + 6.0.7 5.0.1 org.mybatis.spring From e8a2a571db8c6d0adbae1d919863b5328e8e8477 Mon Sep 17 00:00:00 2001 From: "sky.yann" Date: Tue, 28 Mar 2023 23:26:14 +0800 Subject: [PATCH 501/933] fix: change the event type that SqlSessionFactory is listening to --- .../java/org/mybatis/spring/SqlSessionFactoryBean.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index c64328ec51..2103aea282 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -54,7 +54,6 @@ import org.mybatis.spring.transaction.SpringManagedTransactionFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.event.ContextRefreshedEvent; @@ -87,7 +86,7 @@ * @see #setDataSource */ public class SqlSessionFactoryBean - implements FactoryBean, InitializingBean, ApplicationListener { + implements FactoryBean, InitializingBean, ApplicationListener { private static final Logger LOGGER = LoggerFactory.getLogger(SqlSessionFactoryBean.class); @@ -658,8 +657,8 @@ public boolean isSingleton() { * {@inheritDoc} */ @Override - public void onApplicationEvent(ApplicationEvent event) { - if (failFast && event instanceof ContextRefreshedEvent) { + public void onApplicationEvent(ContextRefreshedEvent event) { + if (failFast) { // fail-fast -> check all statements are completed this.sqlSessionFactory.getConfiguration().getMappedStatementNames(); } From 04a962c934812c195e9b1479dca03e2089881a21 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 25 Jan 2023 16:42:42 -0500 Subject: [PATCH 502/933] [ci] import sorting --- src/test/java/org/mybatis/spring/MyBatisSpringTest.java | 6 +++--- .../org/mybatis/spring/submitted/xa/UserServiceTest.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java index 2b5f43f5d5..01d980929c 100644 --- a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,8 @@ import com.mockrunner.mock.jdbc.MockDataSource; import com.mockrunner.mock.jdbc.MockPreparedStatement; +import jakarta.transaction.UserTransaction; + import org.apache.ibatis.exceptions.PersistenceException; import org.apache.ibatis.mapping.Environment; import org.apache.ibatis.session.ExecutorType; @@ -38,8 +40,6 @@ import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.support.DefaultTransactionDefinition; -import jakarta.transaction.UserTransaction; - class MyBatisSpringTest extends AbstractMyBatisSpringTest { private SqlSession session; diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java index 0aeeac48b7..60a59ab50e 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; +import jakarta.transaction.UserTransaction; + import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -24,8 +26,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import jakarta.transaction.UserTransaction; - @Disabled("Yet not found OSS implementation that supported Jakarta EE 9+ APIs") @ExtendWith(SpringExtension.class) @SpringJUnitConfig(locations = "classpath:org/mybatis/spring/submitted/xa/applicationContext.xml") From 6610a6a5d9364bd5c7d9691ef223f7e697826d60 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 25 Jan 2023 16:42:58 -0500 Subject: [PATCH 503/933] [tests] Bump mockito to 5.2.0 and continue using mockito subclass mocking --- pom.xml | 10 ++++++++-- .../mybatis/spring/sample/SampleSqlSessionTest.java | 2 +- .../mockito-extensions/org.mockito.plugins.MockMaker | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/pom.xml b/pom.xml index 951340b102..d1ff20b5ad 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - true - 1670546764 From 1da1624030b2e18452a87715a014f4c9d2827419 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 20:43:51 -0400 Subject: [PATCH 517/933] [pom] Override jacoco to 0.8.9 --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 11dbf0aefa..50502b9f2e 100644 --- a/pom.xml +++ b/pom.xml @@ -118,6 +118,9 @@ 1670546764 + + + 0.8.9 From c9284672f733cba195f772ff86c7e2c5e104030d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 20:51:10 -0400 Subject: [PATCH 518/933] [test] Remove mockito extension as it did not work --- pom.xml | 6 ------ .../org/mybatis/spring/sample/SampleSqlSessionTest.java | 3 --- 2 files changed, 9 deletions(-) diff --git a/pom.xml b/pom.xml index 50502b9f2e..5925c45579 100644 --- a/pom.xml +++ b/pom.xml @@ -236,12 +236,6 @@ 5.2.0 test
    - - org.mockito - mockito-junit-jupiter - 5.2.0 - test - org.assertj diff --git a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java index 69f330cf93..c8750d6cc9 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; import org.mybatis.spring.sample.domain.User; import org.mybatis.spring.sample.service.BarService; import org.springframework.beans.factory.annotation.Autowired; @@ -30,7 +28,6 @@ * Example of basic MyBatis-Spring integration usage with a manual DAO implementation that subclasses * SqlSessionDaoSupport. */ -@ExtendWith(MockitoExtension.class) @DirtiesContext @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-sqlsession.xml" }) class SampleSqlSessionTest { From 97904b5729feb7fe2394031a40e57a8ab5f099e1 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 20:59:42 -0400 Subject: [PATCH 519/933] [test] Remove dirties context annotation mockito seems to trip on this with its auto mocking since 4.10.0. Trying to see if this is really necessary on this test... --- .../java/org/mybatis/spring/sample/SampleSqlSessionTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java index c8750d6cc9..8f2a8a02a0 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java @@ -21,14 +21,12 @@ import org.mybatis.spring.sample.domain.User; import org.mybatis.spring.sample.service.BarService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Example of basic MyBatis-Spring integration usage with a manual DAO implementation that subclasses * SqlSessionDaoSupport. */ -@DirtiesContext @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-sqlsession.xml" }) class SampleSqlSessionTest { From 828e6a5731ee1c4637fbb2c7e8a69a9f6fa81be1 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 21:08:50 -0400 Subject: [PATCH 520/933] [cleanup] Delete really old changes.xml we don't use --- src/changes/changes.xml | 201 ---------------------------------------- 1 file changed, 201 deletions(-) delete mode 100644 src/changes/changes.xml diff --git a/src/changes/changes.xml b/src/changes/changes.xml deleted file mode 100644 index 9af855ece9..0000000000 --- a/src/changes/changes.xml +++ /dev/null @@ -1,201 +0,0 @@ - - - - - The MyBatis Team - Changes - - - - - - mybatis-spring OSGi imports - Spring batch should be optional - - - org.mybatis.spring.transaction.SpringManagedTransaction.logger should be static - - - - - Build a namespace for MyBatis - - - mybatis-spring OSGi imports - Spring batch should be optional - - - Allow setting the super type for domain classes when scanning for type aliases via Spring - - - MapperScannerConfigurer can't work with AnnotationConfigApplicationContext - - - Remove finals in SqlSessionDaoSupport to enable adding Qualifiers - - - Proxy message by istantiating Objects with Spring - - - SqlSessionFactoryBean: add setters for Object[Wrapper]Factory - - - MapperScannerConfigurer should allow setting a BeanNameGenerator - - - - - 2nd level cache consistency with MyBatis-Spring - - - Overriding sqlSessionTemplate in MapperFactoryBean not working in certain circumstances - - - MapperScannerConfigurer causes app initialization problems - - - - - Prevent class loading / add zero-method mappers while scanning for mappers - - - Lazy loads do not execute within Spring-managed transactions - - - MapperScannerConfigurer does not work with PropertyPlaceholderConfigurer - - - - - Add SqlSession.flushStatements() - - - configurationProperties not applied in mappings - - - SqlSessionTemplate throws NullPointerException if ExceptionTranslator cannot translate - exception - - - Replace BeanPostProcessor with BeanDefinitionRegistryPostProcessor - - - - - Added a fail fast checking to ensure that all statements are fully loaded - - - SqlSessionFactoryBean should allow sql fragments to be shared across multiple mapper - files - - - Spring MapperScannerConfigurer does not work properly in OSGi - - - Enable typehandler and alias registration in mybatis-spring - - - - - Support multiple character sets (parse XML from InputStream vs. Reader) - - - Reset error context after calling XMLConfigBuilder or XMLMapperBuilder - - - SqlSession rolls back with no Spring Tx + autocommit=false + dirty=true (an - update was executed) - - - setTransactionFactoryProperties property in SqlSessionFactory has been removed - - - setTransactionFactoryClass property in SqlSessionFactory has been replaced by - setTransactionFactory - - - Improved logging - - - Doesn't propagate exceptions up the stack when using batch mode - - - - - - getSqlSessionTemplate() method in SqlSessionDaoSupport has been replaced by getSqlSession() - - - MapperFactoryBean has been moved to org.mybatis.spring.mapper.MapperFactoryBean - - - MapperScannerPostProcessor has been moved to org.mybatis.spring.mapper.MapperScannerConfigurer - - - Removed @Mapper annotation - - - Mapper scanning should not rely on proprietary @Mapper annotation - - - Avoid one Proxy creation when using injected mappers - - - Add new selectMap methods to SqlSessionTemplate - - - - - - Improved documentation manual. - - - Add operation select(String, ResultHandler) - - - Component Scan for Mappers - - - SqlSessionCallback.doInSqlSession should not throw SqlException - - - getExceptionTranslator() may not be called in mybatis-spring - - - Setting a specific datasource for one mapper does not work - - - should not let changing the executor type during a tx - - - mapperLocations does not work for xml files inside JARs - - - Use a reference to SqlSessionFactory in MapperScanner - - - - - - First RC release. - - - - - From 67417b3546b063ae72a7a5108948d33af4dcb0d7 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 21:13:33 -0400 Subject: [PATCH 521/933] [tests] Figured mockito out, was hidden in xml (wasn't expecting that) --- .../spring/sample/config/applicationContext-sqlsession.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml b/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml index a547d15585..ea8ee39c57 100644 --- a/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml +++ b/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml @@ -1,7 +1,7 @@ - - - + From d520290b9869b3dde2328a6221f885f03238f49d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 21:13:41 -0400 Subject: [PATCH 522/933] Revert "[test] Remove dirties context annotation" This reverts commit 97904b5729feb7fe2394031a40e57a8ab5f099e1. --- .../java/org/mybatis/spring/sample/SampleSqlSessionTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java index 8f2a8a02a0..c8750d6cc9 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java @@ -21,12 +21,14 @@ import org.mybatis.spring.sample.domain.User; import org.mybatis.spring.sample.service.BarService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Example of basic MyBatis-Spring integration usage with a manual DAO implementation that subclasses * SqlSessionDaoSupport. */ +@DirtiesContext @SpringJUnitConfig(locations = { "classpath:org/mybatis/spring/sample/config/applicationContext-sqlsession.xml" }) class SampleSqlSessionTest { From 56f90bad5dea21e74a67782b957a287cdc52b525 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 21:35:23 -0400 Subject: [PATCH 523/933] Revert "[tests] Figured mockito out, was hidden in xml (wasn't expecting that)" This reverts commit 67417b3546b063ae72a7a5108948d33af4dcb0d7. --- .../spring/sample/config/applicationContext-sqlsession.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml b/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml index ea8ee39c57..a547d15585 100644 --- a/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml +++ b/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml @@ -1,7 +1,7 @@ - + + + From eac0433ca99dd8c8c8a66116132671f8fa77b6cb Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 21:56:21 -0400 Subject: [PATCH 524/933] [test] Per https://github.com/mockito/mockito/pull/2779, fixed test case --- .../sample/config/applicationContext-sqlsession.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml b/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml index a547d15585..8c14c7d1a6 100644 --- a/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml +++ b/src/test/java/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml @@ -1,7 +1,7 @@ - - + + + org.mybatis.spring.sample.mapper.UserMapper + From 528bf8decb0b7ef9371e644b1743ff9698122525 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 22:09:55 -0400 Subject: [PATCH 525/933] [pom] Try to set byte buddy experimental --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 5925c45579..de7e1c502f 100644 --- a/pom.xml +++ b/pom.xml @@ -121,6 +121,9 @@ 0.8.9 + + + true From cbdaf82cc73a5d7d9895d790ccffe934f5626fed Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 6 Apr 2023 22:12:18 -0400 Subject: [PATCH 526/933] [pom] Bump byte buddy to 1.14.4 to get newer asm --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index de7e1c502f..15f38570a1 100644 --- a/pom.xml +++ b/pom.xml @@ -317,6 +317,18 @@ test + + net.bytebuddy + byte-buddy + 1.14.4 + test + + + net.bytebuddy + byte-buddy-agent + 1.14.4 + test + From 0771973313945f7ede4c73b96a221c1df7d50c2e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 21:45:41 +0000 Subject: [PATCH 527/933] Update dependency org.mockito:mockito-core to v5.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 15f38570a1..58f4403942 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,7 @@ org.mockito mockito-core - 5.2.0 + 5.3.0 test From 7e8d584bae137060317c21d5bb2033cdebd0988f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:12:00 +0000 Subject: [PATCH 528/933] Update spring core to v6.0.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 58f4403942..bca5979d62 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.7 + 6.0.8 5.0.1 org.mybatis.spring From 63eb86aae5efc8f57a730beca49a29be83a1be56 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 18:53:44 +0000 Subject: [PATCH 529/933] Update dependency org.jboss.byteman:byteman-bmunit to v4.0.21 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 58f4403942..1b06f04e1b 100644 --- a/pom.xml +++ b/pom.xml @@ -181,7 +181,7 @@ org.jboss.byteman byteman-bmunit - 4.0.20 + 4.0.21 test From e25bf49e1cf1cf95bd187af7d8baee621701aba5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Apr 2023 21:06:51 +0000 Subject: [PATCH 530/933] Update dependency org.mockito:mockito-core to v5.3.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e3ec347bb4..7d4d1e0c0d 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,7 @@ org.mockito mockito-core - 5.3.0 + 5.3.1 test From 7e4904fb2ab06c34a9bbeefc866226724e11de37 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 09:08:04 +0000 Subject: [PATCH 531/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.9.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d4d1e0c0d..8b48f44d6f 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 5.0.1 org.mybatis.spring - 5.9.2 + 5.9.3 1670546764 From aa599ce83cbb4c295f0eb7d533d504a79de637bf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 May 2023 15:27:42 +0000 Subject: [PATCH 532/933] Update dependency com.atomikos:transactions-jdbc to v6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b48f44d6f..e6b00849c0 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ com.atomikos transactions-jdbc - 5.0.9 + 6.0.0 test From 9005cbac8ed44fda51d0e1a6a7b82edde21960c0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 May 2023 07:36:58 +0000 Subject: [PATCH 533/933] Update dependency maven to v3.9.2 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index d8b2495a1e..3c6fda8c6e 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 444bf9019323ef93fcc426fee9033b52a23e2c57 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 May 2023 14:14:31 +0000 Subject: [PATCH 534/933] Update spring core to v6.0.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6b00849c0..537bee6f95 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.8 + 6.0.9 5.0.1 org.mybatis.spring From 6200535da5f2cf39709ff76ded2b472c855e18cd Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 13 May 2023 11:10:31 +0900 Subject: [PATCH 535/933] Update license header --- src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 2103aea282..0255a7075c 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From e50be2717c13b29d9750e43eb4c5521c2aa3692a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 13 May 2023 12:12:49 +0900 Subject: [PATCH 536/933] Drop support 1.3.x and 2.0.x Fixes gh-814 --- README.md | 1 - src/site/es/markdown/index.md | 4 ++-- src/site/ja/markdown/index.md | 4 ++-- src/site/ko/markdown/index.md | 4 ++-- src/site/markdown/index.md | 12 ++++++------ src/site/zh/markdown/index.md | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e4ec694397..1bfbf7082d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ Supported Versions - master - Support for Spring 6 and Spring Batch 5 - 2.1.x - Enhance and maintenance for Spring 5 and Spring Batch 4 -- 1.3.x - Continued support for Java 6 and 7 Essentials ---------- diff --git a/src/site/es/markdown/index.md b/src/site/es/markdown/index.md index b79bcb62ff..52a789bfd8 100644 --- a/src/site/es/markdown/index.md +++ b/src/site/es/markdown/index.md @@ -24,8 +24,8 @@ MyBatis-Spring requires following versions: |----------------| --- |------------------|--------------| --- | | **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | | **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | -| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | -| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | +| ~~**2.0**~~ | ~~3.5+~~ | ~~5.x~~ | ~~4.x~~ | ~~Java 8+~~ | +| ~~**1.3**~~ | ~~3.4+~~ | ~~3.2.2+~~ | ~~2.1+~~ | ~~Java 6+~~ | ## Agradecimientos diff --git a/src/site/ja/markdown/index.md b/src/site/ja/markdown/index.md index 3a11e460d9..1bd7b7408b 100644 --- a/src/site/ja/markdown/index.md +++ b/src/site/ja/markdown/index.md @@ -19,8 +19,8 @@ MyBatis-Spring は以下のバージョンを必要とします。 |----------------| --- |------------------|--------------| --- | | **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | | **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | -| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | -| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | +| ~~**2.0**~~ | ~~3.5+~~ | ~~5.x~~ | ~~4.x~~ | ~~Java 8+~~ | +| ~~**1.3**~~ | ~~3.4+~~ | ~~3.2.2+~~ | ~~2.1+~~ | ~~Java 6+~~ | ## 謝辞 diff --git a/src/site/ko/markdown/index.md b/src/site/ko/markdown/index.md index 210c2becd9..83e5567550 100644 --- a/src/site/ko/markdown/index.md +++ b/src/site/ko/markdown/index.md @@ -22,8 +22,8 @@ MyBatis-Spring requires following versions: |----------------| --- |------------------|--------------| --- | | **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | | **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | -| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | -| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | +| ~~**2.0**~~ | ~~3.5+~~ | ~~5.x~~ | ~~4.x~~ | ~~Java 8+~~ | +| ~~**1.3**~~ | ~~3.4+~~ | ~~3.2.2+~~ | ~~2.1+~~ | ~~Java 6+~~ | ## 감사 인사 diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 2826d01602..b6afdff316 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -19,12 +19,12 @@ This document does not attempt to provide background information or basic setup MyBatis-Spring requires following versions: -| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | -|----------------| --- |------------------|--------------|----------| -| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | -| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | -| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | -| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | +| MyBatis-Spring | MyBatis | Spring Framework | Spring Batch | Java | +|----------------| --- |------------------|--------------|-------------| +| **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | +| **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | +| ~~**2.0**~~ | ~~3.5+~~ | ~~5.x~~ | ~~4.x~~ | ~~Java 8+~~ | +| ~~**1.3**~~ | ~~3.4+~~ | ~~3.2.2+~~ | ~~2.1+~~ | ~~Java 6+~~ | ## Acknowledgements diff --git a/src/site/zh/markdown/index.md b/src/site/zh/markdown/index.md index 3239fe84ce..3ffbbaaa03 100644 --- a/src/site/zh/markdown/index.md +++ b/src/site/zh/markdown/index.md @@ -21,8 +21,8 @@ MyBatis-Spring 需要以下版本: |----------------| --- |------------------|--------------| --- | | **3.0** | 3.5+ | 6.0+ | 5.0+ | Java 17+ | | **2.1** | 3.5+ | 5.x | 4.x | Java 8+ | -| **2.0** | 3.5+ | 5.x | 4.x | Java 8+ | -| **1.3** | 3.4+ | 3.2.2+ | 2.1+ | Java 6+ | +| ~~**2.0**~~ | ~~3.5+~~ | ~~5.x~~ | ~~4.x~~ | ~~Java 8+~~ | +| ~~**1.3**~~ | ~~3.4+~~ | ~~3.2.2+~~ | ~~2.1+~~ | ~~Java 6+~~ | ## 致谢 From f206e7e669a59edc5f2ef333c094f3c752d74a08 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 13 May 2023 16:29:46 +0900 Subject: [PATCH 537/933] Support appendable method on SqlSessionFactoryBean Fixes gh-787 * addMapperLocations * addTypeHandlers * addScriptingLanguageDrivers * addPlugins * addTypeAliases --- .../mybatis/spring/SqlSessionFactoryBean.java | 86 +++++++++ .../spring/SqlSessionFactoryBeanTest.java | 163 +++++++++++++++++- .../java/org/mybatis/spring/TestMapper2.xml | 28 +++ .../java/org/mybatis/spring/TestMapper3.xml | 28 +++ 4 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/mybatis/spring/TestMapper2.xml create mode 100644 src/test/java/org/mybatis/spring/TestMapper3.xml diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 0255a7075c..c4032f142c 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -24,10 +24,14 @@ import java.io.IOException; import java.lang.reflect.Modifier; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Optional; import java.util.Properties; import java.util.Set; +import java.util.function.IntFunction; import java.util.stream.Stream; import javax.sql.DataSource; @@ -478,6 +482,88 @@ public void setDefaultScriptingLanguageDriver(Class de this.defaultScriptingLanguageDriver = defaultScriptingLanguageDriver; } + /** + * Add locations of MyBatis mapper files that are going to be merged into the {@code SqlSessionFactory} configuration + * at runtime. + *

    + * This is an alternative to specifying "<sqlmapper>" entries in an MyBatis config file. This property being + * based on Spring's resource abstraction also allows for specifying resource patterns here: e.g. + * "classpath*:sqlmap/*-mapper.xml". + * + * @param mapperLocations + * location of MyBatis mapper files + * + * @see #setMapperLocations(Resource...) + * + * @since 3.0.2 + */ + public void addMapperLocations(Resource... mapperLocations) { + setMapperLocations(appendArrays(this.mapperLocations, mapperLocations, Resource[]::new)); + } + + /** + * Add type handlers. + * + * @param typeHandlers + * Type handler list + * + * @since 3.0.2 + */ + public void addTypeHandlers(TypeHandler... typeHandlers) { + setTypeHandlers(appendArrays(this.typeHandlers, typeHandlers, TypeHandler[]::new)); + } + + /** + * Add scripting language drivers. + * + * @param scriptingLanguageDrivers + * scripting language drivers + * + * @since 3.0.2 + */ + public void addScriptingLanguageDrivers(LanguageDriver... scriptingLanguageDrivers) { + setScriptingLanguageDrivers( + appendArrays(this.scriptingLanguageDrivers, scriptingLanguageDrivers, LanguageDriver[]::new)); + } + + /** + * Add Mybatis plugins. + * + * @param plugins + * list of plugins + * + * @since 3.0.2 + */ + public void addPlugins(Interceptor... plugins) { + setPlugins(appendArrays(this.plugins, plugins, Interceptor[]::new)); + } + + /** + * Add type aliases. + * + * @param typeAliases + * Type aliases list + * + * @since 3.0.2 + */ + public void addTypeAliases(Class... typeAliases) { + setTypeAliases(appendArrays(this.typeAliases, typeAliases, Class[]::new)); + } + + private T[] appendArrays(T[] oldArrays, T[] newArrays, IntFunction generator) { + if (oldArrays == null) { + return newArrays; + } else { + if (newArrays == null) { + return oldArrays; + } else { + List newList = new ArrayList<>(Arrays.asList(oldArrays)); + newList.addAll(Arrays.asList(newArrays)); + return newList.toArray(generator.apply(0)); + } + } + } + /** * {@inheritDoc} */ diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 7ada0e4164..90fda72eb8 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,24 @@ import java.math.BigDecimal; import java.math.BigInteger; +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.Properties; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; import org.apache.ibatis.cache.impl.PerpetualCache; +import org.apache.ibatis.executor.Executor; import org.apache.ibatis.io.JBoss6VFS; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Invocation; +import org.apache.ibatis.plugin.Signature; import org.apache.ibatis.reflection.factory.DefaultObjectFactory; import org.apache.ibatis.reflection.factory.ObjectFactory; import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; @@ -41,9 +52,12 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.transaction.TransactionFactory; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; +import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.EnumOrdinalTypeHandler; +import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeAliasRegistry; import org.apache.ibatis.type.TypeException; +import org.apache.ibatis.type.TypeHandler; import org.apache.ibatis.type.TypeHandlerRegistry; import org.junit.jupiter.api.Test; import org.mybatis.core.jdk.type.AtomicNumberTypeHandler; @@ -492,6 +506,88 @@ void testScriptingLanguageDriverWithDefault() throws Exception { assertThat(registry.getDriver(RawLanguageDriver.class)).isNotNull(); } + @Test + void testAppendableMethod() throws Exception { + setupFactoryBean(); + // add values + this.factoryBean.addScriptingLanguageDrivers(new MyLanguageDriver1()); + this.factoryBean.addScriptingLanguageDrivers(new MyLanguageDriver2()); + this.factoryBean.addPlugins(new MyPlugin1(), new MyPlugin2()); + this.factoryBean.addPlugins(new MyPlugin3()); + this.factoryBean.addTypeHandlers(new MyTypeHandler1()); + this.factoryBean.addTypeHandlers(new MyTypeHandler2(), new MyTypeHandler3()); + this.factoryBean.addTypeAliases(MyTypeHandler1.class, MyTypeHandler2.class, MyTypeHandler3.class); + this.factoryBean.addTypeAliases(MyPlugin1.class); + this.factoryBean.addMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml"), + new ClassPathResource("org/mybatis/spring/TestMapper2.xml")); + this.factoryBean.addMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper3.xml")); + // ignore null value + this.factoryBean.addScriptingLanguageDrivers(null); + this.factoryBean.addPlugins(null); + this.factoryBean.addTypeHandlers(null); + this.factoryBean.addTypeAliases(null); + this.factoryBean.addMapperLocations(null); + SqlSessionFactory factory = this.factoryBean.getObject(); + LanguageDriverRegistry languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); + TypeHandlerRegistry typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); + TypeAliasRegistry typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); + assertThat(languageDriverRegistry.getDriver(MyLanguageDriver1.class)).isNotNull(); + assertThat(languageDriverRegistry.getDriver(MyLanguageDriver2.class)).isNotNull(); + assertThat(typeHandlerRegistry.getTypeHandlers().stream().map(TypeHandler::getClass).map(Class::getSimpleName) + .collect(Collectors.toSet())).contains(MyTypeHandler1.class.getSimpleName(), + MyTypeHandler2.class.getSimpleName(), MyTypeHandler3.class.getSimpleName()); + assertThat(typeAliasRegistry.getTypeAliases()).containsKeys(MyTypeHandler1.class.getSimpleName().toLowerCase(), + MyTypeHandler2.class.getSimpleName().toLowerCase(), MyTypeHandler3.class.getSimpleName().toLowerCase(), + MyPlugin1.class.getSimpleName().toLowerCase()); + assertThat(factory.getConfiguration().getMappedStatement("org.mybatis.spring.TestMapper.findFail")).isNotNull(); + assertThat(factory.getConfiguration().getMappedStatement("org.mybatis.spring.TestMapper2.selectOne")).isNotNull(); + assertThat(factory.getConfiguration().getMappedStatement("org.mybatis.spring.TestMapper3.selectOne")).isNotNull(); + assertThat( + factory.getConfiguration().getInterceptors().stream().map(Interceptor::getClass).map(Class::getSimpleName)) + .contains(MyPlugin1.class.getSimpleName(), MyPlugin2.class.getSimpleName(), + MyPlugin3.class.getSimpleName()); + } + + @Test + void testAppendableMethodWithEmpty() throws Exception { + setupFactoryBean(); + this.factoryBean.addScriptingLanguageDrivers(); + this.factoryBean.addPlugins(); + this.factoryBean.addTypeHandlers(); + this.factoryBean.addTypeAliases(); + this.factoryBean.addMapperLocations(); + SqlSessionFactory factory = this.factoryBean.getObject(); + LanguageDriverRegistry languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); + TypeHandlerRegistry typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); + TypeAliasRegistry typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); + assertThat(languageDriverRegistry.getDriver(MyLanguageDriver1.class)).isNull(); + assertThat(languageDriverRegistry.getDriver(MyLanguageDriver2.class)).isNull(); + assertThat(typeHandlerRegistry.getTypeHandlers()).hasSize(40); + assertThat(typeAliasRegistry.getTypeAliases()).hasSize(80); + assertThat(factory.getConfiguration().getMappedStatementNames()).isEmpty(); + assertThat(factory.getConfiguration().getInterceptors()).isEmpty(); + } + + @Test + void testAppendableMethodWithNull() throws Exception { + setupFactoryBean(); + this.factoryBean.addScriptingLanguageDrivers(null); + this.factoryBean.addPlugins(null); + this.factoryBean.addTypeHandlers(null); + this.factoryBean.addTypeAliases(null); + this.factoryBean.addMapperLocations(null); + SqlSessionFactory factory = this.factoryBean.getObject(); + LanguageDriverRegistry languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); + TypeHandlerRegistry typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); + TypeAliasRegistry typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); + assertThat(languageDriverRegistry.getDriver(MyLanguageDriver1.class)).isNull(); + assertThat(languageDriverRegistry.getDriver(MyLanguageDriver2.class)).isNull(); + assertThat(typeHandlerRegistry.getTypeHandlers()).hasSize(40); + assertThat(typeAliasRegistry.getTypeAliases()).hasSize(80); + assertThat(factory.getConfiguration().getMappedStatementNames()).isEmpty(); + assertThat(factory.getConfiguration().getInterceptors()).isEmpty(); + } + private void assertDefaultConfig(SqlSessionFactory factory) { assertConfig(factory, SqlSessionFactoryBean.class.getSimpleName(), org.mybatis.spring.transaction.SpringManagedTransactionFactory.class); @@ -522,6 +618,71 @@ private static class MyLanguageDriver1 extends RawLanguageDriver { private static class MyLanguageDriver2 extends RawLanguageDriver { } + private static class MyBasePlugin implements Interceptor { + + @Override + public Object intercept(Invocation invocation) throws Throwable { + return null; + } + + @Override + public Object plugin(Object target) { + return Interceptor.super.plugin(target); + } + + @Override + public void setProperties(Properties properties) { + Interceptor.super.setProperties(properties); + } + } + + @Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) + private static class MyPlugin1 extends MyBasePlugin { + + } + + @Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) + private static class MyPlugin2 extends MyBasePlugin { + + } + + @Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) + private static class MyPlugin3 extends MyBasePlugin { + + } + + private static class MyBaseTypeHandler extends BaseTypeHandler { + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) + throws SQLException { + } + + @Override + public String getNullableResult(ResultSet rs, String columnName) throws SQLException { + return null; + } + + @Override + public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + return null; + } + + @Override + public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + return null; + } + } + + private static class MyTypeHandler1 extends MyBaseTypeHandler { + } + + private static class MyTypeHandler2 extends MyBaseTypeHandler { + } + + private static class MyTypeHandler3 extends MyBaseTypeHandler { + } + private static enum MyEnum { } diff --git a/src/test/java/org/mybatis/spring/TestMapper2.xml b/src/test/java/org/mybatis/spring/TestMapper2.xml new file mode 100644 index 0000000000..89f5a09b92 --- /dev/null +++ b/src/test/java/org/mybatis/spring/TestMapper2.xml @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/TestMapper3.xml b/src/test/java/org/mybatis/spring/TestMapper3.xml new file mode 100644 index 0000000000..36278e655d --- /dev/null +++ b/src/test/java/org/mybatis/spring/TestMapper3.xml @@ -0,0 +1,28 @@ + + + + + + + + From 76c1766c8d3a9ef4e55664ce9f47963da277ff2c Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 13 May 2023 21:52:45 +0900 Subject: [PATCH 538/933] Support spring.aot.enabled=true Fixes gh-780 Fix to use the AotDetector#useGeneratedArtifacts() instead of NativeDetector.inNativeImage() for set the includeAnnotationConfig to false on the ClassPathMapperScanner --- .../org/mybatis/spring/mapper/ClassPathMapperScanner.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 617095f7f8..626cba9985 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.mybatis.spring.SqlSessionTemplate; import org.springframework.aop.scope.ScopedProxyFactoryBean; import org.springframework.aop.scope.ScopedProxyUtils; +import org.springframework.aot.AotDetector; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; @@ -87,7 +88,7 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { public ClassPathMapperScanner(BeanDefinitionRegistry registry) { super(registry, false); - setIncludeAnnotationConfig(!NativeDetector.inNativeImage()); + setIncludeAnnotationConfig(!AotDetector.useGeneratedArtifacts()); setPrintWarnLogIfNotFoundMappers(!NativeDetector.inNativeImage()); } From 894b7a39ef0505c34fcb57cdbcb91d534b74d330 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 14 May 2023 22:52:13 +0900 Subject: [PATCH 539/933] Use the TransactionSynchronization instead of TransactionSynchronizationAdapter TransactionSynchronizationAdapter is deprecated already --- src/main/java/org/mybatis/spring/SqlSessionUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionUtils.java b/src/main/java/org/mybatis/spring/SqlSessionUtils.java index 819d062e4f..f36272f0d2 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionUtils.java +++ b/src/main/java/org/mybatis/spring/SqlSessionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.dao.TransientDataAccessResourceException; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; +import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationManager; /** @@ -225,7 +225,7 @@ public static boolean isSqlSessionTransactional(SqlSession session, SqlSessionFa * {@code SqlSession}. It assumes that {@code Connection} life cycle will be managed by * {@code DataSourceTransactionManager} or {@code JtaTransactionManager} */ - private static final class SqlSessionSynchronization extends TransactionSynchronizationAdapter { + private static final class SqlSessionSynchronization implements TransactionSynchronization { private final SqlSessionHolder holder; From a32bf4ed82300b76b2bf0cc1fc0208a41cb602dd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 13:14:08 +0000 Subject: [PATCH 540/933] Update spring batch to v5.0.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 537bee6f95..699aac5f7f 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 3.5.13 6.0.9 - 5.0.1 + 5.0.2 org.mybatis.spring 5.9.3 From a73af23bf144ccaddb1369740cefa6f734b5f9ef Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sat, 20 May 2023 01:41:20 +0900 Subject: [PATCH 541/933] [maven-release-plugin] prepare release mybatis-spring-3.0.2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 699aac5f7f..33a9653693 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.2-SNAPSHOT + 3.0.2 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.2 GitHub Issue Management @@ -117,7 +117,7 @@ 5.9.3 - 1670546764 + 1684514453 0.8.9 From 0f4709c5557dae65ca38ba310abbc62205a4f6c3 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sat, 20 May 2023 01:41:25 +0900 Subject: [PATCH 542/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 33a9653693..55670ac4c3 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.2 + 3.0.3-SNAPSHOT jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.2 + HEAD GitHub Issue Management @@ -117,7 +117,7 @@ 5.9.3 - 1684514453 + 1684514485 0.8.9 From 7388abbba2c2485eb8f94795507db41e7ddb0fcf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 30 May 2023 01:08:24 +0000 Subject: [PATCH 543/933] Update dependency org.mybatis:mybatis-parent to v38 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 55670ac4c3..c2d77ebff7 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 37 + 38 From 9e5674264122e0d2bd7c3d0b62eebba003b52a04 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 03:44:07 +0000 Subject: [PATCH 544/933] Update dependency org.hsqldb:hsqldb to v2.7.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c2d77ebff7..d96ac2fa00 100644 --- a/pom.xml +++ b/pom.xml @@ -222,7 +222,7 @@ org.hsqldb hsqldb - 2.7.1 + 2.7.2 test From 9db03e5be5691467c7308e8b734d787d254b0efc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:31:34 +0000 Subject: [PATCH 545/933] Update dependency net.bytebuddy:byte-buddy to v1.14.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d96ac2fa00..eefacc0115 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ net.bytebuddy byte-buddy - 1.14.4 + 1.14.5 test From 67d79bb86c63266804905cf93945e5cbf407f989 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:31:38 +0000 Subject: [PATCH 546/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d96ac2fa00..466d69d27c 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ net.bytebuddy byte-buddy-agent - 1.14.4 + 1.14.5 test From 3fa2a0ed6aaa2a755c107cff1f9a12f022fb3275 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:27:38 +0000 Subject: [PATCH 547/933] Update spring core to v6.0.10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d31840250c..0a34ee2311 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.9 + 6.0.10 5.0.2 org.mybatis.spring From 63a6600c03d59e646dd4a5404bf5258772459ea5 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 17 Jun 2023 11:09:33 +0900 Subject: [PATCH 548/933] Optimize source * Update license header * Remove wildcard import * Apply formatter --- src/site/es/markdown/boot.md | 2 +- src/site/es/markdown/mappers.md | 2 +- src/site/es/markdown/sqlsession.md | 2 +- src/site/es/markdown/transactions.md | 2 +- src/site/ja/markdown/getting-started.md | 2 +- src/site/ko/markdown/getting-started.md | 2 +- src/site/markdown/factorybean.md | 2 +- src/site/markdown/index.md | 2 +- src/site/markdown/mappers.md | 2 +- src/site/markdown/sqlsession.md | 2 +- src/site/markdown/transactions.md | 2 +- src/test/java/org/mybatis/spring/MyBatisSpringTest.java | 2 +- .../java/org/mybatis/spring/SqlSessionFactoryBeanTest.java | 2 +- .../java/org/mybatis/spring/SqlSessionTemplateTest.java | 4 ++-- .../mybatis/spring/batch/MyBatisBatchItemWriterTest.java | 4 ++-- src/test/java/org/mybatis/spring/batch/SpringBatchTest.java | 4 ++-- .../batch/builder/MyBatisBatchItemWriterBuilderTest.java | 6 ++++-- .../org/mybatis/spring/mapper/MapperFactoryBeanTest.java | 4 ++-- .../java/org/mybatis/spring/sample/AbstractSampleTest.java | 4 ++-- 19 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/site/es/markdown/boot.md b/src/site/es/markdown/boot.md index cda8eb3a3d..678db5d753 100644 --- a/src/site/es/markdown/boot.md +++ b/src/site/es/markdown/boot.md @@ -1,4 +1,4 @@ # Using Spring Boot - + Please see the [MyBatis Spring-boot-starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure) sub project docs for details. diff --git a/src/site/es/markdown/mappers.md b/src/site/es/markdown/mappers.md index 51dd4293d8..5b10210fa8 100644 --- a/src/site/es/markdown/mappers.md +++ b/src/site/es/markdown/mappers.md @@ -85,7 +85,7 @@ The motivation for adding this option is supporting a lazy initialization contro The default of this option is `false` (= not use lazy initialization). If developer want to use lazy initialization for mapper bean, it should be set to the `true` expressly. -IMPORTANT +IMPORTANT If use the lazy initialization feature, the developer need to understand following limitations. If any of following conditions are matches, usually the lazy initialization feature cannot use on your application. diff --git a/src/site/es/markdown/sqlsession.md b/src/site/es/markdown/sqlsession.md index 19fd43b1c3..1615d88896 100644 --- a/src/site/es/markdown/sqlsession.md +++ b/src/site/es/markdown/sqlsession.md @@ -86,7 +86,7 @@ Ahora todos tus statements se ejecutarán en batch de forma que puedes programar ```java public class UserService { - private final SqlSession sqlSession; + private final SqlSession sqlSession; public UserService(SqlSession sqlSession) { this.sqlSession = sqlSession; } diff --git a/src/site/es/markdown/transactions.md b/src/site/es/markdown/transactions.md index 227477ac56..54b9dae328 100644 --- a/src/site/es/markdown/transactions.md +++ b/src/site/es/markdown/transactions.md @@ -73,7 +73,7 @@ Fijate que si quieres usar transacciones CMT pero **no** quieres utilizar la ges ```java @Configuration -public class MyBatisConfig { +public class MyBatisConfig { @Bean public SqlSessionFactory sqlSessionFactory() { SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); diff --git a/src/site/ja/markdown/getting-started.md b/src/site/ja/markdown/getting-started.md index d1ed42e4c1..0fd4ba6b8c 100644 --- a/src/site/ja/markdown/getting-started.md +++ b/src/site/ja/markdown/getting-started.md @@ -1,6 +1,6 @@ # スタートガイド - + この章では、MyBatis-Spring のインストール・設定手順と、トランザクション処理を含むシンプルなアプリケーションの構築する方法について説明します。 ## インストール diff --git a/src/site/ko/markdown/getting-started.md b/src/site/ko/markdown/getting-started.md index f04bde22cc..9547c6f39a 100644 --- a/src/site/ko/markdown/getting-started.md +++ b/src/site/ko/markdown/getting-started.md @@ -19,7 +19,7 @@ ## 빠른 설정 -마이바티스를 스프링과 함께 사용하려면 스프링의 애플리케이션 컨텍스트에 적어도 두개를 정의해줄 필요가 있다. +마이바티스를 스프링과 함께 사용하려면 스프링의 애플리케이션 컨텍스트에 적어도 두개를 정의해줄 필요가 있다. 두가지는 `SqlSessionFactory`와 한개 이상의 매퍼 인터페이스이다. 마이바티스 스프링 연동모듈에서, `SqlSessionFactoryBean`은 `SqlSessionFactory`를 만들기 위해 사용된다. 팩토리 빈을 설정하기 위해, 스프링 설정파일에 다음 설정을 추가하자. diff --git a/src/site/markdown/factorybean.md b/src/site/markdown/factorybean.md index cf403649f8..9253e3f6e5 100644 --- a/src/site/markdown/factorybean.md +++ b/src/site/markdown/factorybean.md @@ -13,7 +13,7 @@ To create the factory bean, put the following in the Spring XML configuration fi ``` Note that `SqlSessionFactoryBean` implements Spring's `FactoryBean` interface see [the Spring documentation(Core Technologies -Customizing instantiation logic with a FactoryBean-)](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-extension-factorybean)). -This means that the bean Spring ultimately creates is **not** the `SqlSessionFactoryBean` itself, but what the factory returns as a result of the `getObject()` call on the factory. +This means that the bean Spring ultimately creates is **not** the `SqlSessionFactoryBean` itself, but what the factory returns as a result of the `getObject()` call on the factory. In this case, Spring will build an `SqlSessionFactory` for you at application startup and store it with the name `sqlSessionFactory`. In Java, the equivalent code would be: diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index b6afdff316..bdfcad162f 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -53,4 +53,4 @@ Users can read about MyBatis-Spring in the following translations: Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your mother tongue documentation! - + diff --git a/src/site/markdown/mappers.md b/src/site/markdown/mappers.md index b6cfec037d..ad365ff92f 100644 --- a/src/site/markdown/mappers.md +++ b/src/site/markdown/mappers.md @@ -25,7 +25,7 @@ public class FooServiceImpl implements FooService { } } ``` - + Notice that there are no `SqlSession` or MyBatis references in this code. Nor is there any need to create, open or close the session, MyBatis-Spring will take care of that. diff --git a/src/site/markdown/sqlsession.md b/src/site/markdown/sqlsession.md index 0d970bf514..38ea215015 100644 --- a/src/site/markdown/sqlsession.md +++ b/src/site/markdown/sqlsession.md @@ -82,7 +82,7 @@ Now all your statements will be batched so the following could be coded in a DAO ```java public class UserService { - private final SqlSession sqlSession; + private final SqlSession sqlSession; public UserService(SqlSession sqlSession) { this.sqlSession = sqlSession; } diff --git a/src/site/markdown/transactions.md b/src/site/markdown/transactions.md index 5eff852cab..580480ee57 100644 --- a/src/site/markdown/transactions.md +++ b/src/site/markdown/transactions.md @@ -3,7 +3,7 @@ One of the primary reasons for using MyBatis-Spring is that it allows MyBatis to participate in Spring transactions. Rather than create a new transaction manager specific to MyBatis, MyBatis-Spring leverages the existing `DataSourceTransactionManager` in Spring. - + Once a Spring transaction manager is configured, you can configure transactions in Spring as you normally would. Both `@Transactional` annotations and AOP style configurations are supported. A single `SqlSession` object will be created and used for the duration of the transaction. This session will be committed or rolled back as appropriate when then transaction completes. diff --git a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java index 01d980929c..fda8ebf659 100644 --- a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java @@ -15,7 +15,7 @@ */ package org.mybatis.spring; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 90fda72eb8..4f5f88e224 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -16,7 +16,7 @@ package org.mybatis.spring; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; import com.mockrunner.mock.jdbc.MockDataSource; diff --git a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java index 1fbe09d180..59cabcd7c3 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.mybatis.spring; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index ad11afbc09..827328bbc9 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package org.mybatis.spring.batch; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.BDDMockito.*; +import static org.mockito.BDDMockito.given; import java.time.Clock; import java.time.Instant; diff --git a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java index c934a9b5d8..a27f0ad3a1 100644 --- a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java +++ b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.mybatis.spring.batch; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import org.apache.ibatis.session.SqlSession; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index e410c88931..4b8fe68203 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,9 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import javax.sql.DataSource; diff --git a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java index b28a67c947..25aa1e7759 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.mybatis.spring.mapper; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java index 60b3c004a5..577f555305 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.mybatis.spring.sample; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; import org.mybatis.spring.sample.domain.User; From 76e8bae48771da0d765c28a84eed442e9640f382 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 17 Jun 2023 22:00:28 +0900 Subject: [PATCH 549/933] Support processPropertyPlaceHolders option in mapper:scan and @MapperScan Fixes gh-829 --- .../mybatis/spring/annotation/MapperScan.java | 13 +++- .../annotation/MapperScannerRegistrar.java | 4 +- .../MapperScannerBeanDefinitionParser.java | 7 +- .../mybatis/spring/config/mybatis-spring.xsd | 12 ++- .../spring/annotation/MapperScanTest.java | 76 ++++++++++++++++++- .../org/mybatis/spring/annotation/MyBean.java | 37 +++++++++ .../spring/annotation/override.properties | 17 +++++ .../spring/annotation/placeholders.properties | 17 +++++ .../org/mybatis/spring/config/MyBean.java | 37 +++++++++ .../mybatis/spring/config/MyFactoryBean.java | 30 ++++++++ .../mybatis/spring/config/NamespaceTest.java | 33 +++++++- .../mybatis/spring/config/override.properties | 17 +++++ .../spring/config/placeholders.properties | 17 +++++ .../process-property-placeholders-false.xml | 35 +++++++++ .../process-property-placeholders-true.xml | 36 +++++++++ 15 files changed, 380 insertions(+), 8 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/annotation/MyBean.java create mode 100644 src/test/java/org/mybatis/spring/annotation/override.properties create mode 100644 src/test/java/org/mybatis/spring/annotation/placeholders.properties create mode 100644 src/test/java/org/mybatis/spring/config/MyBean.java create mode 100644 src/test/java/org/mybatis/spring/config/MyFactoryBean.java create mode 100644 src/test/java/org/mybatis/spring/config/override.properties create mode 100644 src/test/java/org/mybatis/spring/config/placeholders.properties create mode 100644 src/test/java/org/mybatis/spring/config/process-property-placeholders-false.xml create mode 100644 src/test/java/org/mybatis/spring/config/process-property-placeholders-true.xml diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index 78c0d9b0bf..9d51b7ce42 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,4 +185,15 @@ */ String defaultScope() default AbstractBeanDefinition.SCOPE_DEFAULT; + /** + * Specifies a flag that whether execute a property placeholder processing or not. + *

    + * The default is {@literal true}. This means that a property placeholder processing execute. + * + * @since 3.0.3 + * + * @return a flag that whether execute a property placeholder processing or not + */ + boolean processPropertyPlaceHolders() default true; + } diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index cde801d739..fb8f1f94f6 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a BeanDefinitionRegistry registry, String beanName) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); - builder.addPropertyValue("processPropertyPlaceHolders", true); + builder.addPropertyValue("processPropertyPlaceHolders", annoAttrs.getBoolean("processPropertyPlaceHolders")); Class annotationClass = annoAttrs.getClass("annotationClass"); if (!Annotation.class.equals(annotationClass)) { diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index d0e40c5777..927cd627d6 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,7 @@ public class MapperScannerBeanDefinitionParser extends AbstractBeanDefinitionPar private static final String ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS = "mapper-factory-bean-class"; private static final String ATTRIBUTE_LAZY_INITIALIZATION = "lazy-initialization"; private static final String ATTRIBUTE_DEFAULT_SCOPE = "default-scope"; + private static final String ATTRIBUTE_PROCESS_PROPERTY_PLACEHOLDERS = "process-property-placeholders"; /** * {@inheritDoc} @@ -68,7 +69,9 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); - builder.addPropertyValue("processPropertyPlaceHolders", true); + String processPropertyPlaceHolders = element.getAttribute(ATTRIBUTE_PROCESS_PROPERTY_PLACEHOLDERS); + builder.addPropertyValue("processPropertyPlaceHolders", + !StringUtils.hasText(processPropertyPlaceHolders) || Boolean.parseBoolean(processPropertyPlaceHolders)); try { String annotationClassName = element.getAttribute(ATTRIBUTE_ANNOTATION); if (StringUtils.hasText(annotationClassName)) { diff --git a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd index 1a3d5df381..5366717e4d 100644 --- a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd +++ b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd @@ -1,7 +1,7 @@ + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/config/process-property-placeholders-true.xml b/src/test/java/org/mybatis/spring/config/process-property-placeholders-true.xml new file mode 100644 index 0000000000..d10857c242 --- /dev/null +++ b/src/test/java/org/mybatis/spring/config/process-property-placeholders-true.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + From 11707f2a5ad21696f2504e193c7273f100e4be3a Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 18 Jun 2023 00:13:44 +0900 Subject: [PATCH 550/933] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bfbf7082d..00df4dc767 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ MyBatis Spring Adapter ![mybatis-spring](https://mybatis.org/images/mybatis-logo.png) -MyBatis-Spring adapter is an easy-to-use Spring bridge for MyBatis sql mapping framework. +MyBatis-Spring adapter is an easy-to-use [Spring Framework](https://github.com/spring-projects/spring-framework) bridge for [MyBatis](https://github.com/mybatis/mybatis-3) sql mapping framework. Supported Versions ------------------ From 6bdd62e4d32d341e50e405b83fff733b95ff799b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 18 Jun 2023 12:53:04 +0000 Subject: [PATCH 551/933] Update dependency org.mockito:mockito-core to v5.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a34ee2311..0250c1e0e2 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,7 @@ org.mockito mockito-core - 5.3.1 + 5.4.0 test From f938a619bce0a1e5a2def0ead5df9bc68857cbd7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 12:36:01 +0000 Subject: [PATCH 552/933] Update dependency maven to v3.9.3 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 3c6fda8c6e..6d3a56651d 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 7f7ef3d5c932edc0ca263b811cdf0f88347ac575 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Thu, 6 Jul 2023 15:37:18 +0800 Subject: [PATCH 553/933] fix issue 548. add ComponentScan.Filter[] excludeFilters() to @MapperScan,people can use excludeFilters to customized mapper excludeFilters. --- pom.xml | 6 ++ .../mybatis/spring/annotation/MapperScan.java | 7 ++ .../annotation/MapperScannerRegistrar.java | 53 ++++++++++ .../spring/mapper/ClassPathMapperScanner.java | 14 +++ .../mapper/MapperScannerConfigurer.java | 10 ++ .../spring/scan/filter/ScanFilterTest.java | 99 +++++++++++++++++++ .../spring/scan/filter/config/AppConfig.java | 46 +++++++++ .../filter/customfilter/AnnoTypeFilter.java | 9 ++ .../filter/customfilter/CustomTypeFilter.java | 14 +++ .../filter/customfilter/ExcludeMaker.java | 5 + .../commonsource/AnnoExcludeMapper.java | 8 ++ .../commonsource/AssignableMapper.java | 7 ++ .../commonsource/CommonDataSourceMapper.java | 6 ++ .../datasource1/DataSource1Mapper.java | 6 ++ .../datasource2/DataSource2Mapper.java | 6 ++ 15 files changed, 296 insertions(+) create mode 100644 src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java create mode 100644 src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java diff --git a/pom.xml b/pom.xml index f910678b1e..b2766c3ea3 100644 --- a/pom.xml +++ b/pom.xml @@ -313,6 +313,12 @@ 6.0.0 test + + org.aspectj + aspectjweaver + 1.9.19 + true + diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index 78c0d9b0bf..4be73792a6 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -27,6 +27,7 @@ import org.mybatis.spring.mapper.MapperScannerConfigurer; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.AliasFor; @@ -185,4 +186,10 @@ */ String defaultScope() default AbstractBeanDefinition.SCOPE_DEFAULT; + /** + * Specifies which types are not eligible for mapper scanning. + */ + ComponentScan.Filter[] excludeFilters() default {}; + + } diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index cde801d739..1f7d4a5f7b 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.regex.Pattern; import java.util.stream.Collectors; import org.mybatis.spring.mapper.ClassPathMapperScanner; @@ -31,10 +32,13 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.context.ResourceLoaderAware; +import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.io.ResourceLoader; import org.springframework.core.type.AnnotationMetadata; +import org.springframework.core.type.filter.*; +import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; @@ -54,6 +58,7 @@ */ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware { + private ResourceLoader resourceLoader; /** * {@inheritDoc} * @@ -63,6 +68,7 @@ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, Re @Deprecated public void setResourceLoader(ResourceLoader resourceLoader) { // NOP + this.resourceLoader = resourceLoader; } /** @@ -126,6 +132,11 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a basePackages.add(getDefaultBasePackage(annoMeta)); } + AnnotationAttributes[] excludeFilterArray = annoAttrs.getAnnotationArray("excludeFilters"); + for (AnnotationAttributes excludeFilters : excludeFilterArray) { + builder.addPropertyValue("excludeFilters", typeFiltersFor(excludeFilters)); + } + String lazyInitialization = annoAttrs.getString("lazyInitialization"); if (StringUtils.hasText(lazyInitialization)) { builder.addPropertyValue("lazyInitialization", lazyInitialization); @@ -145,6 +156,48 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a } + private List typeFiltersFor(AnnotationAttributes filterAttributes) { + + List typeFilters = new ArrayList<>(); + FilterType filterType = filterAttributes.getEnum("type"); + + for (Class filterClass : filterAttributes.getClassArray("value")) { + switch (filterType) { + case ANNOTATION: + Assert.isAssignable(Annotation.class, filterClass, + "An error occured when processing a @ComponentScan " + "ANNOTATION type filter: "); + @SuppressWarnings("unchecked") + Class annoClass = (Class) filterClass; + typeFilters.add(new AnnotationTypeFilter(annoClass)); + break; + case ASSIGNABLE_TYPE: + typeFilters.add(new AssignableTypeFilter(filterClass)); + break; + case CUSTOM: + Assert.isAssignable(TypeFilter.class, filterClass, + "An error occured when processing a @ComponentScan " + "CUSTOM type filter: "); + typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class)); + break; + default: + throw new IllegalArgumentException("Unknown filter type " + filterType); + } + } + + String[] expressionArray = filterAttributes.getStringArray("pattern"); + for (String expression : expressionArray) { + String rawName = filterType.toString(); + if ("REGEX".equals(rawName)) { + typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression))); + } else if ("ASPECTJ".equals(rawName)) { + typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader())); + } else { + throw new IllegalArgumentException("Unknown filter type " + filterType); + } + } + return typeFilters; + } + + private static String generateBaseBeanName(AnnotationMetadata importingClassMetadata, int index) { return importingClassMetadata.getClassName() + "#" + MapperScannerRegistrar.class.getSimpleName() + "#" + index; } diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 617095f7f8..5956b5bb3b 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -17,6 +17,7 @@ import java.lang.annotation.Annotation; import java.util.Arrays; +import java.util.List; import java.util.Optional; import java.util.Set; @@ -39,6 +40,7 @@ import org.springframework.core.NativeDetector; import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter; +import org.springframework.core.type.filter.TypeFilter; import org.springframework.util.StringUtils; /** @@ -84,6 +86,7 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { private Class mapperFactoryBeanClass = MapperFactoryBean.class; private String defaultScope; + private List excludeFilters; public ClassPathMapperScanner(BeanDefinitionRegistry registry) { super(registry, false); @@ -133,6 +136,10 @@ public void setMarkerInterface(Class markerInterface) { this.markerInterface = markerInterface; } + public void setExcludeFilters(List excludeFilters) { + this.excludeFilters = excludeFilters; + } + public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { this.sqlSessionFactory = sqlSessionFactory; } @@ -218,6 +225,13 @@ protected boolean matchClassName(String className) { String className = metadataReader.getClassMetadata().getClassName(); return className.endsWith("package-info"); }); + + // exclude types declared by MapperScan.excludeFilters + if (excludeFilters != null && excludeFilters.size() > 0) { + for (TypeFilter excludeFilter : excludeFilters) { + addExcludeFilter(excludeFilter); + } + } } /** diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 5b10b71192..30b7724863 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -18,6 +18,7 @@ import static org.springframework.util.Assert.notNull; import java.lang.annotation.Annotation; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -39,6 +40,7 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.Environment; +import org.springframework.core.type.filter.TypeFilter; import org.springframework.util.StringUtils; /** @@ -109,6 +111,9 @@ public class MapperScannerConfigurer private Class markerInterface; + + private List excludeFilters; + private Class mapperFactoryBeanClass; private ApplicationContext applicationContext; @@ -191,6 +196,10 @@ public void setMarkerInterface(Class superClass) { this.markerInterface = superClass; } + public void setExcludeFilters(List excludeFilters) { + this.excludeFilters = excludeFilters; + } + /** * Specifies which {@code SqlSessionTemplate} to use in the case that there is more than one in the spring context. * Usually this is only needed when you have more than one datasource. @@ -364,6 +373,7 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { scanner.setAddToConfig(this.addToConfig); scanner.setAnnotationClass(this.annotationClass); scanner.setMarkerInterface(this.markerInterface); + scanner.setExcludeFilters(this.excludeFilters); scanner.setSqlSessionFactory(this.sqlSessionFactory); scanner.setSqlSessionTemplate(this.sqlSessionTemplate); scanner.setSqlSessionFactoryBeanName(this.sqlSessionFactoryBeanName); diff --git a/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java new file mode 100644 index 0000000000..cf6fe0fd67 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java @@ -0,0 +1,99 @@ +package org.mybatis.spring.scan.filter; + +import com.mockrunner.mock.jdbc.MockDataSource; +import org.junit.jupiter.api.Test; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.scan.filter.config.AppConfig; +import org.springframework.beans.factory.support.GenericBeanDefinition; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; + +// test the function of excludeFilters in @MapperScan +public class ScanFilterTest { + + private AnnotationConfigApplicationContext applicationContext; + + + @Test + void testCustomScanFilter() { + startContext(AppConfig.CustomFilterConfig.class); + // use org.mybatis.spring.scan.filter.datasource as basePackages and exclude package datasource2 by MapperScan.excludeFilters + // mapper in package datasource2 will not be registered to beanFactory + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + + // mapper in package datasource except datasource2 will be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); + } + + @Test + void testAnnoScanFilter() { + startContext(AppConfig.AnnoFilterConfig.class); + + // use @AnnoTypeFilter to exclude mapper + assertThat(applicationContext.containsBean("annoExcludeMapper")).isEqualTo(false); + + // mapper in package datasource except datasource2 will be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + } + + + @Test + void testAssignableScanFilter() { + startContext(AppConfig.AssignableFilterConfig.class); + + // exclude AssignableMapper by AssignableFilter + assertThat(applicationContext.containsBean("assignableMapper")).isEqualTo(false); + + // mapper in package datasource except datasource2 will be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + } + + @Test + void testRegexScanFilter() { + startContext(AppConfig.RegexFilterConfig.class); + + // exclude package datasource1 by Regex + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + + // mapper in package datasource except datasource1 will be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + } + + @Test + void testAspectJScanFilter() { + + startContext(AppConfig.AspectJFilterConfig.class); + + // exclude dataSource1Mapper by AspectJ + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + + // mapper in package datasource except datasource1 will be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + } + + + private void startContext(Class config) { + applicationContext = new AnnotationConfigApplicationContext(); + // use @MapperScan with excludeFilters in AppConfig.class + applicationContext.register(config); + setupSqlSessionFactory("sqlSessionFactory"); + applicationContext.refresh(); + applicationContext.start(); + } + + + private void setupSqlSessionFactory(String name) { + GenericBeanDefinition definition = new GenericBeanDefinition(); + definition.setBeanClass(SqlSessionFactoryBean.class); + definition.getPropertyValues().add("dataSource", new MockDataSource()); + applicationContext.registerBeanDefinition(name, definition); + } +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java new file mode 100644 index 0000000000..c0c3bd1458 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java @@ -0,0 +1,46 @@ +package org.mybatis.spring.scan.filter.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.mybatis.spring.scan.filter.customfilter.AnnoTypeFilter; +import org.mybatis.spring.scan.filter.customfilter.ExcludeMaker; +import org.mybatis.spring.scan.filter.customfilter.CustomTypeFilter; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; + + +public class AppConfig { + + + @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class)}) + public static class CustomFilterConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class)}) + public static class AnnoFilterConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ExcludeMaker.class)}) + public static class AssignableFilterConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, + pattern = "org\\.mybatis\\.spring\\.scan\\.filter\\.datasource\\.datasource1\\..*")}) + public static class RegexFilterConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.ASPECTJ, + pattern = "*..DataSource1Mapper")}) + public static class AspectJFilterConfig { + + } +} + diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java b/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java new file mode 100644 index 0000000000..63e174db9f --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java @@ -0,0 +1,9 @@ +package org.mybatis.spring.scan.filter.customfilter; + +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +@Documented +public @interface AnnoTypeFilter { +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java b/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java new file mode 100644 index 0000000000..64c70fc8d0 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java @@ -0,0 +1,14 @@ +package org.mybatis.spring.scan.filter.customfilter; + +import org.springframework.core.type.classreading.MetadataReader; +import org.springframework.core.type.classreading.MetadataReaderFactory; +import org.springframework.core.type.filter.TypeFilter; + +import java.io.IOException; + +public class CustomTypeFilter implements TypeFilter { + @Override + public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { + return metadataReader.getClassMetadata().getClassName().contains("datasource2"); + } +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java b/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java new file mode 100644 index 0000000000..b4d871e7da --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java @@ -0,0 +1,5 @@ +package org.mybatis.spring.scan.filter.customfilter; + + +public interface ExcludeMaker { +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java new file mode 100644 index 0000000000..a47480f5c7 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java @@ -0,0 +1,8 @@ +package org.mybatis.spring.scan.filter.datasource.commonsource; + +import org.apache.ibatis.annotations.Mapper; +import org.mybatis.spring.scan.filter.customfilter.AnnoTypeFilter; + +@AnnoTypeFilter +public interface AnnoExcludeMapper extends Mapper { +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java new file mode 100644 index 0000000000..8a41645467 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java @@ -0,0 +1,7 @@ +package org.mybatis.spring.scan.filter.datasource.commonsource; + +import org.apache.ibatis.annotations.Mapper; +import org.mybatis.spring.scan.filter.customfilter.ExcludeMaker; + +public interface AssignableMapper extends ExcludeMaker,Mapper { +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java new file mode 100644 index 0000000000..048c706d53 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java @@ -0,0 +1,6 @@ +package org.mybatis.spring.scan.filter.datasource.commonsource; + +import org.apache.ibatis.annotations.Mapper; + +public interface CommonDataSourceMapper extends Mapper { +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java new file mode 100644 index 0000000000..79c47e8e9f --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java @@ -0,0 +1,6 @@ +package org.mybatis.spring.scan.filter.datasource.datasource1; + +import org.apache.ibatis.annotations.Mapper; + +public interface DataSource1Mapper extends Mapper { +} diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java new file mode 100644 index 0000000000..154fe3fe32 --- /dev/null +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java @@ -0,0 +1,6 @@ +package org.mybatis.spring.scan.filter.datasource.datasource2; + +import org.apache.ibatis.annotations.Mapper; + +public interface DataSource2Mapper extends Mapper { +} From cc31d4a4843055e8df6bcd31d0c616f6f5eb3e93 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sat, 8 Jul 2023 17:39:40 +0800 Subject: [PATCH 554/933] optimize imports --- .../filter/datasource/commonsource/AnnoExcludeMapper.java | 3 +-- .../scan/filter/datasource/commonsource/AssignableMapper.java | 3 +-- .../datasource/commonsource/CommonDataSourceMapper.java | 3 +-- .../scan/filter/datasource/datasource1/DataSource1Mapper.java | 4 +--- .../scan/filter/datasource/datasource2/DataSource2Mapper.java | 4 +--- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java index a47480f5c7..64cc3ba15c 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java @@ -1,8 +1,7 @@ package org.mybatis.spring.scan.filter.datasource.commonsource; -import org.apache.ibatis.annotations.Mapper; import org.mybatis.spring.scan.filter.customfilter.AnnoTypeFilter; @AnnoTypeFilter -public interface AnnoExcludeMapper extends Mapper { +public interface AnnoExcludeMapper { } diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java index 8a41645467..cc2cc05870 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java @@ -1,7 +1,6 @@ package org.mybatis.spring.scan.filter.datasource.commonsource; -import org.apache.ibatis.annotations.Mapper; import org.mybatis.spring.scan.filter.customfilter.ExcludeMaker; -public interface AssignableMapper extends ExcludeMaker,Mapper { +public interface AssignableMapper extends ExcludeMaker { } diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java index 048c706d53..c132943f38 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java @@ -1,6 +1,5 @@ package org.mybatis.spring.scan.filter.datasource.commonsource; -import org.apache.ibatis.annotations.Mapper; -public interface CommonDataSourceMapper extends Mapper { +public interface CommonDataSourceMapper { } diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java index 79c47e8e9f..b89298dba5 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java @@ -1,6 +1,4 @@ package org.mybatis.spring.scan.filter.datasource.datasource1; -import org.apache.ibatis.annotations.Mapper; - -public interface DataSource1Mapper extends Mapper { +public interface DataSource1Mapper { } diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java index 154fe3fe32..6a18893bfa 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java @@ -1,6 +1,4 @@ package org.mybatis.spring.scan.filter.datasource.datasource2; -import org.apache.ibatis.annotations.Mapper; - -public interface DataSource2Mapper extends Mapper { +public interface DataSource2Mapper { } From c711ce48b98df43d4cd58ff1e8ca3e0b832ffa8c Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sun, 9 Jul 2023 15:16:03 +0800 Subject: [PATCH 555/933] 1.remove @Deprecated on method setResourceLoader. 2.add comment. --- .../annotation/MapperScannerRegistrar.java | 4 ---- .../mapper/MapperScannerConfigurer.java | 9 ++++++++- .../spring/scan/filter/ScanFilterTest.java | 19 ++++++++++++++++++- .../spring/scan/filter/config/AppConfig.java | 15 +++++++++++++++ .../filter/customfilter/AnnoTypeFilter.java | 15 +++++++++++++++ .../filter/customfilter/CustomTypeFilter.java | 15 +++++++++++++++ .../filter/customfilter/ExcludeMaker.java | 15 +++++++++++++++ .../commonsource/AnnoExcludeMapper.java | 15 +++++++++++++++ .../commonsource/AssignableMapper.java | 15 +++++++++++++++ .../commonsource/CommonDataSourceMapper.java | 15 +++++++++++++++ .../datasource1/DataSource1Mapper.java | 15 +++++++++++++++ .../datasource2/DataSource2Mapper.java | 15 +++++++++++++++ 12 files changed, 161 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index 6f4ee1aefb..a7f194c6a6 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -61,13 +61,9 @@ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, Re private ResourceLoader resourceLoader; /** * {@inheritDoc} - * - * @deprecated Since 2.0.2, this method not used never. */ @Override - @Deprecated public void setResourceLoader(ResourceLoader resourceLoader) { - // NOP this.resourceLoader = resourceLoader; } diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 30b7724863..bfef6ed6b3 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -111,7 +111,6 @@ public class MapperScannerConfigurer private Class markerInterface; - private List excludeFilters; private Class mapperFactoryBeanClass; @@ -196,6 +195,14 @@ public void setMarkerInterface(Class superClass) { this.markerInterface = superClass; } + /** + * Specifies which types are not eligible for the mapper scanner. + *

    + * The scanner will exclude types that define with excludeFilters. + * + * @param excludeFilters + * list of TypeFilter + */ public void setExcludeFilters(List excludeFilters) { this.excludeFilters = excludeFilters; } diff --git a/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java index cf6fe0fd67..9f8cba64d7 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter; import com.mockrunner.mock.jdbc.MockDataSource; @@ -9,7 +24,9 @@ import static org.assertj.core.api.Assertions.assertThat; -// test the function of excludeFilters in @MapperScan +/** + * test the function of excludeFilters in @MapperScan + */ public class ScanFilterTest { private AnnotationConfigApplicationContext applicationContext; diff --git a/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java index c0c3bd1458..1143bf6684 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.config; import org.mybatis.spring.annotation.MapperScan; diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java b/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java index 63e174db9f..d833d5895c 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java +++ b/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.customfilter; import java.lang.annotation.*; diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java b/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java index 64c70fc8d0..3cdf9e0ab4 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java +++ b/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.customfilter; import org.springframework.core.type.classreading.MetadataReader; diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java b/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java index b4d871e7da..307f654930 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java +++ b/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.customfilter; diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java index 64cc3ba15c..a0349afaac 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.datasource.commonsource; import org.mybatis.spring.scan.filter.customfilter.AnnoTypeFilter; diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java index cc2cc05870..86e7048815 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.datasource.commonsource; import org.mybatis.spring.scan.filter.customfilter.ExcludeMaker; diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java index c132943f38..9eda4f5991 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.datasource.commonsource; diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java index b89298dba5..733bc9e51c 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.datasource.datasource1; public interface DataSource1Mapper { diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java index 6a18893bfa..b1427d2d23 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java +++ b/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.mybatis.spring.scan.filter.datasource.datasource2; public interface DataSource2Mapper { From 789a8e32331358fcfbcfe2195f8b3367f800751f Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Tue, 11 Jul 2023 18:57:40 +0800 Subject: [PATCH 556/933] replace start import and format code --- .../mybatis/spring/annotation/MapperScannerRegistrar.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index a7f194c6a6..446ca568f9 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -37,7 +37,11 @@ import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.io.ResourceLoader; import org.springframework.core.type.AnnotationMetadata; -import org.springframework.core.type.filter.*; +import org.springframework.core.type.filter.AnnotationTypeFilter; +import org.springframework.core.type.filter.AspectJTypeFilter; +import org.springframework.core.type.filter.AssignableTypeFilter; +import org.springframework.core.type.filter.RegexPatternTypeFilter; +import org.springframework.core.type.filter.TypeFilter; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; @@ -59,6 +63,7 @@ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware { private ResourceLoader resourceLoader; + /** * {@inheritDoc} */ From eb9e79e9af759f9d3e0e35cbc9dfb7ea60314f59 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Wed, 12 Jul 2023 13:17:37 +0800 Subject: [PATCH 557/933] move package 'filter' from org.mybatis.spring.scan to org.mybatis.spring --- .../{scan => }/filter/ScanFilterTest.java | 4 ++-- .../{scan => }/filter/config/AppConfig.java | 20 +++++++++---------- .../filter/customfilter/AnnoTypeFilter.java | 2 +- .../filter/customfilter/CustomTypeFilter.java | 2 +- .../filter/customfilter/ExcludeMaker.java | 2 +- .../commonsource/AnnoExcludeMapper.java | 4 ++-- .../commonsource/AssignableMapper.java | 4 ++-- .../commonsource/CommonDataSourceMapper.java | 2 +- .../datasource1/DataSource1Mapper.java | 2 +- .../datasource2/DataSource2Mapper.java | 2 +- 10 files changed, 22 insertions(+), 22 deletions(-) rename src/test/java/org/mybatis/spring/{scan => }/filter/ScanFilterTest.java (97%) rename src/test/java/org/mybatis/spring/{scan => }/filter/config/AppConfig.java (68%) rename src/test/java/org/mybatis/spring/{scan => }/filter/customfilter/AnnoTypeFilter.java (93%) rename src/test/java/org/mybatis/spring/{scan => }/filter/customfilter/CustomTypeFilter.java (95%) rename src/test/java/org/mybatis/spring/{scan => }/filter/customfilter/ExcludeMaker.java (92%) rename src/test/java/org/mybatis/spring/{scan => }/filter/datasource/commonsource/AnnoExcludeMapper.java (83%) rename src/test/java/org/mybatis/spring/{scan => }/filter/datasource/commonsource/AssignableMapper.java (84%) rename src/test/java/org/mybatis/spring/{scan => }/filter/datasource/commonsource/CommonDataSourceMapper.java (91%) rename src/test/java/org/mybatis/spring/{scan => }/filter/datasource/datasource1/DataSource1Mapper.java (91%) rename src/test/java/org/mybatis/spring/{scan => }/filter/datasource/datasource2/DataSource2Mapper.java (91%) diff --git a/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java similarity index 97% rename from src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java rename to src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 9f8cba64d7..249c25c68f 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter; +package org.mybatis.spring.filter; import com.mockrunner.mock.jdbc.MockDataSource; import org.junit.jupiter.api.Test; import org.mybatis.spring.SqlSessionFactoryBean; -import org.mybatis.spring.scan.filter.config.AppConfig; +import org.mybatis.spring.filter.config.AppConfig; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java similarity index 68% rename from src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java rename to src/test/java/org/mybatis/spring/filter/config/AppConfig.java index 1143bf6684..98548f1596 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.config; +package org.mybatis.spring.filter.config; import org.mybatis.spring.annotation.MapperScan; -import org.mybatis.spring.scan.filter.customfilter.AnnoTypeFilter; -import org.mybatis.spring.scan.filter.customfilter.ExcludeMaker; -import org.mybatis.spring.scan.filter.customfilter.CustomTypeFilter; +import org.mybatis.spring.filter.customfilter.ExcludeMaker; +import org.mybatis.spring.filter.customfilter.AnnoTypeFilter; +import org.mybatis.spring.filter.customfilter.CustomTypeFilter; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; @@ -26,32 +26,32 @@ public class AppConfig { - @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class)}) public static class CustomFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class)}) public static class AnnoFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ExcludeMaker.class)}) public static class AssignableFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, - pattern = "org\\.mybatis\\.spring\\.scan\\.filter\\.datasource\\.datasource1\\..*")}) + pattern = "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*")}) public static class RegexFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.scan.filter.datasource", + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = {@ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = "*..DataSource1Mapper")}) public static class AspectJFilterConfig { diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java b/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java similarity index 93% rename from src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java rename to src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java index d833d5895c..c07e9056e8 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/customfilter/AnnoTypeFilter.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.customfilter; +package org.mybatis.spring.filter.customfilter; import java.lang.annotation.*; diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java b/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java similarity index 95% rename from src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java rename to src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java index 3cdf9e0ab4..4808b677a8 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/customfilter/CustomTypeFilter.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.customfilter; +package org.mybatis.spring.filter.customfilter; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; diff --git a/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java b/src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java similarity index 92% rename from src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java rename to src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java index 307f654930..1699dd5f62 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/customfilter/ExcludeMaker.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.customfilter; +package org.mybatis.spring.filter.customfilter; public interface ExcludeMaker { diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/AnnoExcludeMapper.java similarity index 83% rename from src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java rename to src/test/java/org/mybatis/spring/filter/datasource/commonsource/AnnoExcludeMapper.java index a0349afaac..bb6db54c4a 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AnnoExcludeMapper.java +++ b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/AnnoExcludeMapper.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.datasource.commonsource; +package org.mybatis.spring.filter.datasource.commonsource; -import org.mybatis.spring.scan.filter.customfilter.AnnoTypeFilter; +import org.mybatis.spring.filter.customfilter.AnnoTypeFilter; @AnnoTypeFilter public interface AnnoExcludeMapper { diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/AssignableMapper.java similarity index 84% rename from src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java rename to src/test/java/org/mybatis/spring/filter/datasource/commonsource/AssignableMapper.java index 86e7048815..7a8398f287 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/AssignableMapper.java +++ b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/AssignableMapper.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.datasource.commonsource; +package org.mybatis.spring.filter.datasource.commonsource; -import org.mybatis.spring.scan.filter.customfilter.ExcludeMaker; +import org.mybatis.spring.filter.customfilter.ExcludeMaker; public interface AssignableMapper extends ExcludeMaker { } diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java similarity index 91% rename from src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java rename to src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java index 9eda4f5991..33cd4bcbb0 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/commonsource/CommonDataSourceMapper.java +++ b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.datasource.commonsource; +package org.mybatis.spring.filter.datasource.commonsource; public interface CommonDataSourceMapper { diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java b/src/test/java/org/mybatis/spring/filter/datasource/datasource1/DataSource1Mapper.java similarity index 91% rename from src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java rename to src/test/java/org/mybatis/spring/filter/datasource/datasource1/DataSource1Mapper.java index 733bc9e51c..2249c92e23 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource1/DataSource1Mapper.java +++ b/src/test/java/org/mybatis/spring/filter/datasource/datasource1/DataSource1Mapper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.datasource.datasource1; +package org.mybatis.spring.filter.datasource.datasource1; public interface DataSource1Mapper { } diff --git a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java b/src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper.java similarity index 91% rename from src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java rename to src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper.java index b1427d2d23..5f94c5b89d 100644 --- a/src/test/java/org/mybatis/spring/scan/filter/datasource/datasource2/DataSource2Mapper.java +++ b/src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mybatis.spring.scan.filter.datasource.datasource2; +package org.mybatis.spring.filter.datasource.datasource2; public interface DataSource2Mapper { } From e550bff958a0a35243f225cde4a597776a2a1e9e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 10:40:31 +0000 Subject: [PATCH 558/933] Update spring core to v6.0.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0250c1e0e2..63b7d36020 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.10 + 6.0.11 5.0.2 org.mybatis.spring From f3344d717239af39a8c2dc546a2a240d49d63f13 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sat, 15 Jul 2023 16:02:43 +0800 Subject: [PATCH 559/933] fix combined exclude filter and add combined filter test --- .../mybatis/spring/annotation/MapperScan.java | 4 +- .../annotation/MapperScannerRegistrar.java | 8 +++- .../mapper/MapperScannerConfigurer.java | 2 + .../mybatis/spring/filter/ScanFilterTest.java | 46 +++++++++++++++++++ .../spring/filter/config/AppConfig.java | 25 ++++++++++ .../datasource1/MapperWithAnnoFilter.java | 22 +++++++++ .../datasource2/DataSource2Mapper1.java | 19 ++++++++ 7 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/filter/datasource/datasource1/MapperWithAnnoFilter.java create mode 100644 src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper1.java diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index fee540804f..402dd54058 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -196,9 +196,11 @@ * @return a flag that whether execute a property placeholder processing or not */ boolean processPropertyPlaceHolders() default true; - + /** * Specifies which types are not eligible for mapper scanning. + * + * @since 3.0.3 */ ComponentScan.Filter[] excludeFilters() default {}; diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index 446ca568f9..8603b61c11 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -134,8 +134,12 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a } AnnotationAttributes[] excludeFilterArray = annoAttrs.getAnnotationArray("excludeFilters"); - for (AnnotationAttributes excludeFilters : excludeFilterArray) { - builder.addPropertyValue("excludeFilters", typeFiltersFor(excludeFilters)); + if (excludeFilterArray.length > 0) { + List typeFilters = new ArrayList<>(); + for (AnnotationAttributes excludeFilters : excludeFilterArray) { + typeFilters.addAll(typeFiltersFor(excludeFilters)); + } + builder.addPropertyValue("excludeFilters", typeFilters); } String lazyInitialization = annoAttrs.getString("lazyInitialization"); diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index bfef6ed6b3..8cebdb74c9 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -200,6 +200,8 @@ public void setMarkerInterface(Class superClass) { *

    * The scanner will exclude types that define with excludeFilters. * + * @since 3.0.3 + * * @param excludeFilters * list of TypeFilter */ diff --git a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 249c25c68f..7206fb729e 100644 --- a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -97,6 +97,52 @@ void testAspectJScanFilter() { } + @Test + void combinedScanFilter() { + // combined filter with Custom and Annotation + startContext(AppConfig.CombinedFilterConfig.class); + + // exclude datasource2.DataSource2Mapper by CustomTypeFilter + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + // exclude datasource1.MapperWithAnnoFilter by AnnoTypeFilter + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isEqualTo(false); + + // other mapper could be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); + } + + + @Test + void multiPatternRegexScanFilter() { + // multi pattern regex filter + startContext(AppConfig.MultiPatternRegexFilterConfig.class); + + // exclude datasource1 by pattern[0] + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + // exclude datasource2 by pattern[1] + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + + // other mapper could be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + } + + @Test + void multiPatternAspectJScanFilter() { + // multi pattern regex filter + startContext(AppConfig.MultiPatternAspectJFilterConfig.class); + + // exclude datasource1 by pattern[0] + assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + // exclude datasource2 by pattern[1] + assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + + // other mapper could be registered to beanFactory correctly. + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("dataSource2Mapper1")).isEqualTo(true); + } + + private void startContext(Class config) { applicationContext = new AnnotationConfigApplicationContext(); // use @MapperScan with excludeFilters in AppConfig.class diff --git a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java index 98548f1596..36e437d07b 100644 --- a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -57,5 +57,30 @@ public static class RegexFilterConfig { public static class AspectJFilterConfig { } + + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class), + @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class)}) + public static class CombinedFilterConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, + pattern = {"org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*", + "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource2\\..*"})}) + public static class MultiPatternRegexFilterConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.ASPECTJ, + pattern = {"*..DataSource1Mapper", + "*..DataSource2Mapper"})}) + public static class MultiPatternAspectJFilterConfig { + + } + } diff --git a/src/test/java/org/mybatis/spring/filter/datasource/datasource1/MapperWithAnnoFilter.java b/src/test/java/org/mybatis/spring/filter/datasource/datasource1/MapperWithAnnoFilter.java new file mode 100644 index 0000000000..e7b93138e0 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/datasource/datasource1/MapperWithAnnoFilter.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.spring.filter.datasource.datasource1; + +import org.mybatis.spring.filter.customfilter.AnnoTypeFilter; + +@AnnoTypeFilter +public interface MapperWithAnnoFilter { +} diff --git a/src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper1.java b/src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper1.java new file mode 100644 index 0000000000..4df89b6b1f --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/datasource/datasource2/DataSource2Mapper1.java @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.spring.filter.datasource.datasource2; + +public interface DataSource2Mapper1 { +} From 7fefb72ee38384d4e2a851ee3fcd00a4df27d028 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sat, 15 Jul 2023 17:26:18 +0800 Subject: [PATCH 560/933] modify exception prompt message and add exception test code --- .../annotation/MapperScannerRegistrar.java | 20 ++++++++++-------- .../mybatis/spring/filter/ScanFilterTest.java | 21 +++++++++++++++++++ .../spring/filter/config/AppConfig.java | 18 ++++++++++++++++ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index 8603b61c11..fab9705bfd 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -170,7 +170,7 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { switch (filterType) { case ANNOTATION: Assert.isAssignable(Annotation.class, filterClass, - "An error occured when processing a @ComponentScan " + "ANNOTATION type filter: "); + "Specified an unsupported type in 'ANNOTATION' exclude filter of @MapperScan"); @SuppressWarnings("unchecked") Class annoClass = (Class) filterClass; typeFilters.add(new AnnotationTypeFilter(annoClass)); @@ -184,19 +184,21 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class)); break; default: - throw new IllegalArgumentException("Unknown filter type " + filterType); + throw new IllegalArgumentException("Cannot specify the 'value' or 'classes' attribute if use the " + filterType + " FilterType in exclude filter of @MapperScan"); } } String[] expressionArray = filterAttributes.getStringArray("pattern"); for (String expression : expressionArray) { - String rawName = filterType.toString(); - if ("REGEX".equals(rawName)) { - typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression))); - } else if ("ASPECTJ".equals(rawName)) { - typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader())); - } else { - throw new IllegalArgumentException("Unknown filter type " + filterType); + switch (filterType) { + case REGEX: + typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression))); + break; + case ASPECTJ: + typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader())); + break; + default: + throw new IllegalArgumentException("Cannot specify the 'pattern' attribute if use the " + filterType + " FilterType in exclude filter of @MapperScan"); } } return typeFilters; diff --git a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 7206fb729e..01f257884d 100644 --- a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -23,6 +23,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * test the function of excludeFilters in @MapperScan @@ -143,6 +144,26 @@ void multiPatternAspectJScanFilter() { } + @Test + void invalidTypeFilter() { + // invalid value using Annotation type filter + assertThrows(IllegalArgumentException.class, + () -> startContext(AppConfig.InvalidFilterTypeConfig.class)); + } + + @Test + void invalidPropertyPattern() { + assertThrows(IllegalArgumentException.class, + () -> startContext(AppConfig.AnnoTypeWithPatternPropertyConfig.class)); + } + + @Test + void invalidPropertyClasses() { + assertThrows(IllegalArgumentException.class, + () -> startContext(AppConfig.RegexTypeWithClassesPropertyConfig.class)); + } + + private void startContext(Class config) { applicationContext = new AnnotationConfigApplicationContext(); // use @MapperScan with excludeFilters in AppConfig.class diff --git a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java index 36e437d07b..c519520e3a 100644 --- a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -82,5 +82,23 @@ public static class MultiPatternAspectJFilterConfig { } + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = ExcludeMaker.class)}) + public static class InvalidFilterTypeConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, + pattern = {"org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*"})}) + public static class AnnoTypeWithPatternPropertyConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", + excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, value = AnnoTypeFilter.class)}) + public static class RegexTypeWithClassesPropertyConfig { + + } } From f449b4c17fdeb22789e5384e4efdc962e5e56a15 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sat, 15 Jul 2023 20:21:52 +0800 Subject: [PATCH 561/933] code format --- .../annotation/MapperScannerRegistrar.java | 11 ++-- .../mapper/MapperScannerConfigurer.java | 2 +- .../spring/filter/config/AppConfig.java | 62 ++++++++----------- .../filter/customfilter/AnnoTypeFilter.java | 2 +- .../filter/customfilter/CustomTypeFilter.java | 4 +- .../filter/customfilter/ExcludeMaker.java | 1 - .../commonsource/CommonDataSourceMapper.java | 1 - 7 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index fab9705bfd..a3c98e603e 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -170,7 +170,7 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { switch (filterType) { case ANNOTATION: Assert.isAssignable(Annotation.class, filterClass, - "Specified an unsupported type in 'ANNOTATION' exclude filter of @MapperScan"); + "Specified an unsupported type in 'ANNOTATION' exclude filter of @MapperScan"); @SuppressWarnings("unchecked") Class annoClass = (Class) filterClass; typeFilters.add(new AnnotationTypeFilter(annoClass)); @@ -180,11 +180,12 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { break; case CUSTOM: Assert.isAssignable(TypeFilter.class, filterClass, - "An error occured when processing a @ComponentScan " + "CUSTOM type filter: "); + "An error occured when processing a @ComponentScan " + "CUSTOM type filter: "); typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class)); break; default: - throw new IllegalArgumentException("Cannot specify the 'value' or 'classes' attribute if use the " + filterType + " FilterType in exclude filter of @MapperScan"); + throw new IllegalArgumentException("Cannot specify the 'value' or 'classes' attribute if use the " + + filterType + " FilterType in exclude filter of @MapperScan"); } } @@ -198,13 +199,13 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader())); break; default: - throw new IllegalArgumentException("Cannot specify the 'pattern' attribute if use the " + filterType + " FilterType in exclude filter of @MapperScan"); + throw new IllegalArgumentException("Cannot specify the 'pattern' attribute if use the " + filterType + + " FilterType in exclude filter of @MapperScan"); } } return typeFilters; } - private static String generateBaseBeanName(AnnotationMetadata importingClassMetadata, int index) { return importingClassMetadata.getClassName() + "#" + MapperScannerRegistrar.class.getSimpleName() + "#" + index; } diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 8cebdb74c9..07455682ad 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java index c519520e3a..a040e8d359 100644 --- a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -16,89 +16,81 @@ package org.mybatis.spring.filter.config; import org.mybatis.spring.annotation.MapperScan; -import org.mybatis.spring.filter.customfilter.ExcludeMaker; import org.mybatis.spring.filter.customfilter.AnnoTypeFilter; import org.mybatis.spring.filter.customfilter.CustomTypeFilter; +import org.mybatis.spring.filter.customfilter.ExcludeMaker; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; - public class AppConfig { - - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class)}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class) }) public static class CustomFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class)}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class) }) public static class AnnoFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ExcludeMaker.class)}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ExcludeMaker.class) }) public static class AssignableFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, - pattern = "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*")}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*") }) public static class RegexFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.ASPECTJ, - pattern = "*..DataSource1Mapper")}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = "*..DataSource1Mapper") }) public static class AspectJFilterConfig { } - - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class), - @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class)}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class), + @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class) }) public static class CombinedFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, - pattern = {"org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*", - "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource2\\..*"})}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, pattern = { + "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*", + "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource2\\..*" }) }) public static class MultiPatternRegexFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.ASPECTJ, - pattern = {"*..DataSource1Mapper", - "*..DataSource2Mapper"})}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = { "*..DataSource1Mapper", "*..DataSource2Mapper" }) }) public static class MultiPatternAspectJFilterConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = ExcludeMaker.class)}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.ANNOTATION, value = ExcludeMaker.class) }) public static class InvalidFilterTypeConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, - pattern = {"org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*"})}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.ANNOTATION, pattern = { + "org\\.mybatis\\.spring\\.filter\\.datasource\\.datasource1\\..*" }) }) public static class AnnoTypeWithPatternPropertyConfig { } - @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", - excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, value = AnnoTypeFilter.class)}) + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, value = AnnoTypeFilter.class) }) public static class RegexTypeWithClassesPropertyConfig { } } - diff --git a/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java b/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java index c07e9056e8..e32715a1c7 100644 --- a/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java @@ -18,7 +18,7 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) +@Target({ ElementType.TYPE }) @Documented public @interface AnnoTypeFilter { } diff --git a/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java b/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java index 4808b677a8..52f8e05875 100644 --- a/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java @@ -15,12 +15,12 @@ */ package org.mybatis.spring.filter.customfilter; +import java.io.IOException; + import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.filter.TypeFilter; -import java.io.IOException; - public class CustomTypeFilter implements TypeFilter { @Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { diff --git a/src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java b/src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java index 1699dd5f62..155235af99 100644 --- a/src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/ExcludeMaker.java @@ -15,6 +15,5 @@ */ package org.mybatis.spring.filter.customfilter; - public interface ExcludeMaker { } diff --git a/src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java index 33cd4bcbb0..1c6446904f 100644 --- a/src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java +++ b/src/test/java/org/mybatis/spring/filter/datasource/commonsource/CommonDataSourceMapper.java @@ -15,6 +15,5 @@ */ package org.mybatis.spring.filter.datasource.commonsource; - public interface CommonDataSourceMapper { } From 756531a4f65c1ed3d300abe29e0f04c8b93d1bc3 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sun, 16 Jul 2023 16:51:29 +0800 Subject: [PATCH 562/933] support exclude filter on mapper scan with xml --- .../MapperScannerBeanDefinitionParser.java | 74 ++++++++++ .../mybatis/spring/config/mybatis-spring.xsd | 45 +++++++ .../mybatis/spring/filter/ScanFilterTest.java | 81 +++++------ .../spring/filter/xml/XmlScanFilterTest.java | 126 ++++++++++++++++++ .../filter/xml/appContextAnnoFilter.xml | 45 +++++++ .../filter/xml/appContextAspectJFilter.xml | 45 +++++++ .../filter/xml/appContextAssignFilter.xml | 45 +++++++ .../filter/xml/appContextCombinedFilter.xml | 49 +++++++ .../filter/xml/appContextCustFilter.xml | 45 +++++++ .../filter/xml/appContextInvalidFilter.xml | 45 +++++++ .../filter/xml/appContextInvalidFilter1.xml | 45 +++++++ .../filter/xml/appContextRegexFilter.xml | 45 +++++++ 12 files changed, 646 insertions(+), 44 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index 927cd627d6..4a2a1b9aea 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -16,6 +16,9 @@ package org.mybatis.spring.config; import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; import org.mybatis.spring.mapper.ClassPathMapperScanner; import org.mybatis.spring.mapper.MapperFactoryBean; @@ -28,9 +31,17 @@ import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.XmlReaderContext; +import org.springframework.core.type.filter.AnnotationTypeFilter; +import org.springframework.core.type.filter.AspectJTypeFilter; +import org.springframework.core.type.filter.AssignableTypeFilter; +import org.springframework.core.type.filter.RegexPatternTypeFilter; +import org.springframework.core.type.filter.TypeFilter; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * A {#code BeanDefinitionParser} that handles the element scan of the MyBatis. namespace @@ -57,6 +68,7 @@ public class MapperScannerBeanDefinitionParser extends AbstractBeanDefinitionPar private static final String ATTRIBUTE_LAZY_INITIALIZATION = "lazy-initialization"; private static final String ATTRIBUTE_DEFAULT_SCOPE = "default-scope"; private static final String ATTRIBUTE_PROCESS_PROPERTY_PLACEHOLDERS = "process-property-placeholders"; + private static final String ATTRIBUTE_EXCLUDE_FILTER = "exclude-filter"; /** * {@inheritDoc} @@ -98,6 +110,12 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa .loadClass(mapperFactoryBeanClassName); builder.addPropertyValue("mapperFactoryBeanClass", mapperFactoryBeanClass); } + + // parse exclude-filter + List typeFilters = parseTypeFilters(element, parserContext, classLoader); + if (!typeFilters.isEmpty()) { + builder.addPropertyValue("excludeFilters", typeFilters); + } } catch (Exception ex) { XmlReaderContext readerContext = parserContext.getReaderContext(); readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause()); @@ -115,6 +133,62 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa return builder.getBeanDefinition(); } + private List parseTypeFilters(Element element, ParserContext parserContext, ClassLoader classLoader) { + // Parse exclude filter elements. + List typeFilters = new ArrayList<>(); + NodeList nodeList = element.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node node = nodeList.item(i); + if (Node.ELEMENT_NODE == node.getNodeType()) { + String localName = parserContext.getDelegate().getLocalName(node); + try { + if (ATTRIBUTE_EXCLUDE_FILTER.equals(localName)) { + TypeFilter typeFilter = createTypeFilter((Element) node, classLoader, parserContext); + typeFilters.add(typeFilter); + } + } catch (ClassNotFoundException ex) { + parserContext.getReaderContext().warning("Ignoring non-present type filter class: " + ex, + parserContext.extractSource(element)); + } catch (Exception ex) { + parserContext.getReaderContext().error(ex.getMessage(), parserContext.extractSource(element), ex.getCause()); + } + } + } + return typeFilters; + } + + @SuppressWarnings("unchecked") + private TypeFilter createTypeFilter(Element element, @Nullable ClassLoader classLoader, ParserContext parserContext) + throws ClassNotFoundException { + String filterType = element.getAttribute("type"); + String expression = element.getAttribute("expression"); + expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); + switch (filterType) { + case "annotation": + Class filterAnno = ClassUtils.forName(expression, classLoader); + if(!Annotation.class.isAssignableFrom(filterAnno)){ + throw new IllegalArgumentException( + "Class is not assignable to [" + Annotation.class.getName() + "]: " + expression); + } + return new AnnotationTypeFilter((Class) filterAnno); + case "custom": + Class filterClass = ClassUtils.forName(expression, classLoader); + if (!TypeFilter.class.isAssignableFrom(filterClass)) { + throw new IllegalArgumentException( + "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); + } + return (TypeFilter) BeanUtils.instantiateClass(filterClass); + case "assignable": + return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); + case "regex": + return new RegexPatternTypeFilter(Pattern.compile(expression)); + case "aspectj": + return new AspectJTypeFilter(expression, classLoader); + default: + throw new IllegalArgumentException("Unsupported filter type: " + filterType); + } + } + /** * {@inheritDoc} * diff --git a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd index 5366717e4d..dcf4caae77 100644 --- a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd +++ b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd @@ -33,6 +33,16 @@ + + + + + + + @@ -160,4 +170,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 01f257884d..f8f99ae37a 100644 --- a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -15,16 +15,17 @@ */ package org.mybatis.spring.filter; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.mockrunner.mock.jdbc.MockDataSource; + import org.junit.jupiter.api.Test; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.filter.config.AppConfig; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * test the function of excludeFilters in @MapperScan */ @@ -32,17 +33,17 @@ public class ScanFilterTest { private AnnotationConfigApplicationContext applicationContext; - @Test void testCustomScanFilter() { startContext(AppConfig.CustomFilterConfig.class); - // use org.mybatis.spring.scan.filter.datasource as basePackages and exclude package datasource2 by MapperScan.excludeFilters + // use org.mybatis.spring.scan.filter.datasource as basePackages and exclude package datasource2 by + // MapperScan.excludeFilters // mapper in package datasource2 will not be registered to beanFactory - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); // mapper in package datasource except datasource2 will be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); } @Test @@ -50,26 +51,25 @@ void testAnnoScanFilter() { startContext(AppConfig.AnnoFilterConfig.class); // use @AnnoTypeFilter to exclude mapper - assertThat(applicationContext.containsBean("annoExcludeMapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("annoExcludeMapper")).isFalse(); // mapper in package datasource except datasource2 will be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isTrue(); } - @Test void testAssignableScanFilter() { startContext(AppConfig.AssignableFilterConfig.class); // exclude AssignableMapper by AssignableFilter - assertThat(applicationContext.containsBean("assignableMapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("assignableMapper")).isFalse(); // mapper in package datasource except datasource2 will be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isTrue(); } @Test @@ -77,11 +77,11 @@ void testRegexScanFilter() { startContext(AppConfig.RegexFilterConfig.class); // exclude package datasource1 by Regex - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isFalse(); // mapper in package datasource except datasource1 will be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isTrue(); } @Test @@ -90,42 +90,40 @@ void testAspectJScanFilter() { startContext(AppConfig.AspectJFilterConfig.class); // exclude dataSource1Mapper by AspectJ - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isFalse(); // mapper in package datasource except datasource1 will be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isTrue(); } - @Test void combinedScanFilter() { // combined filter with Custom and Annotation startContext(AppConfig.CombinedFilterConfig.class); // exclude datasource2.DataSource2Mapper by CustomTypeFilter - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); // exclude datasource1.MapperWithAnnoFilter by AnnoTypeFilter - assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isEqualTo(false); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); // other mapper could be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); } - @Test void multiPatternRegexScanFilter() { // multi pattern regex filter startContext(AppConfig.MultiPatternRegexFilterConfig.class); // exclude datasource1 by pattern[0] - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isFalse(); // exclude datasource2 by pattern[1] - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); // other mapper could be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); } @Test @@ -134,36 +132,32 @@ void multiPatternAspectJScanFilter() { startContext(AppConfig.MultiPatternAspectJFilterConfig.class); // exclude datasource1 by pattern[0] - assertThat(applicationContext.containsBean("dataSource1Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isFalse(); // exclude datasource2 by pattern[1] - assertThat(applicationContext.containsBean("dataSource2Mapper")).isEqualTo(false); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); // other mapper could be registered to beanFactory correctly. - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isEqualTo(true); - assertThat(applicationContext.containsBean("dataSource2Mapper1")).isEqualTo(true); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource2Mapper1")).isTrue(); } - @Test void invalidTypeFilter() { // invalid value using Annotation type filter - assertThrows(IllegalArgumentException.class, - () -> startContext(AppConfig.InvalidFilterTypeConfig.class)); + assertThrows(IllegalArgumentException.class, () -> startContext(AppConfig.InvalidFilterTypeConfig.class)); } @Test void invalidPropertyPattern() { - assertThrows(IllegalArgumentException.class, - () -> startContext(AppConfig.AnnoTypeWithPatternPropertyConfig.class)); + assertThrows(IllegalArgumentException.class, () -> startContext(AppConfig.AnnoTypeWithPatternPropertyConfig.class)); } @Test void invalidPropertyClasses() { assertThrows(IllegalArgumentException.class, - () -> startContext(AppConfig.RegexTypeWithClassesPropertyConfig.class)); + () -> startContext(AppConfig.RegexTypeWithClassesPropertyConfig.class)); } - private void startContext(Class config) { applicationContext = new AnnotationConfigApplicationContext(); // use @MapperScan with excludeFilters in AppConfig.class @@ -173,7 +167,6 @@ private void startContext(Class config) { applicationContext.start(); } - private void setupSqlSessionFactory(String name) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java new file mode 100644 index 0000000000..9f3228556f --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.spring.filter.xml; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * test the function of excludeFilters in + */ +public class XmlScanFilterTest { + + private ClassPathXmlApplicationContext applicationContext; + + @Test + void testCustomScanFilter() { + // exclude datasource2 by CustomTypeFilter + startContext("org/mybatis/spring/filter/xml/appContextCustFilter.xml"); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + + @Test + void testAnnoScanFilter() { + // exclude mappers which has @AnnoTypeFilter + startContext("org/mybatis/spring/filter/xml/appContextAnnoFilter.xml"); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + + @Test + void testAssignScanFilter() { + // exclude mappers which can assignable to ExcludeMaker + startContext("org/mybatis/spring/filter/xml/appContextAssignFilter.xml"); + assertThat(applicationContext.containsBean("assignableMapper")).isFalse(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + + @Test + void testRegexScanFilter() { + // exclude datasource1 by regex + startContext("org/mybatis/spring/filter/xml/appContextRegexFilter.xml"); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isFalse(); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + + @Test + void testAspectJScanFilter() { + // exclude mappers which class name start with DataSource + startContext("org/mybatis/spring/filter/xml/appContextAspectJFilter.xml"); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isFalse(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + + @Test + void testCombinedScanFilter() { + // exclude filters combined with Annotation Custom and Assignable + startContext("org/mybatis/spring/filter/xml/appContextCombinedFilter.xml"); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); + assertThat(applicationContext.containsBean("assignableMapper")).isFalse(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + + @Test + void invalidPatternFilter() { + try { + startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter.xml"); + } catch (BeanDefinitionParsingException ex) { + assertThat(ex.getMessage()).contains("Class is not assignable to [java.lang.annotation.Annotation]"); + } finally { + closeContext(); + } + } + + @Test + void invalidPropertyPattern() { + assertThrows(BeanDefinitionParsingException.class, + () -> startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml")); + closeContext(); + } + + + private void startContext(String config) { + applicationContext = new ClassPathXmlApplicationContext(config); + applicationContext.refresh(); + applicationContext.start(); + } + + private void closeContext() { + if (null != applicationContext) + applicationContext.close(); + } +} diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml new file mode 100644 index 0000000000..67d1db1e37 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml new file mode 100644 index 0000000000..952f381415 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml new file mode 100644 index 0000000000..afddfa1898 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml new file mode 100644 index 0000000000..60ba0132ec --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml new file mode 100644 index 0000000000..8d5aa2dd72 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml new file mode 100644 index 0000000000..dd3ee9281d --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml new file mode 100644 index 0000000000..49c126b478 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml new file mode 100644 index 0000000000..6bd23fb252 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + From 564c1086fa709d7125418535e4f1b6904ee3ba87 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Sun, 16 Jul 2023 17:17:36 +0800 Subject: [PATCH 563/933] add more test --- .../spring/filter/xml/XmlScanFilterTest.java | 11 +++++ .../filter/xml/appContextPlaceHolder.xml | 47 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java index 9f3228556f..ac6af5f929 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -49,6 +49,17 @@ void testAnnoScanFilter() { closeContext(); } + @Test + void testAnnoScanWithPlaceHolderFilter() { + // exclude mappers which has @AnnoTypeFilter + System.getProperties().put("annoFilter","org.mybatis.spring.filter.customfilter.AnnoTypeFilter"); + startContext("org/mybatis/spring/filter/xml/appContextPlaceHolder.xml"); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + @Test void testAssignScanFilter() { // exclude mappers which can assignable to ExcludeMaker diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml new file mode 100644 index 0000000000..75398c62e5 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + From 3e67f256c501a96d894182aeb8c10187185b22d1 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Tue, 18 Jul 2023 18:08:52 +0800 Subject: [PATCH 564/933] Optimized process to parse excludeFilters --- .../mybatis/spring/annotation/MapperScan.java | 2 + .../annotation/MapperScannerRegistrar.java | 67 ++++++++++---- .../MapperScannerBeanDefinitionParser.java | 70 +++------------ .../mapper/MapperScannerConfigurer.java | 89 +++++++++++++++++++ .../mybatis/spring/config/mybatis-spring.xsd | 8 +- .../mybatis/spring/filter/ScanFilterTest.java | 57 +++++++++--- .../spring/filter/config/AppConfig.java | 32 ++++++- .../filter/config/application.properties | 18 ++++ .../spring/filter/xml/XmlScanFilterTest.java | 42 ++++++--- .../filter/xml/appContextCombinedFilter.xml | 7 +- .../filter/xml/appContextInvalidFilter2.xml | 45 ++++++++++ .../filter/xml/appContextPlaceHolder1.xml | 49 ++++++++++ .../spring/filter/xml/default.properties | 18 ++++ 13 files changed, 395 insertions(+), 109 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/filter/config/application.properties create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml create mode 100644 src/test/java/org/mybatis/spring/filter/xml/default.properties diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index 402dd54058..e533833492 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -201,6 +201,8 @@ * Specifies which types are not eligible for mapper scanning. * * @since 3.0.3 + * + * @return array of customized mapper excludeFilter */ ComponentScan.Filter[] excludeFilters() default {}; diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index a3c98e603e..88155e15e0 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -18,8 +18,9 @@ import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; -import java.util.regex.Pattern; +import java.util.Map; import java.util.stream.Collectors; import org.mybatis.spring.mapper.ClassPathMapperScanner; @@ -38,9 +39,7 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.filter.AnnotationTypeFilter; -import org.springframework.core.type.filter.AspectJTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter; -import org.springframework.core.type.filter.RegexPatternTypeFilter; import org.springframework.core.type.filter.TypeFilter; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -136,10 +135,17 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a AnnotationAttributes[] excludeFilterArray = annoAttrs.getAnnotationArray("excludeFilters"); if (excludeFilterArray.length > 0) { List typeFilters = new ArrayList<>(); + List> rawTypeFilters = new ArrayList<>(); for (AnnotationAttributes excludeFilters : excludeFilterArray) { - typeFilters.addAll(typeFiltersFor(excludeFilters)); + if (excludeFilters.getStringArray("pattern").length > 0) { + // in oder to apply placeholder resolver + rawTypeFilters.addAll(parseFiltersHasPatterns(excludeFilters)); + } else { + typeFilters.addAll(typeFiltersFor(excludeFilters)); + } } builder.addPropertyValue("excludeFilters", typeFilters); + builder.addPropertyValue("rawExcludeFilters", rawTypeFilters); } String lazyInitialization = annoAttrs.getString("lazyInitialization"); @@ -161,6 +167,44 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a } + /** + * Parse excludeFilters which FilterType is REGEX or ASPECTJ + * + * @param filterAttributes + * AnnotationAttributes of excludeFilters + * + * @since 3.0.3 + */ + private List> parseFiltersHasPatterns(AnnotationAttributes filterAttributes) { + + List> rawTypeFilters = new ArrayList<>(); + FilterType filterType = filterAttributes.getEnum("type"); + String[] expressionArray = filterAttributes.getStringArray("pattern"); + for (String expression : expressionArray) { + switch (filterType) { + case REGEX: + case ASPECTJ: + Map typeFilter = new HashMap<>(16); + typeFilter.put("type", filterType.name().toLowerCase()); + typeFilter.put("expression", expression); + rawTypeFilters.add(typeFilter); + break; + default: + throw new IllegalArgumentException("Cannot specify the 'pattern' attribute if use the " + filterType + + " FilterType in exclude filter of @MapperScan"); + } + } + return rawTypeFilters; + } + + /** + * Parse excludeFilters which FilterType is ANNOTATION ASSIGNABLE or CUSTOM + * + * @param filterAttributes + * AnnotationAttributes of excludeFilters + * + * @since 3.0.3 + */ private List typeFiltersFor(AnnotationAttributes filterAttributes) { List typeFilters = new ArrayList<>(); @@ -188,21 +232,6 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { + filterType + " FilterType in exclude filter of @MapperScan"); } } - - String[] expressionArray = filterAttributes.getStringArray("pattern"); - for (String expression : expressionArray) { - switch (filterType) { - case REGEX: - typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression))); - break; - case ASPECTJ: - typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader())); - break; - default: - throw new IllegalArgumentException("Cannot specify the 'pattern' attribute if use the " + filterType - + " FilterType in exclude filter of @MapperScan"); - } - } return typeFilters; } diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index 4a2a1b9aea..5858a2e3b6 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -17,8 +17,9 @@ import java.lang.annotation.Annotation; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.regex.Pattern; +import java.util.Map; import org.mybatis.spring.mapper.ClassPathMapperScanner; import org.mybatis.spring.mapper.MapperFactoryBean; @@ -31,12 +32,6 @@ import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.XmlReaderContext; -import org.springframework.core.type.filter.AnnotationTypeFilter; -import org.springframework.core.type.filter.AspectJTypeFilter; -import org.springframework.core.type.filter.AssignableTypeFilter; -import org.springframework.core.type.filter.RegexPatternTypeFilter; -import org.springframework.core.type.filter.TypeFilter; -import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; @@ -111,11 +106,12 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa builder.addPropertyValue("mapperFactoryBeanClass", mapperFactoryBeanClass); } - // parse exclude-filter - List typeFilters = parseTypeFilters(element, parserContext, classLoader); - if (!typeFilters.isEmpty()) { - builder.addPropertyValue("excludeFilters", typeFilters); + // parse raw exclude-filter in + List> rawExcludeFilters = parseScanTypeFilters(element, parserContext); + if (!rawExcludeFilters.isEmpty()) { + builder.addPropertyValue("rawExcludeFilters", rawExcludeFilters); } + } catch (Exception ex) { XmlReaderContext readerContext = parserContext.getReaderContext(); readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause()); @@ -133,62 +129,24 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa return builder.getBeanDefinition(); } - private List parseTypeFilters(Element element, ParserContext parserContext, ClassLoader classLoader) { - // Parse exclude filter elements. - List typeFilters = new ArrayList<>(); + private List> parseScanTypeFilters(Element element, ParserContext parserContext) { + List> typeFilters = new ArrayList<>(); NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { String localName = parserContext.getDelegate().getLocalName(node); - try { - if (ATTRIBUTE_EXCLUDE_FILTER.equals(localName)) { - TypeFilter typeFilter = createTypeFilter((Element) node, classLoader, parserContext); - typeFilters.add(typeFilter); - } - } catch (ClassNotFoundException ex) { - parserContext.getReaderContext().warning("Ignoring non-present type filter class: " + ex, - parserContext.extractSource(element)); - } catch (Exception ex) { - parserContext.getReaderContext().error(ex.getMessage(), parserContext.extractSource(element), ex.getCause()); + if (ATTRIBUTE_EXCLUDE_FILTER.equals(localName)) { + Map filter = new HashMap<>(16); + filter.put("type", ((Element) node).getAttribute("type")); + filter.put("expression", ((Element) node).getAttribute("expression")); + typeFilters.add(filter); } } } return typeFilters; } - @SuppressWarnings("unchecked") - private TypeFilter createTypeFilter(Element element, @Nullable ClassLoader classLoader, ParserContext parserContext) - throws ClassNotFoundException { - String filterType = element.getAttribute("type"); - String expression = element.getAttribute("expression"); - expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); - switch (filterType) { - case "annotation": - Class filterAnno = ClassUtils.forName(expression, classLoader); - if(!Annotation.class.isAssignableFrom(filterAnno)){ - throw new IllegalArgumentException( - "Class is not assignable to [" + Annotation.class.getName() + "]: " + expression); - } - return new AnnotationTypeFilter((Class) filterAnno); - case "custom": - Class filterClass = ClassUtils.forName(expression, classLoader); - if (!TypeFilter.class.isAssignableFrom(filterClass)) { - throw new IllegalArgumentException( - "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); - } - return (TypeFilter) BeanUtils.instantiateClass(filterClass); - case "assignable": - return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); - case "regex": - return new RegexPatternTypeFilter(Pattern.compile(expression)); - case "aspectj": - return new AspectJTypeFilter(expression, classLoader); - default: - throw new IllegalArgumentException("Unsupported filter type: " + filterType); - } - } - /** * {@inheritDoc} * diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 07455682ad..9525f41869 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -18,12 +18,15 @@ import static org.springframework.util.Assert.notNull; import java.lang.annotation.Annotation; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.regex.Pattern; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.BeanUtils; import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.BeanNameAware; @@ -40,7 +43,13 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.Environment; +import org.springframework.core.type.filter.AnnotationTypeFilter; +import org.springframework.core.type.filter.AspectJTypeFilter; +import org.springframework.core.type.filter.AssignableTypeFilter; +import org.springframework.core.type.filter.RegexPatternTypeFilter; import org.springframework.core.type.filter.TypeFilter; +import org.springframework.lang.Nullable; +import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** @@ -113,6 +122,8 @@ public class MapperScannerConfigurer private List excludeFilters; + private List> rawExcludeFilters; + private Class mapperFactoryBeanClass; private ApplicationContext applicationContext; @@ -209,6 +220,20 @@ public void setExcludeFilters(List excludeFilters) { this.excludeFilters = excludeFilters; } + /** + * In order to support process PropertyPlaceHolders. + *

    + * After parsed, it will be added to excludeFilters. + * + * @since 3.0.3 + * + * @param rawExcludeFilters + * list of rawExcludeFilter + */ + public void setRawExcludeFilters(List> rawExcludeFilters) { + this.rawExcludeFilters = rawExcludeFilters; + } + /** * Specifies which {@code SqlSessionTemplate} to use in the case that there is more than one in the spring context. * Usually this is only needed when you have more than one datasource. @@ -432,6 +457,7 @@ private void processPropertyPlaceHolders() { this.sqlSessionTemplateBeanName = getPropertyValue("sqlSessionTemplateBeanName", values); this.lazyInitialization = getPropertyValue("lazyInitialization", values); this.defaultScope = getPropertyValue("defaultScope", values); + this.rawExcludeFilters = getPropertyValueForTypeFilter("rawExcludeFilters", values); } this.basePackage = Optional.ofNullable(this.basePackage).map(getEnvironment()::resolvePlaceholders).orElse(null); this.sqlSessionFactoryBeanName = Optional.ofNullable(this.sqlSessionFactoryBeanName) @@ -441,6 +467,7 @@ private void processPropertyPlaceHolders() { this.lazyInitialization = Optional.ofNullable(this.lazyInitialization).map(getEnvironment()::resolvePlaceholders) .orElse(null); this.defaultScope = Optional.ofNullable(this.defaultScope).map(getEnvironment()::resolvePlaceholders).orElse(null); + this.excludeFilters = mergeExcludeFilters(); } private Environment getEnvironment() { @@ -467,4 +494,66 @@ private String getPropertyValue(String propertyName, PropertyValues values) { } } + @SuppressWarnings("unchecked") + private List> getPropertyValueForTypeFilter(String propertyName, PropertyValues values) { + PropertyValue property = values.getPropertyValue(propertyName); + Object value; + if (property == null || (value = property.getValue()) == null || !(value instanceof List)) { + return null; + } + return (List>) value; + } + + private List mergeExcludeFilters() { + List typeFilters = new ArrayList<>(); + if (this.rawExcludeFilters == null || this.rawExcludeFilters.isEmpty()) { + return this.excludeFilters; + } + if (this.excludeFilters != null && !this.excludeFilters.isEmpty()) { + typeFilters.addAll(this.excludeFilters); + } + try { + for (Map typeFilter : this.rawExcludeFilters) { + typeFilters.add( + createTypeFilter(typeFilter.get("type"), typeFilter.get("expression"), this.getClass().getClassLoader())); + } + } catch (ClassNotFoundException exception) { + throw new RuntimeException("ClassNotFoundException occur when to load the Specified excludeFilter classes.", + exception); + } + return typeFilters; + } + + @SuppressWarnings("unchecked") + private TypeFilter createTypeFilter(String filterType, String expression, @Nullable ClassLoader classLoader) + throws ClassNotFoundException { + + expression = this.getEnvironment().resolvePlaceholders(expression); + + switch (filterType) { + case "annotation": + Class filterAnno = ClassUtils.forName(expression, classLoader); + if (!Annotation.class.isAssignableFrom(filterAnno)) { + throw new IllegalArgumentException( + "Class is not assignable to [" + Annotation.class.getName() + "]: " + expression); + } + return new AnnotationTypeFilter((Class) filterAnno); + case "custom": + Class filterClass = ClassUtils.forName(expression, classLoader); + if (!TypeFilter.class.isAssignableFrom(filterClass)) { + throw new IllegalArgumentException( + "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); + } + return (TypeFilter) BeanUtils.instantiateClass(filterClass); + case "assignable": + return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); + case "regex": + return new RegexPatternTypeFilter(Pattern.compile(expression)); + case "aspectj": + return new AspectJTypeFilter(expression, classLoader); + default: + throw new IllegalArgumentException("Unsupported filter type: " + filterType); + } + } + } diff --git a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd index dcf4caae77..196a6fe35b 100644 --- a/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd +++ b/src/main/resources/org/mybatis/spring/config/mybatis-spring.xsd @@ -177,10 +177,10 @@ startContext(AppConfig.InvalidFilterTypeConfig.class)); } @Test void invalidPropertyPattern() { + // illegal mixed use type Annotation and pattern assertThrows(IllegalArgumentException.class, () -> startContext(AppConfig.AnnoTypeWithPatternPropertyConfig.class)); } @Test void invalidPropertyClasses() { + // illegal mixed use type REGEX and value assertThrows(IllegalArgumentException.class, () -> startContext(AppConfig.RegexTypeWithClassesPropertyConfig.class)); } diff --git a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java index a040e8d359..aede81c9a2 100644 --- a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -19,8 +19,11 @@ import org.mybatis.spring.filter.customfilter.AnnoTypeFilter; import org.mybatis.spring.filter.customfilter.CustomTypeFilter; import org.mybatis.spring.filter.customfilter.ExcludeMaker; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.io.ClassPathResource; public class AppConfig { @@ -56,9 +59,16 @@ public static class AspectJFilterConfig { @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { @ComponentScan.Filter(type = FilterType.CUSTOM, classes = CustomTypeFilter.class), - @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class) }) + @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class), + @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = { "*..DataSource1Mapper", + "${exclude-filters.aspectj}" }) }) public static class CombinedFilterConfig { - + @Bean + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + configurer.setLocation(new ClassPathResource("/org/mybatis/spring/filter/config/application.properties")); + return configurer; + } } @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { @@ -93,4 +103,22 @@ public static class AnnoTypeWithPatternPropertyConfig { public static class RegexTypeWithClassesPropertyConfig { } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "${excludeFilter.regex}") }) + public static class RegexFilterWithPlaceHolderConfig { + + } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "${exclude-filters.regex}") }) + public static class RegexFilterWithPlaceHolderConfig1 { + @Bean + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + configurer.setLocation(new ClassPathResource("/org/mybatis/spring/filter/config/application.properties")); + return configurer; + } + + } } diff --git a/src/test/java/org/mybatis/spring/filter/config/application.properties b/src/test/java/org/mybatis/spring/filter/config/application.properties new file mode 100644 index 0000000000..32576e93d0 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/config/application.properties @@ -0,0 +1,18 @@ +# +# Copyright 2010-2023 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +exclude-filters.regex=org\.mybatis\.spring\.filter\.datasource\.datasource1\..* +exclude-filters.aspectj=*..CommonDataSourceMapper \ No newline at end of file diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java index ac6af5f929..59c94c1eca 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; /** @@ -50,9 +49,9 @@ void testAnnoScanFilter() { } @Test - void testAnnoScanWithPlaceHolderFilter() { + void testScanWithPlaceHolderFilter() { // exclude mappers which has @AnnoTypeFilter - System.getProperties().put("annoFilter","org.mybatis.spring.filter.customfilter.AnnoTypeFilter"); + System.getProperties().put("annoFilter", "org.mybatis.spring.filter.customfilter.AnnoTypeFilter"); startContext("org/mybatis/spring/filter/xml/appContextPlaceHolder.xml"); assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); @@ -60,6 +59,18 @@ void testAnnoScanWithPlaceHolderFilter() { closeContext(); } + @Test + void testScanWithPlaceHolderFilter1() { + // exclude datasource2 mappers by CustomTypeFilter + startContext("org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml"); + assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); + assertThat(applicationContext.containsBean("dataSource2Mapper1")).isFalse(); + assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isTrue(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); + closeContext(); + } + @Test void testAssignScanFilter() { // exclude mappers which can assignable to ExcludeMaker @@ -95,34 +106,37 @@ void testAspectJScanFilter() { @Test void testCombinedScanFilter() { - // exclude filters combined with Annotation Custom and Assignable + // exclude filters combined with Annotation Custom Assignable and aspectj expression startContext("org/mybatis/spring/filter/xml/appContextCombinedFilter.xml"); assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse(); assertThat(applicationContext.containsBean("dataSource2Mapper")).isFalse(); assertThat(applicationContext.containsBean("assignableMapper")).isFalse(); + assertThat(applicationContext.containsBean("commonDataSourceMapper")).isFalse(); + assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue(); - assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue(); closeContext(); } @Test void invalidPatternFilter() { - try { - startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter.xml"); - } catch (BeanDefinitionParsingException ex) { - assertThat(ex.getMessage()).contains("Class is not assignable to [java.lang.annotation.Annotation]"); - } finally { - closeContext(); - } + assertThrows(IllegalArgumentException.class, + () -> startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter.xml")); + closeContext(); } @Test void invalidPropertyPattern() { - assertThrows(BeanDefinitionParsingException.class, - () -> startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml")); + assertThrows(IllegalArgumentException.class, + () -> startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml")); closeContext(); } + @Test + void warpedClassNotFoundException() { + assertThrows(RuntimeException.class, + () -> startContext("org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml")); + closeContext(); + } private void startContext(String config) { applicationContext = new ClassPathXmlApplicationContext(config); diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml index 60ba0132ec..b882eacb27 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml @@ -22,8 +22,9 @@ + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"> @@ -37,6 +38,8 @@ + + @@ -44,6 +47,8 @@ expression="org.mybatis.spring.filter.customfilter.CustomTypeFilter"/> + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml new file mode 100644 index 0000000000..a38d81c527 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml new file mode 100644 index 0000000000..a4a1e2b951 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/default.properties b/src/test/java/org/mybatis/spring/filter/xml/default.properties new file mode 100644 index 0000000000..69057dc48e --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/default.properties @@ -0,0 +1,18 @@ +# +# Copyright 2010-2023 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +filter.custom=org.mybatis.spring.filter.customfilter.CustomTypeFilter +filter.aspectj=*..CommonDataSourceMapper \ No newline at end of file From 82ef68fa8d646b057a8af5f5ff1a72891d271d40 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Wed, 19 Jul 2023 09:38:46 +0800 Subject: [PATCH 565/933] Optimized process to parse excludeFilters and add 'processPropertyPlaceHolders' turn off test --- .../mapper/MapperScannerConfigurer.java | 7 +-- .../mybatis/spring/filter/ScanFilterTest.java | 15 ++++++ .../spring/filter/config/AppConfig.java | 17 +++++++ .../spring/filter/xml/XmlScanFilterTest.java | 10 ++++ .../xml/appContextProcessPlaceHolderOff.xml | 48 +++++++++++++++++++ .../spring/filter/xml/default.properties | 3 +- 6 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 9525f41869..e436513abd 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -407,7 +407,7 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { scanner.setAddToConfig(this.addToConfig); scanner.setAnnotationClass(this.annotationClass); scanner.setMarkerInterface(this.markerInterface); - scanner.setExcludeFilters(this.excludeFilters); + scanner.setExcludeFilters(this.excludeFilters = mergeExcludeFilters()); scanner.setSqlSessionFactory(this.sqlSessionFactory); scanner.setSqlSessionTemplate(this.sqlSessionTemplate); scanner.setSqlSessionFactoryBeanName(this.sqlSessionFactoryBeanName); @@ -467,7 +467,6 @@ private void processPropertyPlaceHolders() { this.lazyInitialization = Optional.ofNullable(this.lazyInitialization).map(getEnvironment()::resolvePlaceholders) .orElse(null); this.defaultScope = Optional.ofNullable(this.defaultScope).map(getEnvironment()::resolvePlaceholders).orElse(null); - this.excludeFilters = mergeExcludeFilters(); } private Environment getEnvironment() { @@ -528,7 +527,9 @@ private List mergeExcludeFilters() { private TypeFilter createTypeFilter(String filterType, String expression, @Nullable ClassLoader classLoader) throws ClassNotFoundException { - expression = this.getEnvironment().resolvePlaceholders(expression); + if (this.processPropertyPlaceHolders) { + expression = this.getEnvironment().resolvePlaceholders(expression); + } switch (filterType) { case "annotation": diff --git a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 14a0e17dd3..76a96a7baf 100644 --- a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -20,6 +20,8 @@ import com.mockrunner.mock.jdbc.MockDataSource; +import java.util.regex.PatternSyntaxException; + import org.junit.jupiter.api.Test; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.filter.config.AppConfig; @@ -189,6 +191,19 @@ void invalidPropertyClasses() { () -> startContext(AppConfig.RegexTypeWithClassesPropertyConfig.class)); } + @Test + void processPropertyPlaceHoldersSwitchTest() { + // if processPropertyPlaceHolders turn off regex compile will fail + assertThrows(PatternSyntaxException.class, + () -> startContext(AppConfig.ProcessPropertyPlaceHoldersOffConfig.class)); + } + + @Test + void processPropertyPlaceHoldersSwitchTest1() { + // processPropertyPlaceHolders turn off has no effect to FilterType which don't use pattern property + startContext(AppConfig.AnnoFilterWithProcessPlaceHolderOffConfig.class); + } + private void startContext(Class config) { applicationContext = new AnnotationConfigApplicationContext(); // use @MapperScan with excludeFilters in AppConfig.class diff --git a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java index aede81c9a2..f331e2d8ce 100644 --- a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -121,4 +121,21 @@ static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer } } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", processPropertyPlaceHolders = false, excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "${exclude-filters.regex}") }) + public static class ProcessPropertyPlaceHoldersOffConfig { + @Bean + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + configurer.setLocation(new ClassPathResource("/org/mybatis/spring/filter/config/application.properties")); + return configurer; + } + } + + @MapperScan(basePackages = "org.mybatis.spring.filter.datasource", processPropertyPlaceHolders = false, excludeFilters = { + @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = AnnoTypeFilter.class) }) + public static class AnnoFilterWithProcessPlaceHolderOffConfig { + + } } diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java index 59c94c1eca..237e3d1d8d 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -18,6 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.util.regex.PatternSyntaxException; + import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -138,6 +140,14 @@ void warpedClassNotFoundException() { closeContext(); } + @Test + void processPropertyPlaceHoldersSwitchTest() { + // if processPropertyPlaceHolders turn off regex compile will fail + assertThrows(PatternSyntaxException.class, + () -> startContext("org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml")); + closeContext(); + } + private void startContext(String config) { applicationContext = new ClassPathXmlApplicationContext(config); applicationContext.refresh(); diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml new file mode 100644 index 0000000000..71e28999b0 --- /dev/null +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/default.properties b/src/test/java/org/mybatis/spring/filter/xml/default.properties index 69057dc48e..9c6582656d 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/default.properties +++ b/src/test/java/org/mybatis/spring/filter/xml/default.properties @@ -15,4 +15,5 @@ # filter.custom=org.mybatis.spring.filter.customfilter.CustomTypeFilter -filter.aspectj=*..CommonDataSourceMapper \ No newline at end of file +filter.aspectj=*..CommonDataSourceMapper +filter.regex=org\.mybatis\.spring\.filter\.datasource\.datasource1\..* \ No newline at end of file From c6a487480676a5a01e71c7761b7b1538915a9f8d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 16:15:06 +0000 Subject: [PATCH 566/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 63b7d36020..705a16acd4 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 5.0.2 org.mybatis.spring - 5.9.3 + 5.10.0 1684514485 From b7f09eb2b89830f391995ee7040b2486cc3e2644 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 21:51:53 +0000 Subject: [PATCH 567/933] Update dependency com.mockrunner:mockrunner-core to v2.0.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 63b7d36020..45ccfaabb4 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ com.mockrunner mockrunner-core - 2.0.6 + 2.0.7 test From 0eda0e2ac633521f5bd1ff8ed3bcb1d427ae45bb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 21:51:57 +0000 Subject: [PATCH 568/933] Update dependency com.mockrunner:mockrunner-ejb to v2.0.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 63b7d36020..e85b99f84c 100644 --- a/pom.xml +++ b/pom.xml @@ -278,7 +278,7 @@ com.mockrunner mockrunner-ejb - 2.0.6 + 2.0.7 test From 5ba168205dd43fd215cab926f28f583783971f5a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 01:44:48 +0000 Subject: [PATCH 569/933] Update dependency com.mockrunner:mockrunner-jdbc to v2.0.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 63b7d36020..da854b6e08 100644 --- a/pom.xml +++ b/pom.xml @@ -294,7 +294,7 @@ com.mockrunner mockrunner-jdbc - 2.0.6 + 2.0.7 test From b4607b738c5a76bbd216fdd8aa27dee4f36c5732 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 3 Aug 2023 11:41:31 +0000 Subject: [PATCH 570/933] Update dependency maven to v3.9.4 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 6d3a56651d..ac184013fc 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 07628b846c198c5dde947b782c6de3f937e3b1ae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 23:07:52 +0000 Subject: [PATCH 571/933] Update dependency net.bytebuddy:byte-buddy to v1.14.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4aed544dab..5f77e87648 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ net.bytebuddy byte-buddy - 1.14.5 + 1.14.6 test From 957e12b85df744cda73d9ef1a147480ed1b000df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 23:07:56 +0000 Subject: [PATCH 572/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4aed544dab..d905a7e50d 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ net.bytebuddy byte-buddy-agent - 1.14.5 + 1.14.6 test From a5762c4236463d4765ff3a82c2e5743edcd76fb5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:27:49 +0000 Subject: [PATCH 573/933] Update dependency org.mockito:mockito-core to v5.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f5ace7699e..079d9411d0 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,7 @@ org.mockito mockito-core - 5.4.0 + 5.5.0 test From c8be6843cab282792b20729bae43126a4b9cfe8f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 19:14:22 +0000 Subject: [PATCH 574/933] Update spring batch to v5.0.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f5ace7699e..6a22dbb018 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 3.5.13 6.0.11 - 5.0.2 + 5.0.3 org.mybatis.spring 5.10.0 From f4f0ff16e08232434c91d5aa6118872e0ad80485 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 01:37:56 +0000 Subject: [PATCH 575/933] Update dependency net.bytebuddy:byte-buddy to v1.14.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cce47bb7f7..dfff277c8d 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ net.bytebuddy byte-buddy - 1.14.6 + 1.14.7 test From a375349e540f7db677850b19b3955f1bf02ecada Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 01:38:00 +0000 Subject: [PATCH 576/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cce47bb7f7..5603d575eb 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ net.bytebuddy byte-buddy-agent - 1.14.6 + 1.14.7 test From 2fbbdb9224822922e338f7a5ea4fef235337e12a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 3 Sep 2023 18:37:59 +0000 Subject: [PATCH 577/933] Update dependency org.slf4j:slf4j-simple to v2.0.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3757952b6c..28cb5362e6 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ org.slf4j slf4j-simple - 2.0.7 + 2.0.9 test From 3aeeeb56a51734c49b7bda4cc134afdfdeae61eb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:48:13 +0000 Subject: [PATCH 578/933] Update actions/checkout action to v4 --- .github/workflows/ci.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dce307ae9a..50b3d508c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 - name: Set up JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index ac387747b0..a7ae1a8902 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -25,7 +25,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 - name: Set up JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index eda5f33114..3265674054 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -26,7 +26,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 008954a7f3..f98fbaa737 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -26,7 +26,7 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 - name: Set up JDK uses: actions/setup-java@v3 with: From 881df32fa4522078b5107f56b650124861392222 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 09:26:00 +0000 Subject: [PATCH 579/933] Update spring core to v6.0.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28cb5362e6..9ecca0ddd4 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.11 + 6.0.12 5.0.3 org.mybatis.spring From 46ef4c34a083a74491a1bfcedf944331429ea02b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:15:01 +0000 Subject: [PATCH 580/933] Update dependency net.bytebuddy:byte-buddy to v1.14.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28cb5362e6..3f87736771 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ net.bytebuddy byte-buddy - 1.14.7 + 1.14.8 test From d2af28c5b47591782a1b88717bc9d6804b6bab0d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:15:06 +0000 Subject: [PATCH 581/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28cb5362e6..6e5823d0ff 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ net.bytebuddy byte-buddy-agent - 1.14.7 + 1.14.8 test From d4b00fcd6113cbe057c53e1d34cc4e522e90a1c8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 19:34:03 +0000 Subject: [PATCH 582/933] Update actions/checkout digest to 8ade135 --- .github/workflows/ci.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 50b3d508c7..50327c2fcc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 - name: Set up JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index a7ae1a8902..e9013c47ca 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -25,7 +25,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 - name: Set up JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 3265674054..6c1ce41476 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -26,7 +26,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index f98fbaa737..8b1b444bba 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -26,7 +26,7 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 - name: Set up JDK uses: actions/setup-java@v3 with: From 7f48df6d3f20fbeb2c8b3df34eeb797f90483a25 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:10:04 +0000 Subject: [PATCH 583/933] Update dependency org.mybatis:mybatis-parent to v39 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a31e5bf31e..3cf807cfa7 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 38 + 39 From 7d9928b129610a245301abb075c185955996fb61 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:05:58 +0000 Subject: [PATCH 584/933] Update dependency maven to v3.9.5 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ac184013fc..eacdc9ed17 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 8054b095e1fc7881c7bb8d88704aabad7526e1ba Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:19:30 +0000 Subject: [PATCH 585/933] Update dependency org.mockito:mockito-core to v5.6.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3cf807cfa7..1467f8e633 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,7 @@ org.mockito mockito-core - 5.5.0 + 5.6.0 test From 37eac4baa8a158ec464e20a4e06c60475e3ed7f0 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 8 Oct 2023 16:22:47 -0400 Subject: [PATCH 586/933] [GHA] Fix checkout and update jdks --- .github/workflows/ci.yaml | 4 ++-- .github/workflows/coveralls.yaml | 4 ++-- .github/workflows/sonar.yaml | 4 ++-- .github/workflows/sonatype.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 50327c2fcc..14ed4e2d7c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,14 +26,14 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - java: [17, 20, 21-ea] + java: [17, 21] distribution: ['zulu'] fail-fast: false max-parallel: 5 name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index e9013c47ca..0413b2c8d0 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -25,11 +25,11 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: zulu - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 6c1ce41476..7188289209 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -26,14 +26,14 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 + - uses: actions/checkout@v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: zulu - name: Analyze with SonarCloud run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 8b1b444bba..d579dae246 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -26,11 +26,11 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: zulu - name: Deploy to Sonatype run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true From 27d118d3620cdc6ab149a0baf10c8c547c818e08 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:51:17 +0000 Subject: [PATCH 587/933] Update dependency net.bytebuddy:byte-buddy to v1.14.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1467f8e633..5f9ea730b0 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ net.bytebuddy byte-buddy - 1.14.8 + 1.14.9 test From 301fb324b1b0277efb1070cb6d9ad238a832ae8d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:51:21 +0000 Subject: [PATCH 588/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1467f8e633..59097c07fd 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ net.bytebuddy byte-buddy-agent - 1.14.8 + 1.14.9 test From 87fb1b73e0347e6d1ec7e426a2ba7a443d508e4f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:46:43 +0000 Subject: [PATCH 589/933] Update spring core to v6.0.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b9af45be9..73be746329 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 3.5.13 - 6.0.12 + 6.0.13 5.0.3 org.mybatis.spring From a781e865356dc4e7dbdf437aa5927356dcca96b0 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 23 Oct 2023 20:22:39 +0900 Subject: [PATCH 590/933] Corrected to set bean class instead of bean class name to factoryBeanObjectType of BeanDefinition attribute. Fixes gh-855 * Related with gh-494 * Related with spring-projects/spring-framework#29799 --- .../mybatis/spring/mapper/ClassPathMapperScanner.java | 10 +++++----- .../spring/mapper/MapperScannerConfigurerTest.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 626cba9985..fab1c66ac5 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -262,8 +262,12 @@ private void processBeanDefinitions(Set beanDefinitions) { // but, the actual class of the bean is MapperFactoryBean definition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName); // issue #59 try { + Class beanClass = Resources.classForName(beanClassName); + // Attribute for MockitoPostProcessor + // https://github.com/mybatis/spring-boot-starter/issues/475 + definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClass); // for spring-native - definition.getPropertyValues().add("mapperInterface", Resources.classForName(beanClassName)); + definition.getPropertyValues().add("mapperInterface", beanClass); } catch (ClassNotFoundException ignore) { // ignore } @@ -272,10 +276,6 @@ private void processBeanDefinitions(Set beanDefinitions) { definition.getPropertyValues().add("addToConfig", this.addToConfig); - // Attribute for MockitoPostProcessor - // https://github.com/mybatis/spring-boot-starter/issues/475 - definition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, beanClassName); - boolean explicitFactoryUsed = false; if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) { definition.getPropertyValues().add("sqlSessionFactory", diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index 0dc0854393..3a9a3f16f9 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -399,7 +399,7 @@ void testMapperBeanAttribute() { startContext(); assertThat(applicationContext.getBeanDefinition("annotatedMapper") - .getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class.getName()); + .getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class); } private void setupSqlSessionFactory(String name) { From ad1e61e34061876bdaecc734ca193923cafeca83 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Tue, 31 Oct 2023 09:28:12 +0900 Subject: [PATCH 591/933] Support JDK 22 on CI Fixes gh-867 --- .github/workflows/ci.yaml | 11 +++++++++-- pom.xml | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 14ed4e2d7c..fd0b334d10 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - java: [17, 21] + java: [17, 21, 22] distribution: ['zulu'] fail-fast: false max-parallel: 5 @@ -34,10 +34,17 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK + - name: Set JDK from jdk.java.net + uses: oracle-actions/setup-java@v1 + with: + website: jdk.java.net + release: ${{ matrix.java }} + if: ${{ matrix.java != '17' }} + - name: Set up older JDK uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} + if: ${{ matrix.java == '17' }} - name: Test with Maven run: ./mvnw test -B -D"license.skip=true" diff --git a/pom.xml b/pom.xml index 73be746329..9ba69852fb 100644 --- a/pom.xml +++ b/pom.xml @@ -119,8 +119,8 @@ 1684514485 - - 0.8.9 + + 0.8.11 true From 08004f22009a409b23415dd485dc5c2ba7a0fbac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 07:46:34 +0000 Subject: [PATCH 592/933] Update dependency org.mybatis:mybatis to v3.5.14 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9ba69852fb..b043c85c32 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ 17 17 - 3.5.13 + 3.5.14 6.0.13 5.0.3 org.mybatis.spring From 97b14966e8de74b0ffd64e41b1246da9e4634fab Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:38:42 +0000 Subject: [PATCH 593/933] Update dependency org.mockito:mockito-core to v5.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b043c85c32..99638cc445 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,7 @@ org.mockito mockito-core - 5.6.0 + 5.7.0 test From 4e2a04adf13f7586e46b7384bbee615b013fc2d5 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 3 Nov 2023 09:26:12 +0900 Subject: [PATCH 594/933] Switch to temurin as JDK distribution on CI for support JDK 22 Fixes gh-867 --- .github/workflows/ci.yaml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fd0b334d10..531c9ae997 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,25 +26,18 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - java: [17, 21, 22] - distribution: ['zulu'] + java: [17, 21, 22-ea] + distribution: ['temurin'] fail-fast: false max-parallel: 5 name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Set JDK from jdk.java.net - uses: oracle-actions/setup-java@v1 - with: - website: jdk.java.net - release: ${{ matrix.java }} - if: ${{ matrix.java != '17' }} - - name: Set up older JDK + - name: Set up JDK uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - if: ${{ matrix.java == '17' }} - name: Test with Maven run: ./mvnw test -B -D"license.skip=true" From ad01f74bc1a447a3fc7e4f81c0dbc828882f5090 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:53:10 +0000 Subject: [PATCH 595/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 99638cc445..75db090ff3 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 5.0.3 org.mybatis.spring - 5.10.0 + 5.10.1 1684514485 From b2ef5140fc4581dc19af257e2a281ae010221fbd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 7 Nov 2023 08:10:49 +0000 Subject: [PATCH 596/933] Update dependency org.mybatis:mybatis-parent to v40 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75db090ff3..b4cb071a71 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 39 + 40 From f8715f6af155a350516ac1b261bcc5625f7d7451 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 8 Nov 2023 21:40:07 -0500 Subject: [PATCH 597/933] [mvn] Move gh-pages to gh-pages-scm --- .mvn/settings.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.mvn/settings.xml b/.mvn/settings.xml index 61c3da7c04..645d1f9f7d 100644 --- a/.mvn/settings.xml +++ b/.mvn/settings.xml @@ -24,8 +24,13 @@ ${env.CI_DEPLOY_USERNAME} ${env.CI_DEPLOY_PASSWORD} + - gh-pages + gh-pages-scm + + branch + gh-pages + github From 846e0db1bc69fa753a8044114691c02a2443aa70 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 8 Nov 2023 21:40:18 -0500 Subject: [PATCH 598/933] [ci] update notice --- NOTICE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOTICE b/NOTICE index 8617f29c7d..79fd4a0c7d 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ MyBatis Spring -Copyright 2010-2013 +Copyright 2010-2023 This product includes software developed by The MyBatis Team (http://www.mybatis.org/). From 44bc2068ca6045cabcfad26847c47e2e3bcab4a4 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 8 Nov 2023 21:40:35 -0500 Subject: [PATCH 599/933] [pom] Update site distribution --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b4cb071a71..ccd0b2b761 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ http://github.com/mybatis/spring - scm:git:ssh://github.com/mybatis/spring.git + scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git HEAD @@ -92,9 +92,9 @@ - gh-pages + gh-pages-scm Mybatis GitHub Pages - git:ssh://git@github.com/mybatis/spring.git?gh-pages# + scm:git:ssh://git@github.com/mybatis/spring.git From c2d9115bab8b6f6ae296a843b1557e612978331e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 9 Nov 2023 18:24:27 -0500 Subject: [PATCH 600/933] [pom] Sortpom --- pom.xml | 146 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/pom.xml b/pom.xml index ccd0b2b761..2cd823925f 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.mybatis mybatis-parent 40 - + mybatis-spring @@ -77,10 +77,10 @@ - http://github.com/mybatis/spring scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git HEAD + http://github.com/mybatis/spring GitHub Issue Management @@ -212,10 +212,10 @@ ${spring-batch.version} test - - junit - junit - + + junit + junit + @@ -331,7 +331,72 @@ + + + sonatype-oss-snapshots + Sonatype OSS Snapshots Repository + https://oss.sonatype.org/content/repositories/snapshots + + + + false + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + + + false + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + + + + + + false + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + + + false + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + + + + + + META-INF + ${project.basedir} + + LICENSE + NOTICE + + + + ${project.basedir}/src/main/resources + + + + + ${project.build.testSourceDirectory} + + **/*.java + + + org.apache.maven.plugins @@ -356,10 +421,10 @@ filter-site - pre-site copy-resources + pre-site ${project.build.directory}/site-src @@ -378,7 +443,7 @@ en,es,zh_CN,ja,ko ${project.build.directory}/site-src - + @@ -394,70 +459,5 @@ - - - - ${project.basedir} - META-INF - - LICENSE - NOTICE - - - - ${project.basedir}/src/main/resources - - - - - ${project.build.testSourceDirectory} - - **/*.java - - - - - - - sonatype-oss-snapshots - Sonatype OSS Snapshots Repository - https://oss.sonatype.org/content/repositories/snapshots - - - spring-snapshot - Spring Snapshots - https://repo.spring.io/snapshot - - false - - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - false - - - - - - - spring-snapshot - Spring Snapshots - https://repo.spring.io/snapshot - - false - - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - false - - - From 08811d43138e9240f7582bc394aa7bdd6928e472 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 9 Nov 2023 18:24:53 -0500 Subject: [PATCH 601/933] [mvn] Update maven wrapper --- .mvn/maven.config | 1 + .mvn/wrapper/MavenWrapperDownloader.java | 2 +- .mvn/wrapper/maven-wrapper.properties | 2 +- mvnw | 2 +- mvnw.cmd | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.mvn/maven.config b/.mvn/maven.config index 956533e67c..afdcfab795 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1 +1,2 @@ -Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 +-Daether.connector.smartChecksums=false diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index 84d1e60d8d..f57fd86fbf 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index eacdc9ed17..39a584eb21 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/mvnw b/mvnw index 8d937f4c14..66df285428 100755 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/mvnw.cmd b/mvnw.cmd index c4586b564e..95ba6f54ac 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -7,7 +7,7 @@ @REM "License"); you may not use this file except in compliance @REM with the License. You may obtain a copy of the License at @REM -@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM https://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, @REM software distributed under the License is distributed on an From 2454d55a2adb8ab32f3deb0f092355aac2265518 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 9 Nov 2023 18:27:00 -0500 Subject: [PATCH 602/933] [GHA] Update actions --- .github/workflows/ci.yaml | 28 +++++----------------------- .github/workflows/coveralls.yaml | 24 +++--------------------- .github/workflows/sonar.yaml | 18 +----------------- .github/workflows/sonatype.yaml | 18 +----------------- 4 files changed, 10 insertions(+), 78 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 531c9ae997..06b1c2163e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,43 +1,25 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - name: Java CI -on: - push: - pull_request: +on: [workflow_dispatch, push, pull_request] jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [ubuntu-latest, macos-latest, windows-latest] java: [17, 21, 22-ea] distribution: ['temurin'] fail-fast: false - max-parallel: 5 + max-parallel: 4 name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Set up JDK + - name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }} uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - name: Test with Maven - run: ./mvnw test -B -D"license.skip=true" + run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 0413b2c8d0..03df1ede11 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -1,24 +1,6 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - name: Coveralls -on: - push: - pull_request: +on: [push, pull_request] jobs: build: @@ -33,12 +15,12 @@ jobs: distribution: zulu - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER + run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} - name: Report Coverage to Coveralls for General Push if: github.event_name == 'push' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github + run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 7188289209..2c986b2f84 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,19 +1,3 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - name: SonarCloud on: @@ -36,7 +20,7 @@ jobs: java-version: 21 distribution: zulu - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true + run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index d579dae246..46800b489e 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -1,19 +1,3 @@ -# -# Copyright 2010-2022 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - name: Sonatype on: @@ -33,7 +17,7 @@ jobs: java-version: 21 distribution: zulu - name: Deploy to Sonatype - run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true + run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} From 296b7ab5c80a48ab3f7308d182b3913297ee040e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 12 Nov 2023 01:13:21 -0500 Subject: [PATCH 603/933] [derby] Restore java 11 and adjust derby to change per jdk version --- .github/workflows/ci.yaml | 2 +- pom.xml | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06b1c2163e..b14431cd50 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - java: [17, 21, 22-ea] + java: [11, 17, 21, 22-ea] distribution: ['temurin'] fail-fast: false max-parallel: 4 diff --git a/pom.xml b/pom.xml index 2cd823925f..25ceaed902 100644 --- a/pom.xml +++ b/pom.xml @@ -109,6 +109,7 @@ 17 17 + 10.17.1.0 3.5.14 6.0.13 5.0.3 @@ -167,7 +168,7 @@ org.apache.derby derby - 10.16.1.1 + ${derby.version} test @@ -460,4 +461,34 @@ + + + + pre16 + + (,16) + + + 10.15.2.0 + + + + 17 + + [17,) + + + 10.16.1.1 + + + + 19 + + [19,) + + + 10.17.1.0 + + + From 2141d75f92ec9bb0f3aa09eef58b93b2a7ac4181 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 12 Nov 2023 01:13:30 -0500 Subject: [PATCH 604/933] [pom] Remove jacoco override as no longer needed --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index 25ceaed902..62b011b77c 100644 --- a/pom.xml +++ b/pom.xml @@ -120,9 +120,6 @@ 1684514485 - - 0.8.11 - true From b5fcb5e6d625f990275fd8c826d8814252331075 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 12 Nov 2023 01:18:25 -0500 Subject: [PATCH 605/933] [GHA] Drop jdk 11 again as this is spring 6 left profile as that needs copied to javax support. Javax support can run 11 with derby this way. --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b14431cd50..06b1c2163e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - java: [11, 17, 21, 22-ea] + java: [17, 21, 22-ea] distribution: ['temurin'] fail-fast: false max-parallel: 4 From a66132df6a54562315e911685a4648299fa568be Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:42:28 +0000 Subject: [PATCH 606/933] Update dependency org.jboss.byteman:byteman-bmunit to v4.0.22 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 62b011b77c..a39fbf5ab0 100644 --- a/pom.xml +++ b/pom.xml @@ -179,7 +179,7 @@ org.jboss.byteman byteman-bmunit - 4.0.21 + 4.0.22 test From 827940b1dedf314e2e5de569b2a5a4738a9ceddb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:42:33 +0000 Subject: [PATCH 607/933] Update spring core to v6.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 62b011b77c..fa0401b676 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 10.17.1.0 3.5.14 - 6.0.13 + 6.1.0 5.0.3 org.mybatis.spring From a0af9840f398cacf864e164d0d365a8379921492 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Mon, 20 Nov 2023 19:32:36 +0900 Subject: [PATCH 608/933] [maven-release-plugin] prepare release mybatis-spring-3.0.3 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index dc135150bb..93670a43fb 100644 --- a/pom.xml +++ b/pom.xml @@ -23,11 +23,11 @@ org.mybatis mybatis-parent 40 - + mybatis-spring - 3.0.3-SNAPSHOT + 3.0.3 jar mybatis-spring @@ -79,7 +79,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.3 http://github.com/mybatis/spring @@ -118,7 +118,7 @@ 5.10.1 - 1684514485 + 1700476303 true From 8d8e362446001dcf3480d63e4b157eab9b49599a Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Mon, 20 Nov 2023 19:32:41 +0900 Subject: [PATCH 609/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 93670a43fb..9111a3b0cc 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 3.0.3 + 3.0.4-SNAPSHOT jar mybatis-spring @@ -79,7 +79,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.3 + HEAD http://github.com/mybatis/spring @@ -118,7 +118,7 @@ 5.10.1 - 1700476303 + 1700476361 true From 8abde7855ef80bd4a71f94d791cc976b8992ef6d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:32:53 +0000 Subject: [PATCH 610/933] Update dependency net.bytebuddy:byte-buddy to v1.14.10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9111a3b0cc..dfe32d237e 100644 --- a/pom.xml +++ b/pom.xml @@ -318,7 +318,7 @@ net.bytebuddy byte-buddy - 1.14.9 + 1.14.10 test From ff050aaee9b014062fd8b85cfe86919ef7d22a3f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:32:57 +0000 Subject: [PATCH 611/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9111a3b0cc..368f6b5e87 100644 --- a/pom.xml +++ b/pom.xml @@ -324,7 +324,7 @@ net.bytebuddy byte-buddy-agent - 1.14.9 + 1.14.10 test From 64286838acc5495278dac0d917eb2c7e0ad7e022 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 18:26:30 +0000 Subject: [PATCH 612/933] Update spring batch to v5.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c56ac7c9f..9a287b8a9f 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.14 6.1.0 - 5.0.3 + 5.1.0 org.mybatis.spring 5.10.1 From f8162fe252a1be4e681e292ef9bbc58de49fcb24 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Fri, 24 Nov 2023 05:37:30 +0900 Subject: [PATCH 613/933] Adjust MyBatisSystemException to Spring 6 Since Spring 6, `org.springframework.core.NestedRuntimeException` no longer includes the message of the wrapped exception. https://github.com/spring-projects/spring-framework/issues/25162 Should fix gh-887 --- .../org/mybatis/spring/MyBatisExceptionTranslator.java | 8 ++++++-- .../java/org/mybatis/spring/MyBatisSystemException.java | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index 2fdc030060..f7a8bb5825 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,8 +82,12 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { if (e instanceof PersistenceException) { // Batch exceptions come inside another PersistenceException // recursion has a risk of infinite loop so better make another if + String msg = e.getMessage(); if (e.getCause() instanceof PersistenceException) { e = (PersistenceException) e.getCause(); + if (msg == null) { + msg = e.getMessage(); + } } if (e.getCause() instanceof SQLException) { this.initExceptionTranslator(); @@ -94,7 +98,7 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { } else if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } - return new MyBatisSystemException(e); + return new MyBatisSystemException(msg, e); } return null; } diff --git a/src/main/java/org/mybatis/spring/MyBatisSystemException.java b/src/main/java/org/mybatis/spring/MyBatisSystemException.java index 566cf9ba62..b794708de4 100644 --- a/src/main/java/org/mybatis/spring/MyBatisSystemException.java +++ b/src/main/java/org/mybatis/spring/MyBatisSystemException.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ public class MyBatisSystemException extends UncategorizedDataAccessException { private static final long serialVersionUID = -5284728621670758939L; - public MyBatisSystemException(Throwable cause) { - super(null, cause); + public MyBatisSystemException(String msg, Throwable cause) { + super(msg, cause); } } From 6427eb0879bc35c11bbc873e76028cce708db188 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 05:04:55 +0000 Subject: [PATCH 614/933] Update spring core to v6.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a287b8a9f..68e09cff56 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 10.17.1.0 3.5.14 - 6.1.0 + 6.1.1 5.1.0 org.mybatis.spring From f53cfce9298bdce7e3b07ebcfa049cd5b4eb85b2 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 25 Nov 2023 19:34:16 +0900 Subject: [PATCH 615/933] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00df4dc767..1108087d39 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Supported Versions ------------------ - master - Support for Spring 6 and Spring Batch 5 -- 2.1.x - Enhance and maintenance for Spring 5 and Spring Batch 4 +- 2.1.x - Maintenance for Spring 5 and Spring Batch 4 Essentials ---------- From 2234e483b17eee526761a3e1376b8323e6af5714 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 26 Nov 2023 08:47:04 +0900 Subject: [PATCH 616/933] Add tests for MyBatisExceptionTranslator behavior --- .../MyBatisExceptionTranslatorTest.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java diff --git a/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java b/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java new file mode 100644 index 0000000000..62db9e51cf --- /dev/null +++ b/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.spring; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +import com.mockrunner.mock.jdbc.MockDataSource; + +import java.sql.SQLException; + +import org.apache.ibatis.exceptions.PersistenceException; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.UncategorizedSQLException; +import org.springframework.jdbc.support.SQLExceptionTranslator; + +class MyBatisExceptionTranslatorTest { + + @Test + void shouldNonPersistenceExceptionBeTranslatedToNull() { + MockDataSource mockDataSource = new MockDataSource(); + MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(mockDataSource, false); + DataAccessException e = translator.translateExceptionIfPossible(new RuntimeException()); + assertNull(e); + } + + @Test + void shouldSqlExceptionBeTranslatedToUncategorizedSqlException() { + String msg = "Error!"; + SQLException sqlException = new SQLException(msg); + SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + DataAccessException e = translator.translateExceptionIfPossible(new PersistenceException(sqlException)); + assertTrue(e instanceof UncategorizedSQLException); + Mockito.verify(sqlExceptionTranslator, times(1)).translate(SQLException.class.getName() + ": " + msg + "\n", null, + sqlException); + } + + @Test + void shouldPersistenceExceptionBeTranslatedToMyBatisSystemException() { + String msg = "Error!"; + SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + DataAccessException e = translator.translateExceptionIfPossible(new PersistenceException(msg)); + assertTrue(e instanceof MyBatisSystemException); + assertEquals(msg, e.getMessage()); + } + + @Test + void shouldNestedPersistenceExceptionReportsMsgOfParentException() { + String msg = "Error!"; + SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + DataAccessException e = translator + .translateExceptionIfPossible(new PersistenceException(msg, new PersistenceException("Inner error!"))); + assertTrue(e instanceof MyBatisSystemException); + assertEquals(msg, e.getMessage()); + } + + @Test + void shouldNestedPersistenceExceptionReportsMsgOfChildExceptionIfParentsMsgIsNull() { + String msg = "Error!"; + SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + DataAccessException e = translator + .translateExceptionIfPossible(new PersistenceException(null, new PersistenceException(msg))); + assertTrue(e instanceof MyBatisSystemException); + assertEquals(msg, e.getMessage()); + } + +} From 2afe7e441afeec2022ee18bcd914cadb14c03692 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 26 Nov 2023 08:51:19 +0900 Subject: [PATCH 617/933] Restore the original constructor with `@Deprecated` --- .../org/mybatis/spring/MyBatisSystemException.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisSystemException.java b/src/main/java/org/mybatis/spring/MyBatisSystemException.java index b794708de4..42c47e378f 100644 --- a/src/main/java/org/mybatis/spring/MyBatisSystemException.java +++ b/src/main/java/org/mybatis/spring/MyBatisSystemException.java @@ -18,11 +18,9 @@ import org.springframework.dao.UncategorizedDataAccessException; /** - * MyBatis specific subclass of {@code UncategorizedDataAccessException}, for MyBatis system errors that do not match - * any concrete {@code org.springframework.dao} exceptions. + * MyBatis specific subclass of {@code UncategorizedDataAccessException}, for MyBatis system errors that do not match any concrete {@code org.springframework.dao} exceptions. *

    - * In MyBatis 3 {@code org.apache.ibatis.exceptions.PersistenceException} is a {@code RuntimeException}, but using this - * wrapper class to bring everything under a single hierarchy will be easier for client code to handle. + * In MyBatis 3 {@code org.apache.ibatis.exceptions.PersistenceException} is a {@code RuntimeException}, but using this wrapper class to bring everything under a single hierarchy will be easier for client code to handle. * * @author Hunter Presnall */ @@ -31,6 +29,11 @@ public class MyBatisSystemException extends UncategorizedDataAccessException { private static final long serialVersionUID = -5284728621670758939L; + @Deprecated(since = "3.0.4", forRemoval = true) + public MyBatisSystemException(Throwable cause) { + this(cause.getMessage(), cause); + } + public MyBatisSystemException(String msg, Throwable cause) { super(msg, cause); } From d3490694e8b465375cddebacb828463b975911e7 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 26 Nov 2023 09:10:17 +0900 Subject: [PATCH 618/933] Revert unintentional format change --- .../java/org/mybatis/spring/MyBatisSystemException.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisSystemException.java b/src/main/java/org/mybatis/spring/MyBatisSystemException.java index 42c47e378f..a40d25c4a6 100644 --- a/src/main/java/org/mybatis/spring/MyBatisSystemException.java +++ b/src/main/java/org/mybatis/spring/MyBatisSystemException.java @@ -18,9 +18,11 @@ import org.springframework.dao.UncategorizedDataAccessException; /** - * MyBatis specific subclass of {@code UncategorizedDataAccessException}, for MyBatis system errors that do not match any concrete {@code org.springframework.dao} exceptions. + * MyBatis specific subclass of {@code UncategorizedDataAccessException}, for MyBatis system errors that do not match + * any concrete {@code org.springframework.dao} exceptions. *

    - * In MyBatis 3 {@code org.apache.ibatis.exceptions.PersistenceException} is a {@code RuntimeException}, but using this wrapper class to bring everything under a single hierarchy will be easier for client code to handle. + * In MyBatis 3 {@code org.apache.ibatis.exceptions.PersistenceException} is a {@code RuntimeException}, but using this + * wrapper class to bring everything under a single hierarchy will be easier for client code to handle. * * @author Hunter Presnall */ From 7a3059211686f202388cbda62f2082922a914e43 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:28:13 +0000 Subject: [PATCH 619/933] Update actions/setup-java action to v4 --- .github/workflows/ci.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06b1c2163e..d1bb42b90a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }} - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 03df1ede11..a898e37933 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 21 distribution: zulu diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 2c986b2f84..4cab3d94a9 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -15,7 +15,7 @@ jobs: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 21 distribution: zulu diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 46800b489e..72086bc1d7 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 21 distribution: zulu From 217c6a4e70863397d337bef4d553004faca5ecc0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:00:28 +0000 Subject: [PATCH 620/933] Update dependency maven to v3.9.6 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 39a584eb21..2f9352f713 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 8929f3f17dab347c906249115dccccc8ad25fb09 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:37:36 +0000 Subject: [PATCH 621/933] Update dependency org.mybatis:mybatis-parent to v41 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68e09cff56..b924a9dfa5 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 40 + 41 From f19dc645a95ca6f722b405b58fdf47e91d70b375 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:47:56 +0000 Subject: [PATCH 622/933] Update dependency org.mockito:mockito-core to v5.8.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68e09cff56..98c32b3a1f 100644 --- a/pom.xml +++ b/pom.xml @@ -234,7 +234,7 @@ org.mockito mockito-core - 5.7.0 + 5.8.0 test From 2f5a5c1a6d52a8662733777dff0daa20694ca647 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:56:32 +0000 Subject: [PATCH 623/933] Update spring core to v6.1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b845e03924..fe0eefb0bf 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 10.17.1.0 3.5.14 - 6.1.1 + 6.1.2 5.1.0 org.mybatis.spring From 36a7084f3e35d6b7f05733e3de076a1e5fefd65d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 06:37:19 +0000 Subject: [PATCH 624/933] Update dependency org.mybatis:mybatis to v3.5.15 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fe0eefb0bf..f0ce436de0 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 17 10.17.1.0 - 3.5.14 + 3.5.15 6.1.2 5.1.0 org.mybatis.spring From 65e2cbaa469602685dce211de69b8fb1aa4440ef Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:17:52 +0000 Subject: [PATCH 625/933] Update dependency net.bytebuddy:byte-buddy to v1.14.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0ce436de0..ab9542cf39 100644 --- a/pom.xml +++ b/pom.xml @@ -318,7 +318,7 @@ net.bytebuddy byte-buddy - 1.14.10 + 1.14.11 test From 2a47b71fd30fe44b0d15a0730789bb1e8538e1b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:17:55 +0000 Subject: [PATCH 626/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0ce436de0..459f5dc1e7 100644 --- a/pom.xml +++ b/pom.xml @@ -324,7 +324,7 @@ net.bytebuddy byte-buddy-agent - 1.14.10 + 1.14.11 test From c0da6181593043e75903c67f1a303d2083fdc213 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 17 Dec 2023 23:16:28 -0500 Subject: [PATCH 627/933] [site] Add site for GHA distributions --- .github/workflows/site.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/site.yaml diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml new file mode 100644 index 0000000000..f3ca17bff7 --- /dev/null +++ b/.github/workflows/site.yaml @@ -0,0 +1,34 @@ +name: Site + +on: + push: + branches: + - site + +jobs: + build: + if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: zulu + - uses: webfactory/ssh-agent@master + with: + ssh-private-key: ${{ secrets.DEPLOY_KEY }} + - name: Build site + run: ./mvnw site site:stage -DskipTests -B -V --no-transfer-progress -Dlicense.skip=true + env: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy Site to gh-pages + uses: JamesIves/github-pages-deploy-action@v4.4.3 + with: + ssh-key: true + branch: gh-pages + folder: target/staging + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d4f59f8954a875f9e55720286e022ff812b6b1cc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 27 Dec 2023 02:24:58 +0000 Subject: [PATCH 628/933] Update JamesIves/github-pages-deploy-action action to v4.5.0 --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index f3ca17bff7..cefbc68d15 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -25,7 +25,7 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@v4.4.3 + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: ssh-key: true branch: gh-pages From 20266e9889e903fc042ce270f8f04cf706309191 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 27 Dec 2023 02:25:01 +0000 Subject: [PATCH 629/933] Update actions/setup-java action to v4 --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index f3ca17bff7..dc1644d54c 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 21 distribution: zulu From 35b3d9d5b5b929cb80a3ffec5647773e51c98ab2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 29 Dec 2023 01:39:47 +0000 Subject: [PATCH 630/933] Update dependency org.slf4j:slf4j-simple to v2.0.10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b3d71a1495..330f8d3f59 100644 --- a/pom.xml +++ b/pom.xml @@ -227,7 +227,7 @@ org.slf4j slf4j-simple - 2.0.9 + 2.0.10 test From ff4339ebf9c7db8321e95b58242f2a38cc0b1ee5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 31 Dec 2023 19:16:57 +0000 Subject: [PATCH 631/933] Update dependency org.assertj:assertj-core to v3.25.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 330f8d3f59..29b0b52e8f 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.assertj assertj-core - 3.24.2 + 3.25.0 test From 1a5468ebe1e29e0c9ba2851a4effb00460801e1c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 00:34:30 +0000 Subject: [PATCH 632/933] Update dependency org.assertj:assertj-core to v3.25.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 29b0b52e8f..c6e9503600 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.assertj assertj-core - 3.25.0 + 3.25.1 test From 824c3477cfa01e6e33ffc9f313cc5fa2f1c97245 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:47:38 +0000 Subject: [PATCH 633/933] Update dependency org.slf4j:slf4j-simple to v2.0.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6e9503600..9a9879677a 100644 --- a/pom.xml +++ b/pom.xml @@ -227,7 +227,7 @@ org.slf4j slf4j-simple - 2.0.10 + 2.0.11 test From bced6b200f94d37a4d0c76bda2e9922894484e10 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 12:36:42 +0000 Subject: [PATCH 634/933] Update spring core to v6.1.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a9879677a..8b9377f6a4 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 10.17.1.0 3.5.15 - 6.1.2 + 6.1.3 5.1.0 org.mybatis.spring From ca11c7544ff48b3ed99c7f30beb66bed9f6a32c6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Jan 2024 15:06:32 +0000 Subject: [PATCH 635/933] Update dependency org.mockito:mockito-core to v5.9.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b9377f6a4..1fd726ac59 100644 --- a/pom.xml +++ b/pom.xml @@ -234,7 +234,7 @@ org.mockito mockito-core - 5.8.0 + 5.9.0 test From ec4164818984340795db5ccc11d235c2ec9ce9fb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:28:41 +0000 Subject: [PATCH 636/933] Update dependency org.assertj:assertj-core to v3.25.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1fd726ac59..4b8ad4bd25 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.assertj assertj-core - 3.25.1 + 3.25.2 test From 8bc4211320c28fbf4260430bc606ab72e1e604df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:03:18 +0000 Subject: [PATCH 637/933] Update dependency org.mockito:mockito-core to v5.10.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1fd726ac59..2e4af9bdf4 100644 --- a/pom.xml +++ b/pom.xml @@ -234,7 +234,7 @@ org.mockito mockito-core - 5.9.0 + 5.10.0 test From ae2e3f38dc4dc2ed60631562a48898129701a19f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 21:32:27 +0000 Subject: [PATCH 638/933] Update dependency org.mybatis:mybatis-parent to v42 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6a0090bbb1..8e8878f715 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.mybatis mybatis-parent - 41 + 42 From 1db79cccd872f4657dce60ddcf4b78f116e6852c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:20:24 +0000 Subject: [PATCH 639/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8e8878f715..fa5b479955 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 5.1.0 org.mybatis.spring - 5.10.1 + 5.10.2 1700476361 From 9aeea6a5626a7ff858d142a77e65b90ed3b8aa07 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:38:19 +0000 Subject: [PATCH 640/933] Update dependency org.assertj:assertj-core to v3.25.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fa5b479955..5b16e20c25 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.assertj assertj-core - 3.25.2 + 3.25.3 test From c6b5a031ee946c4487aa255244c5070676495d7f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 01:21:34 +0000 Subject: [PATCH 641/933] Update dependency org.slf4j:slf4j-simple to v2.0.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b16e20c25..dd6f1b5e6e 100644 --- a/pom.xml +++ b/pom.xml @@ -227,7 +227,7 @@ org.slf4j slf4j-simple - 2.0.11 + 2.0.12 test From bc13f05b5b596c898f2bf3c65ffbc5991aa1ab06 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Feb 2024 14:41:59 -0500 Subject: [PATCH 642/933] Create codeql.yml --- .github/workflows/codeql.yml | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..bd854db357 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,84 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '37 14 * * 6' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + # required for all workflows + security-events: write + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + language: [ 'java-kotlin' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From 797b61daeebf13c5c80916d5458e450e883018d5 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 4 Feb 2024 14:15:02 -0500 Subject: [PATCH 643/933] [ci] Use https in license --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 57bc88a15a..7e835b2fa9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -192,7 +192,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, From 5203a00e32a0ccf5dd3c60d4da7df9d717f659e4 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 4 Feb 2024 14:15:09 -0500 Subject: [PATCH 644/933] [renovate] Update config --- renovate.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 39a2b6e9a5..5db72dd6a9 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "config:base" + "config:recommended" ] } From edb4648d4ad7e820a5f33cc548b2f1ff685701c2 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Feb 2024 14:27:48 -0500 Subject: [PATCH 645/933] [GHA] Update sonar.login to sonar.token --- .github/workflows/sonar.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 4cab3d94a9..a803d9e302 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -20,7 +20,7 @@ jobs: java-version: 21 distribution: zulu - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress + run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 7ac58f19f6011c2376eeab0a27fc8c5a16140fa1 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Feb 2024 18:06:11 -0500 Subject: [PATCH 646/933] [pom] Cleanup pom and fix urls --- pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index dd6f1b5e6e..bec26b2911 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ --> + 4.0.0 @@ -26,13 +27,13 @@ + org.mybatis mybatis-spring 3.0.4-SNAPSHOT - jar mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. - http://www.mybatis.org/spring/ + https://www.mybatis.org/spring/ @@ -80,7 +81,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git HEAD - http://github.com/mybatis/spring + https://github.com/mybatis/spring/ GitHub Issue Management From a1b320afb82bd92338a6f7490b0bafea249a6e11 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Feb 2024 18:08:48 -0500 Subject: [PATCH 647/933] [git] Update git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 001d888176..908d8660e8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ .mvn/wrapper/maven-wrapper.jar release.properties *.releaseBackup +.github/keys/ From 2afd409f71e2691549bb03738c535d961e56cac9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:01:12 +0000 Subject: [PATCH 648/933] Update spring core to v6.1.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bec26b2911..391d9461df 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.15 - 6.1.3 + 6.1.4 5.1.0 org.mybatis.spring From 6d5a081c313b92af7b0bd7b4a2f7f166053286ef Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:15:25 +0000 Subject: [PATCH 649/933] Update dependency net.bytebuddy:byte-buddy to v1.14.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bec26b2911..3632062af2 100644 --- a/pom.xml +++ b/pom.xml @@ -319,7 +319,7 @@ net.bytebuddy byte-buddy - 1.14.11 + 1.14.12 test From ec74507290155b21aeb4fba7ce046a75fd6ad9df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:15:28 +0000 Subject: [PATCH 650/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bec26b2911..efe772b533 100644 --- a/pom.xml +++ b/pom.xml @@ -325,7 +325,7 @@ net.bytebuddy byte-buddy-agent - 1.14.11 + 1.14.12 test From 41c2d5cd1a6010d853169a003637f7596af8ec4a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:47:44 +0000 Subject: [PATCH 651/933] Update spring batch to v5.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2796aa0b0..cf96bdf5cd 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ 10.17.1.0 3.5.15 6.1.4 - 5.1.0 + 5.1.1 org.mybatis.spring 5.10.2 From bde2594e9eaea73ea61891232d8d56b9aae2ec74 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:23:19 +0000 Subject: [PATCH 652/933] Update dependency org.mockito:mockito-core to v5.11.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf96bdf5cd..219430c3a5 100644 --- a/pom.xml +++ b/pom.xml @@ -235,7 +235,7 @@ org.mockito mockito-core - 5.10.0 + 5.11.0 test From 2f41efef3ed865abd584f0f7d2bcdafaf3ed65cb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:20:55 +0000 Subject: [PATCH 653/933] Update spring core to v6.1.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 219430c3a5..7b98667884 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.15 - 6.1.4 + 6.1.5 5.1.1 org.mybatis.spring From fb4b69159ff8cbaff4242347d6867a8edd123b65 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 23:31:41 +0000 Subject: [PATCH 654/933] Update dependency net.bytebuddy:byte-buddy to v1.14.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b98667884..febffc55eb 100644 --- a/pom.xml +++ b/pom.xml @@ -319,7 +319,7 @@ net.bytebuddy byte-buddy - 1.14.12 + 1.14.13 test From 7fd77174dc08384bb212dd3be681d2a17e22f093 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 23:31:45 +0000 Subject: [PATCH 655/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b98667884..2d41cc11f6 100644 --- a/pom.xml +++ b/pom.xml @@ -325,7 +325,7 @@ net.bytebuddy byte-buddy-agent - 1.14.12 + 1.14.13 test From 0b59fd7a4708c324aa12c1f59f6e645378ef1519 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:48:35 +0000 Subject: [PATCH 656/933] Update dependency org.mybatis:mybatis to v3.5.16 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 64e04f90cf..fd6005e4ec 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 17 10.17.1.0 - 3.5.15 + 3.5.16 6.1.5 5.1.1 org.mybatis.spring From fe56bf513a375bde58039af4bc227a8d2f6851b7 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 7 Apr 2024 04:10:13 +0900 Subject: [PATCH 657/933] Adjustment needed to build the site properly - Change the language : en -> default - Rename the directory zh to zh_CN --- pom.xml | 2 +- src/site/es/markdown/index.md | 2 +- src/site/ja/markdown/index.md | 2 +- src/site/ko/markdown/index.md | 2 +- src/site/markdown/index.md | 2 +- src/site/resources/{zh => zh_CN}/css/site.css | 0 src/site/{site_zh.xml => site_zh_CN.xml} | 0 src/site/{zh => zh_CN}/markdown/README.md | 0 src/site/{zh => zh_CN}/markdown/batch.md | 0 src/site/{zh => zh_CN}/markdown/boot.md | 0 src/site/{zh => zh_CN}/markdown/factorybean.md | 0 src/site/{zh => zh_CN}/markdown/getting-started.md | 0 src/site/{zh => zh_CN}/markdown/index.md | 0 src/site/{zh => zh_CN}/markdown/mappers.md | 0 src/site/{zh => zh_CN}/markdown/sample.md | 0 src/site/{zh => zh_CN}/markdown/sqlsession.md | 0 src/site/{zh => zh_CN}/markdown/transactions.md | 0 src/site/{zh => zh_CN}/markdown/using-api.md | 0 18 files changed, 5 insertions(+), 5 deletions(-) rename src/site/resources/{zh => zh_CN}/css/site.css (100%) rename src/site/{site_zh.xml => site_zh_CN.xml} (100%) rename src/site/{zh => zh_CN}/markdown/README.md (100%) rename src/site/{zh => zh_CN}/markdown/batch.md (100%) rename src/site/{zh => zh_CN}/markdown/boot.md (100%) rename src/site/{zh => zh_CN}/markdown/factorybean.md (100%) rename src/site/{zh => zh_CN}/markdown/getting-started.md (100%) rename src/site/{zh => zh_CN}/markdown/index.md (100%) rename src/site/{zh => zh_CN}/markdown/mappers.md (100%) rename src/site/{zh => zh_CN}/markdown/sample.md (100%) rename src/site/{zh => zh_CN}/markdown/sqlsession.md (100%) rename src/site/{zh => zh_CN}/markdown/transactions.md (100%) rename src/site/{zh => zh_CN}/markdown/using-api.md (100%) diff --git a/pom.xml b/pom.xml index fd6005e4ec..05ca68757e 100644 --- a/pom.xml +++ b/pom.xml @@ -440,7 +440,7 @@ org.apache.maven.plugins maven-site-plugin - en,es,zh_CN,ja,ko + default,es,zh_CN,ja,ko ${project.build.directory}/site-src diff --git a/src/site/es/markdown/index.md b/src/site/es/markdown/index.md index 52a789bfd8..25d8c9331b 100644 --- a/src/site/es/markdown/index.md +++ b/src/site/es/markdown/index.md @@ -51,7 +51,7 @@ Users can read about MyBatis-Spring in the following translations:

  • Español
  • 日本語
  • 한국어
  • -
  • 简体中文
  • +
  • 简体中文
  • Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your mother tongue documentation! diff --git a/src/site/ja/markdown/index.md b/src/site/ja/markdown/index.md index 1bd7b7408b..74d84347e5 100644 --- a/src/site/ja/markdown/index.md +++ b/src/site/ja/markdown/index.md @@ -48,7 +48,7 @@ MyBatis-Spring は以下の言語の翻訳を用意しています。
  • Español
  • 日本語
  • 한국어
  • -
  • 简体中文
  • +
  • 简体中文
  • 母国語でMyBatis Springのリファレンスを読んでみませんか? ぜひドキュメントを母国語へ翻訳するためのIssue(パッチ)を作成してください! diff --git a/src/site/ko/markdown/index.md b/src/site/ko/markdown/index.md index 83e5567550..e2bd35161f 100644 --- a/src/site/ko/markdown/index.md +++ b/src/site/ko/markdown/index.md @@ -48,7 +48,7 @@ MyBatis-Spring requires following versions: diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index bdfcad162f..8f9f49ae10 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -49,7 +49,7 @@ Users can read about MyBatis-Spring in the following translations:
  • Español
  • 日本語
  • 한국어
  • -
  • 简体中文
  • +
  • 简体中文
  • Do you want to read about MyBatis in your own native language? Fill an issue providing patches with your mother tongue documentation! diff --git a/src/site/resources/zh/css/site.css b/src/site/resources/zh_CN/css/site.css similarity index 100% rename from src/site/resources/zh/css/site.css rename to src/site/resources/zh_CN/css/site.css diff --git a/src/site/site_zh.xml b/src/site/site_zh_CN.xml similarity index 100% rename from src/site/site_zh.xml rename to src/site/site_zh_CN.xml diff --git a/src/site/zh/markdown/README.md b/src/site/zh_CN/markdown/README.md similarity index 100% rename from src/site/zh/markdown/README.md rename to src/site/zh_CN/markdown/README.md diff --git a/src/site/zh/markdown/batch.md b/src/site/zh_CN/markdown/batch.md similarity index 100% rename from src/site/zh/markdown/batch.md rename to src/site/zh_CN/markdown/batch.md diff --git a/src/site/zh/markdown/boot.md b/src/site/zh_CN/markdown/boot.md similarity index 100% rename from src/site/zh/markdown/boot.md rename to src/site/zh_CN/markdown/boot.md diff --git a/src/site/zh/markdown/factorybean.md b/src/site/zh_CN/markdown/factorybean.md similarity index 100% rename from src/site/zh/markdown/factorybean.md rename to src/site/zh_CN/markdown/factorybean.md diff --git a/src/site/zh/markdown/getting-started.md b/src/site/zh_CN/markdown/getting-started.md similarity index 100% rename from src/site/zh/markdown/getting-started.md rename to src/site/zh_CN/markdown/getting-started.md diff --git a/src/site/zh/markdown/index.md b/src/site/zh_CN/markdown/index.md similarity index 100% rename from src/site/zh/markdown/index.md rename to src/site/zh_CN/markdown/index.md diff --git a/src/site/zh/markdown/mappers.md b/src/site/zh_CN/markdown/mappers.md similarity index 100% rename from src/site/zh/markdown/mappers.md rename to src/site/zh_CN/markdown/mappers.md diff --git a/src/site/zh/markdown/sample.md b/src/site/zh_CN/markdown/sample.md similarity index 100% rename from src/site/zh/markdown/sample.md rename to src/site/zh_CN/markdown/sample.md diff --git a/src/site/zh/markdown/sqlsession.md b/src/site/zh_CN/markdown/sqlsession.md similarity index 100% rename from src/site/zh/markdown/sqlsession.md rename to src/site/zh_CN/markdown/sqlsession.md diff --git a/src/site/zh/markdown/transactions.md b/src/site/zh_CN/markdown/transactions.md similarity index 100% rename from src/site/zh/markdown/transactions.md rename to src/site/zh_CN/markdown/transactions.md diff --git a/src/site/zh/markdown/using-api.md b/src/site/zh_CN/markdown/using-api.md similarity index 100% rename from src/site/zh/markdown/using-api.md rename to src/site/zh_CN/markdown/using-api.md From 2b69e584377f0e0514ea29b5f909ce10afe8a970 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:44:44 +0000 Subject: [PATCH 658/933] Update spring core to v6.1.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd6005e4ec..582ad64749 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.16 - 6.1.5 + 6.1.6 5.1.1 org.mybatis.spring From 8713e532a292cccd04629a4195bc8bc2710e4e79 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:36:28 +0000 Subject: [PATCH 659/933] Update dependency org.slf4j:slf4j-simple to v2.0.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4f47d74f0d..b16b86a5c4 100644 --- a/pom.xml +++ b/pom.xml @@ -228,7 +228,7 @@ org.slf4j slf4j-simple - 2.0.12 + 2.0.13 test From 5e225dd27f27dfd8481a11b342d9e763ee0ec6b8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 01:43:44 +0000 Subject: [PATCH 660/933] Update dependency org.mybatis:mybatis-parent to v43 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b16b86a5c4..dffc1301b2 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.mybatis mybatis-parent - 42 + 43 From eae721b0ee575dd962ab35a6806e13fd291e8e30 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:02:01 +0000 Subject: [PATCH 661/933] Update JamesIves/github-pages-deploy-action action to v4.6.0 --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index d0c67a283a..651ce3145d 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -25,7 +25,7 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@v4.5.0 + uses: JamesIves/github-pages-deploy-action@v4.6.0 with: ssh-key: true branch: gh-pages From 48ed5a6d290fdaddd8e83b5d43348151330e63d9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:07:36 +0000 Subject: [PATCH 662/933] Update dependency net.bytebuddy:byte-buddy to v1.14.14 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dffc1301b2..98815b1833 100644 --- a/pom.xml +++ b/pom.xml @@ -319,7 +319,7 @@ net.bytebuddy byte-buddy - 1.14.13 + 1.14.14 test From 0924a4629fb9cf89546b3df85005dfd7258ff435 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:07:39 +0000 Subject: [PATCH 663/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.14 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dffc1301b2..f8c7636a06 100644 --- a/pom.xml +++ b/pom.xml @@ -325,7 +325,7 @@ net.bytebuddy byte-buddy-agent - 1.14.13 + 1.14.14 test From c2f7dece35ae8d5b96519cfbe54904630ed0d0c8 Mon Sep 17 00:00:00 2001 From: luozhenyu Date: Sat, 27 Apr 2024 19:55:58 +0800 Subject: [PATCH 664/933] Add environment to ClassPathMapperScanner to get properties from PropertySources --- pom.xml | 8 ++++++ .../spring/mapper/ClassPathMapperScanner.java | 13 ++++++++- .../mapper/MapperScannerConfigurer.java | 4 +-- .../AnnotatedMapperOnPropertyCondition.java | 27 +++++++++++++++++++ .../mapper/MapperScannerConfigurerTest.java | 16 ++++++++++- 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/mybatis/spring/mapper/AnnotatedMapperOnPropertyCondition.java diff --git a/pom.xml b/pom.xml index dffc1301b2..afb3b778bb 100644 --- a/pom.xml +++ b/pom.xml @@ -113,6 +113,7 @@ 10.17.1.0 3.5.16 6.1.6 + 3.2.5 5.1.1 org.mybatis.spring @@ -218,6 +219,13 @@
    + + org.springframework.boot + spring-boot-autoconfigure + ${spring-boot.version} + test + + org.hsqldb hsqldb diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index fab1c66ac5..dca8d02f3f 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; import org.springframework.core.NativeDetector; +import org.springframework.core.env.Environment; import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.util.StringUtils; @@ -86,6 +87,16 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { private String defaultScope; + public ClassPathMapperScanner(BeanDefinitionRegistry registry, Environment environment) { + super(registry, false, environment); + setIncludeAnnotationConfig(!AotDetector.useGeneratedArtifacts()); + setPrintWarnLogIfNotFoundMappers(!NativeDetector.inNativeImage()); + } + + /** + * @deprecated Please use the {@link #ClassPathMapperScanner(BeanDefinitionRegistry, Environment)}. + */ + @Deprecated(since = "3.0.4", forRemoval = true) public ClassPathMapperScanner(BeanDefinitionRegistry registry) { super(registry, false); setIncludeAnnotationConfig(!AotDetector.useGeneratedArtifacts()); diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 5b10b71192..29552ef25b 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -360,7 +360,7 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { processPropertyPlaceHolders(); } - ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry); + ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry, getEnvironment()); scanner.setAddToConfig(this.addToConfig); scanner.setAnnotationClass(this.annotationClass); scanner.setMarkerInterface(this.markerInterface); diff --git a/src/test/java/org/mybatis/spring/mapper/AnnotatedMapperOnPropertyCondition.java b/src/test/java/org/mybatis/spring/mapper/AnnotatedMapperOnPropertyCondition.java new file mode 100644 index 0000000000..a5170a92bc --- /dev/null +++ b/src/test/java/org/mybatis/spring/mapper/AnnotatedMapperOnPropertyCondition.java @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.spring.mapper; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +// annotated interface for MapperScannerPostProcessor tests +// ensures annotated classes are loaded on property condition +@Component +@ConditionalOnProperty(prefix = "mapper", value = "condition", havingValue = "true") +public interface AnnotatedMapperOnPropertyCondition { + void method(); +} diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index 3a9a3f16f9..fc1ce5f4b3 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,8 @@ import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.SimpleThreadScope; +import org.springframework.core.env.MutablePropertySources; +import org.springframework.mock.env.MockPropertySource; import org.springframework.stereotype.Component; class MapperScannerConfigurerTest { @@ -402,6 +404,18 @@ void testMapperBeanAttribute() { .getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)).isEqualTo(AnnotatedMapper.class); } + @Test + void testMapperBeanOnConditionalProperties() { + MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources(); + propertySources.addLast(new MockPropertySource().withProperty("mapper.condition", "true")); + + startContext(); + + assertThat(applicationContext.getBeanDefinition("annotatedMapperOnPropertyCondition") + .getAttribute(ClassPathMapperScanner.FACTORY_BEAN_OBJECT_TYPE)) + .isEqualTo(AnnotatedMapperOnPropertyCondition.class); + } + private void setupSqlSessionFactory(String name) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); From ad6c07cea22602683661bc91cc9a6c18b82ceae0 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 27 Apr 2024 14:30:07 -0400 Subject: [PATCH 665/933] [mvn] Update maven wrapper --- .mvn/extensions.xml | 2 +- .mvn/settings.xml | 14 +- .mvn/wrapper/MavenWrapperDownloader.java | 93 ++++---- .mvn/wrapper/maven-wrapper.properties | 3 +- mvnw | 256 +++++++++++++---------- mvnw.cmd | 21 +- pom.xml | 2 +- src/site/resources/zh_CN/css/site.css | 2 +- src/site/site_zh_CN.xml | 2 +- 9 files changed, 214 insertions(+), 181 deletions(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 5d2499ed32..aeaad3ef68 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -1,7 +1,7 @@ + + ossrh ${env.CI_DEPLOY_USERNAME} ${env.CI_DEPLOY_PASSWORD} + gh-pages-scm @@ -32,10 +35,19 @@ gh-pages + + github ${env.CI_DEPLOY_USERNAME} ${env.GITHUB_TOKEN} + + + + nvd + ${env.NVD_API_KEY} + + diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index f57fd86fbf..f6cb0fa0bb 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -21,77 +21,72 @@ import java.io.InputStream; import java.net.Authenticator; import java.net.PasswordAuthentication; +import java.net.URI; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.util.concurrent.ThreadLocalRandom; -public final class MavenWrapperDownloader -{ - private static final String WRAPPER_VERSION = "3.2.0"; +public final class MavenWrapperDownloader { + private static final String WRAPPER_VERSION = "3.3.1"; - private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) ); + private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE")); - public static void main( String[] args ) - { - log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION ); + public static void main(String[] args) { + log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION); - if ( args.length != 2 ) - { - System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" ); - System.exit( 1 ); + if (args.length != 2) { + System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing"); + System.exit(1); } - try - { - log( " - Downloader started" ); - final URL wrapperUrl = new URL( args[0] ); - final String jarPath = args[1].replace( "..", "" ); // Sanitize path - final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize(); - downloadFileFromURL( wrapperUrl, wrapperJarPath ); - log( "Done" ); - } - catch ( IOException e ) - { - System.err.println( "- Error downloading: " + e.getMessage() ); - if ( VERBOSE ) - { + try { + log(" - Downloader started"); + final URL wrapperUrl = URI.create(args[0]).toURL(); + final String jarPath = args[1].replace("..", ""); // Sanitize path + final Path wrapperJarPath = Paths.get(jarPath).toAbsolutePath().normalize(); + downloadFileFromURL(wrapperUrl, wrapperJarPath); + log("Done"); + } catch (IOException e) { + System.err.println("- Error downloading: " + e.getMessage()); + if (VERBOSE) { e.printStackTrace(); } - System.exit( 1 ); + System.exit(1); } } - private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath ) - throws IOException - { - log( " - Downloading to: " + wrapperJarPath ); - if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null ) - { - final String username = System.getenv( "MVNW_USERNAME" ); - final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray(); - Authenticator.setDefault( new Authenticator() - { + private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath) + throws IOException { + log(" - Downloading to: " + wrapperJarPath); + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + final String username = System.getenv("MVNW_USERNAME"); + final char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { @Override - protected PasswordAuthentication getPasswordAuthentication() - { - return new PasswordAuthentication( username, password ); + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); } - } ); + }); } - try ( InputStream inStream = wrapperUrl.openStream() ) - { - Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING ); + Path temp = wrapperJarPath + .getParent() + .resolve(wrapperJarPath.getFileName() + "." + + Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp"); + try (InputStream inStream = wrapperUrl.openStream()) { + Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING); + Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING); + } finally { + Files.deleteIfExists(temp); } - log( " - Downloader complete" ); + log(" - Downloader complete"); } - private static void log( String msg ) - { - if ( VERBOSE ) - { - System.out.println( msg ); + private static void log(String msg) { + if (VERBOSE) { + System.out.println(msg); } } diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 2f9352f713..d2a5c3fb8f 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +wrapperVersion=3.3.1 distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar diff --git a/mvnw b/mvnw index 66df285428..b21a698ee2 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.2.0 +# Apache Maven Wrapper startup batch script, version 3.3.1 # # Required ENV vars: # ------------------ @@ -33,75 +33,84 @@ # MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then +if [ -z "$MAVEN_SKIP_RC" ]; then - if [ -f /usr/local/etc/mavenrc ] ; then + if [ -f /usr/local/etc/mavenrc ]; then . /usr/local/etc/mavenrc fi - if [ -f /etc/mavenrc ] ; then + if [ -f /etc/mavenrc ]; then . /etc/mavenrc fi - if [ -f "$HOME/.mavenrc" ] ; then + if [ -f "$HOME/.mavenrc" ]; then . "$HOME/.mavenrc" fi fi # OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; +cygwin=false +darwin=false mingw=false case "$(uname)" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME - else - JAVA_HOME="/Library/Java/Home"; export JAVA_HOME - fi +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)" + export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home" + export JAVA_HOME fi - ;; + fi + ;; esac -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then JAVA_HOME=$(java-config --jre-home) fi fi # For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +if $cygwin; then + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") fi # For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && - JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +if $mingw; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ + && JAVA_HOME="$( + cd "$JAVA_HOME" || ( + echo "cannot cd into $JAVA_HOME." >&2 + exit 1 + ) + pwd + )" fi if [ -z "$JAVA_HOME" ]; then javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. readLink=$(which readlink) if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then - if $darwin ; then - javaHome="$(dirname "\"$javaExecutable\"")" - javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + if $darwin; then + javaHome="$(dirname "$javaExecutable")" + javaExecutable="$(cd "$javaHome" && pwd -P)/javac" else - javaExecutable="$(readlink -f "\"$javaExecutable\"")" + javaExecutable="$(readlink -f "$javaExecutable")" fi - javaHome="$(dirname "\"$javaExecutable\"")" + javaHome="$(dirname "$javaExecutable")" javaHome=$(expr "$javaHome" : '\(.*\)/bin') JAVA_HOME="$javaHome" export JAVA_HOME @@ -109,52 +118,60 @@ if [ -z "$JAVA_HOME" ]; then fi fi -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + JAVACMD="$( + \unset -f command 2>/dev/null + \command -v java + )" fi fi -if [ ! -x "$JAVACMD" ] ; then +if [ ! -x "$JAVACMD" ]; then echo "Error: JAVA_HOME is not defined correctly." >&2 echo " We cannot execute $JAVACMD" >&2 exit 1 fi -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." >&2 fi # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" >&2 return 1 fi basedir="$1" wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then basedir=$wdir break fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then - wdir=$(cd "$wdir/.." || exit 1; pwd) + wdir=$( + cd "$wdir/.." || exit 1 + pwd + ) fi # end of workaround done - printf '%s' "$(cd "$basedir" || exit 1; pwd)" + printf '%s' "$( + cd "$basedir" || exit 1 + pwd + )" } # concatenates all lines of a file @@ -165,7 +182,7 @@ concat_lines() { # enabled. Otherwise, we may read lines that are delimited with # \r\n and produce $'-Xarg\r' rather than -Xarg due to word # splitting rules. - tr -s '\r\n' ' ' < "$1" + tr -s '\r\n' ' ' <"$1" fi } @@ -177,10 +194,11 @@ log() { BASE_DIR=$(find_maven_basedir "$(dirname "$0")") if [ -z "$BASE_DIR" ]; then - exit 1; + exit 1 fi -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +export MAVEN_PROJECTBASEDIR log "$MAVEN_PROJECTBASEDIR" ########################################################################################## @@ -189,63 +207,66 @@ log "$MAVEN_PROJECTBASEDIR" ########################################################################################## wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" if [ -r "$wrapperJarPath" ]; then - log "Found $wrapperJarPath" + log "Found $wrapperJarPath" else - log "Couldn't find $wrapperJarPath, downloading it ..." + log "Couldn't find $wrapperJarPath, downloading it ..." - if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in wrapperUrl) + wrapperUrl="$safeValue" + break + ;; + esac + done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" fi - while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') - case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; - esac - done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" - log "Downloading from: $wrapperUrl" - + elif command -v curl >/dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") fi - - if command -v wget > /dev/null; then - log "Found wget ... using wget" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - log "Found curl ... using curl" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - fi - else - log "Falling back to using Java to download" - javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaSource=$(cygpath --path --windows "$javaSource") - javaClass=$(cygpath --path --windows "$javaClass") - fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - log " - Compiling MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/javac" "$javaSource") - fi - if [ -e "$javaClass" ]; then - log " - Running MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" - fi - fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi fi + fi fi ########################################################################################## # End of extension @@ -254,22 +275,25 @@ fi # If specified, validate the SHA-256 sum of the Maven wrapper jar file wrapperSha256Sum="" while IFS="=" read -r key value; do - case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + case "$key" in wrapperSha256Sum) + wrapperSha256Sum=$value + break + ;; esac -done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" if [ -n "$wrapperSha256Sum" ]; then wrapperSha256Result=false - if command -v sha256sum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + if command -v sha256sum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then wrapperSha256Result=true fi - elif command -v shasum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + elif command -v shasum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then wrapperSha256Result=true fi else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." - echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 exit 1 fi if [ $wrapperSha256Result = false ]; then @@ -284,12 +308,12 @@ MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] \ + && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") fi # Provide a "standardized" way to retrieve the CLI args that will diff --git a/mvnw.cmd b/mvnw.cmd index 95ba6f54ac..f93f29a8e3 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM Apache Maven Wrapper startup batch script, version 3.3.1 @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -59,22 +59,22 @@ set ERROR_CODE=0 @REM ==== START VALIDATION ==== if not "%JAVA_HOME%" == "" goto OkJHome -echo. +echo. >&2 echo Error: JAVA_HOME not found in your environment. >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 -echo. +echo. >&2 goto error :OkJHome if exist "%JAVA_HOME%\bin\java.exe" goto init -echo. +echo. >&2 echo Error: JAVA_HOME is set to an invalid directory. >&2 echo JAVA_HOME = "%JAVA_HOME%" >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 -echo. +echo. >&2 goto error @REM ==== END VALIDATION ==== @@ -119,7 +119,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar" FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B @@ -133,7 +133,7 @@ if exist %WRAPPER_JAR% ( ) ) else ( if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar" ) if "%MVNW_VERBOSE%" == "true" ( echo Couldn't find %WRAPPER_JAR%, downloading it ... @@ -160,11 +160,12 @@ FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapp ) IF NOT %WRAPPER_SHA_256_SUM%=="" ( powershell -Command "&{"^ + "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ - " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ - " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ - " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ " exit 1;"^ "}"^ "}" diff --git a/pom.xml b/pom.xml index bfd6a34d39..fe8ae88f54 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml index 952f381415..594ba58a3c 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml @@ -27,8 +27,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml index afddfa1898..6336a75ece 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextAssignFilter.xml @@ -27,8 +27,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml index b882eacb27..f477031cc0 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml @@ -28,8 +28,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml index 8d5aa2dd72..2cc3416793 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextCustFilter.xml @@ -27,8 +27,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml index dd3ee9281d..dfb19ac3d2 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml @@ -27,8 +27,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml index 49c126b478..a3c9cb881d 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml @@ -27,8 +27,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml index a38d81c527..b6f835770f 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml @@ -27,8 +27,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml index 75398c62e5..e2f5c502bf 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml @@ -28,8 +28,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml index a4a1e2b951..2b508e804b 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml @@ -28,8 +28,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml index 71e28999b0..f37b79028e 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml @@ -28,8 +28,8 @@ - - + + diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml index 6bd23fb252..2d909a4fe5 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextRegexFilter.xml @@ -27,8 +27,8 @@ - - + + From 3b5f798247d5c79ff8b0e6d17bc24b8e5acf0b7b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 23:06:27 +0000 Subject: [PATCH 669/933] Update dependency org.aspectj:aspectjweaver to v1.9.22 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c237fb2fd0..161a8c617c 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ org.aspectj aspectjweaver - 1.9.19 + 1.9.22 true From fbb5db2c77befae7fe67d1d68d75b5e8286250ef Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 11 May 2024 08:11:01 +0000 Subject: [PATCH 670/933] Update dependency org.aspectj:aspectjweaver to v1.9.22.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 161a8c617c..34d8e42cdc 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ org.aspectj aspectjweaver - 1.9.22 + 1.9.22.1 true From 95e8ff04c6a9021f6ffc946043a6a375517046e6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 11 May 2024 13:05:41 +0000 Subject: [PATCH 671/933] Update dependency org.mockito:mockito-core to v5.12.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 161a8c617c..c859458ee5 100644 --- a/pom.xml +++ b/pom.xml @@ -243,7 +243,7 @@ org.mockito mockito-core - 5.11.0 + 5.12.0 test From 09df48b82f3414cdbb27bc3e30891163f9643fae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 15:39:05 +0000 Subject: [PATCH 672/933] Update spring core to v6.1.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f8061a8d8a..39218757fd 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.16 - 6.1.6 + 6.1.7 3.2.5 5.1.1 org.mybatis.spring From bebd18111b7a5ceb3296b3cd003bb13314d7f0f3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 18 May 2024 11:43:23 +0000 Subject: [PATCH 673/933] Update JamesIves/github-pages-deploy-action action to v4.6.1 --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 651ce3145d..746afc0ec6 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -25,7 +25,7 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@v4.6.0 + uses: JamesIves/github-pages-deploy-action@v4.6.1 with: ssh-key: true branch: gh-pages From 36a8e2d3609e8782bd718543f64ad2d02c23b906 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 19 May 2024 14:22:13 -0400 Subject: [PATCH 674/933] [GHA] Add setup java for codeql --- .github/workflows/codeql.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bd854db357..4f13b7e031 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -50,6 +50,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 From b6f55ffe1b6d13da4a42dfbb89e1e177999348cb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 13:57:50 +0000 Subject: [PATCH 675/933] Update dependency net.bytebuddy:byte-buddy to v1.14.16 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 39218757fd..f16d2b5445 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.14.15 + 1.14.16 test From aaf241bfc7f9cdd6a003fed44c2ff0bcbb498c47 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 13:57:54 +0000 Subject: [PATCH 676/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.16 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 39218757fd..24d436d793 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.14.15 + 1.14.16 test From f2e89d090bf49dadcbf3ba162bdb21e24791a07d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 17:00:06 +0000 Subject: [PATCH 677/933] Update spring batch to v5.1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 39218757fd..e75ef0778f 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 3.5.16 6.1.7 3.2.5 - 5.1.1 + 5.1.2 org.mybatis.spring 5.10.2 From 2ceaa7b6abf089d441aa7e3eba3dbcc6b9d1d666 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 19:20:54 +0000 Subject: [PATCH 678/933] Update spring core to v6.1.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 39218757fd..2168cce6e9 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.16 - 6.1.7 + 6.1.8 3.2.5 5.1.1 org.mybatis.spring From 35fb42043d520b6984b5f01c9acc3c605a4231c4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 14:41:08 +0000 Subject: [PATCH 679/933] Update dependency org.springframework.boot:spring-boot-autoconfigure to v3.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index def4d9920d..703fb55203 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ 10.17.1.0 3.5.16 6.1.8 - 3.2.5 + 3.3.0 5.1.2 org.mybatis.spring From 090fb4ae0a88853a03c7ae1e4f12bed458c54656 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 25 May 2024 10:35:11 +0000 Subject: [PATCH 680/933] Update dependency maven to v3.9.7 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index d2a5c3fb8f..34d5438899 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -15,5 +15,5 @@ # specific language governing permissions and limitations # under the License. wrapperVersion=3.3.1 -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar From 102740b18d1b37ee05703beff957ba1c8dbfbf4c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 13:38:17 +0000 Subject: [PATCH 681/933] Update dependency org.assertj:assertj-core to v3.26.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 703fb55203..835c35a952 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ org.assertj assertj-core - 3.25.3 + 3.26.0 test From 27ed0c34ae67fa0523a2cd36dc48c48b02b7eda7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 20:25:54 +0000 Subject: [PATCH 682/933] Update dependency org.mybatis:mybatis-parent to v44 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 835c35a952..5bffb97641 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.mybatis mybatis-parent - 43 + 44 From f4230426abe9f4184ed69458a51e464a1c5334ad Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 18:31:55 +0000 Subject: [PATCH 683/933] Update dependency org.jboss.byteman:byteman-bmunit to v4.0.23 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5bffb97641..41896686f0 100644 --- a/pom.xml +++ b/pom.xml @@ -181,7 +181,7 @@ org.jboss.byteman byteman-bmunit - 4.0.22 + 4.0.23 test From fb83b852e0730c116266675db9a70b05bb9dd858 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 19:49:04 +0000 Subject: [PATCH 684/933] Update dependency net.bytebuddy:byte-buddy to v1.14.17 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41896686f0..dc4d18f8b5 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.14.16 + 1.14.17 test From 67cf83e15501dc6ab017f340e357f21f2209d2a5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 19:49:08 +0000 Subject: [PATCH 685/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.17 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41896686f0..6bf42346a3 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.14.16 + 1.14.17 test From 6490ee159db7dcc2a572d913d96413120a385a97 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 05:10:44 +0000 Subject: [PATCH 686/933] Update dependency org.hsqldb:hsqldb to v2.7.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0108f4d79e..88c40b196b 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ org.hsqldb hsqldb - 2.7.2 + 2.7.3 test From 62aacd5f3eb396a8d177f388458d3cb1c17edb6e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:06:45 +0000 Subject: [PATCH 687/933] Update dependency jakarta.servlet:jakarta.servlet-api to v6.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88c40b196b..8ad02784ac 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ jakarta.servlet jakarta.servlet-api - 6.0.0 + 6.1.0 test From 623ced743683867e8fd3235928254c77d6490d78 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:40:52 +0000 Subject: [PATCH 688/933] Update spring core to v6.1.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8ad02784ac..0cc8da32db 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.16 - 6.1.8 + 6.1.9 3.3.0 5.1.2 org.mybatis.spring From 79c3bf8dbe7ba0e2897cebde5de0aca9b434664f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:47:27 +0000 Subject: [PATCH 689/933] Update dependency maven to v3.9.8 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 34d5438899..bceca511d6 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -15,5 +15,5 @@ # specific language governing permissions and limitations # under the License. wrapperVersion=3.3.1 -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar From 4d0305fc6a3a4db9aebf034141a3d0946b250460 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:21:17 +0000 Subject: [PATCH 690/933] Update dependency org.springframework.boot:spring-boot-autoconfigure to v3.3.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0cc8da32db..5b8c5ca0b6 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ 10.17.1.0 3.5.16 6.1.9 - 3.3.0 + 3.3.1 5.1.2 org.mybatis.spring From bc15b50c11266b1b87cff790ddc1c5bfcd2daffb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 03:21:16 +0000 Subject: [PATCH 691/933] Update spring core to v6.1.10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b8c5ca0b6..cf677f2233 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.16 - 6.1.9 + 6.1.10 3.3.1 5.1.2 org.mybatis.spring From a75801afbc662d19a1b4b2667d37206027df65d5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:24:41 +0000 Subject: [PATCH 692/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf677f2233..d4554afc63 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 5.1.2 org.mybatis.spring - 5.10.2 + 5.10.3 1700476361 From 6a2e7bc3c2ba7942ffadce3f9266fcce8e1ace73 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:29:03 +0000 Subject: [PATCH 693/933] Update JamesIves/github-pages-deploy-action action to v4.6.3 --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 746afc0ec6..11eb6ac739 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -25,7 +25,7 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@v4.6.1 + uses: JamesIves/github-pages-deploy-action@v4.6.3 with: ssh-key: true branch: gh-pages From 58b695e383dd5203cb76564c32a5e41181885cf1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 19:41:52 +0000 Subject: [PATCH 694/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.18 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d4554afc63..5ad12d81d7 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.14.17 + 1.14.18 test From 37eabf8c9bfdbc0e5657c54d9d3309bb3458103a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 22:35:41 +0000 Subject: [PATCH 695/933] Update dependency net.bytebuddy:byte-buddy to v1.14.18 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d4554afc63..fb88375984 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.14.17 + 1.14.18 test From 280814fa39deb6a5261d2c1c111ca91e4142a8d7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:46:15 +0000 Subject: [PATCH 696/933] Update dependency org.assertj:assertj-core to v3.26.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9d6142e977..9c46e3174a 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ org.assertj assertj-core - 3.26.0 + 3.26.3 test From a0832abcf4e10cd5d8d0abb074c8c9f5e0c157d6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:26:34 +0000 Subject: [PATCH 697/933] Update spring core to v6.1.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9c46e3174a..bd72f8cee3 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 10.17.1.0 3.5.16 - 6.1.10 + 6.1.11 3.3.1 5.1.2 org.mybatis.spring From 593380bd3dd4e083488a51443ac65ebb2cfd1d5f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 13 Jul 2024 20:39:52 -0400 Subject: [PATCH 698/933] [ci] Update copyright date --- .../java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextAspectJFilter.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextAssignFilter.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextCombinedFilter.xml | 2 +- .../java/org/mybatis/spring/filter/xml/appContextCustFilter.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextInvalidFilter.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextPlaceHolder.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml | 2 +- .../spring/filter/xml/appContextProcessPlaceHolderOff.xml | 2 +- .../org/mybatis/spring/filter/xml/appContextRegexFilter.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml b/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml index c04257fe35..226600a61a 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml +++ b/src/test/java/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml @@ -1,7 +1,7 @@ 17 17 + 17 + 17 10.17.1.0 3.5.16 @@ -475,15 +477,6 @@ - - pre16 - - (,16) - - - 10.15.2.0 - - 17 From 1433d478524734d340748485197820ebaa20b9cd Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 14:50:13 -0400 Subject: [PATCH 708/933] [docs] javax.inject should be jakarta and reference to EE version should be removed on specific version as Jakarta is all that way --- src/site/es/markdown/mappers.md | 2 +- src/site/ja/markdown/mappers.md | 2 +- src/site/ko/markdown/mappers.md | 2 +- src/site/markdown/mappers.md | 2 +- src/site/zh_CN/markdown/mappers.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/site/es/markdown/mappers.md b/src/site/es/markdown/mappers.md index 5b10210fa8..01e3bce019 100644 --- a/src/site/es/markdown/mappers.md +++ b/src/site/es/markdown/mappers.md @@ -141,7 +141,7 @@ Si se indican ambas se añadirán todos los mappers que cumplan **cualquier** cr Los mappers descubiertos serán nombrados usando la estratégia de nombres por defecto de Spring para los componentes autodetectados (see [the Spring reference document(Core Technologies -Naming autodetected components-](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-scanning-name-generator)). Es decir, si no se encuentra ninguna anotación, se usará el nombre no cualificado sin capitalizar del mapper. Pero si se encuentra una anotación `@Component` o JSR-330 `@Named` se obtendrá el nombre de dicha anotación. -Fíjate que puedes usar como valor de la `annotation` el valor `org.springframework.stereotype.Component`, `javax.inject.Named` (if you have JSE 6) o una anotación propia (que debe ser a su vez anotada) de forma que la anotación hará las veces de localizador y de proveedor de nombre. +Fíjate que puedes usar como valor de la `annotation` el valor `org.springframework.stereotype.Component`, `jakarta.inject.Named` (if you have Jakarta EE) o una anotación propia (que debe ser a su vez anotada) de forma que la anotación hará las veces de localizador y de proveedor de nombre. NOTE `` no puede encontrar y registrar mappers. Los mappers son interfaces y, para poderlos registrar en Spring, el scanner deben conocer cómo crear un `MapperFactoryBean` para cada interfaz encontrado. diff --git a/src/site/ja/markdown/mappers.md b/src/site/ja/markdown/mappers.md index 03dcb250a1..9d9a7f09a6 100644 --- a/src/site/ja/markdown/mappers.md +++ b/src/site/ja/markdown/mappers.md @@ -139,7 +139,7 @@ XML 設定の例: 検出された Mapper は、Spring の自動検出コンポーネントに対するデフォルト命名規則によって Bean 名が決められます[the Spring reference document(Core Technologies -Naming autodetected components-](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-scanning-name-generator) を参照してください。 アノテーションによる指定がない場合はクラス名の先頭を小文字にした文字列が Bean 名となりますが、`@Component` あるいは JSR-330 の `@Named` アノテーションを使って Bean 名を明示的に指定することもできます。 -先に説明した `annotation` 属性で `org.springframework.stereotype.Component` や `javax.inject.Named` (Java 6 以降を利用している場合のみ)を指定すれば、検出時のマーカーと Bean 名の指定を1つのアノテーションで兼ねることができます。 +先に説明した `annotation` 属性で `org.springframework.stereotype.Component` や `jakarta.inject.Named` (Jakarta EE 以降を利用している場合のみ)を指定すれば、検出時のマーカーと Bean 名の指定を1つのアノテーションで兼ねることができます。 同じ目的で独自に定義したアノテーションを使うこともできますが、このアノテーション自体に `@Component` か `@Named` を付加しておく必要があります。 NOTE diff --git a/src/site/ko/markdown/mappers.md b/src/site/ko/markdown/mappers.md index c56ba731ff..0d3c2bdf78 100644 --- a/src/site/ko/markdown/mappers.md +++ b/src/site/ko/markdown/mappers.md @@ -136,7 +136,7 @@ The `default-scope` apply to the mapper bean(`MapperFactoryBean`) when scope of 발견된 매퍼는 자동검색된 컴포넌트를 위한 스프링의 디폴트 명명규칙 전략(see [the Spring reference document(Core Technologies -Naming autodetected components-)](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-scanning-name-generator) 을 사용해서 빈이름이 명명된다. 빈 이름을 정하는 애노테이션이 없다면 매퍼의 이름에서 첫글자를 소문자로 변환한 형태로 빈 이름을 사용할 것이다. `@Component` 나 JSR-330의 `@Named` 애노테이션이 있다면 애노테이션에 정의한 이름을 그대로 사용할 것이다. -`annotation` 프로퍼티를 `org.springframework.stereotype.Component`, `javax.inject.Named`(자바SE 1.6을 사용한다면) 또는 개발자가 스스로 작성한 애노테이션으로 셋팅할 수 있다. +`annotation` 프로퍼티를 `org.springframework.stereotype.Component`, `jakarta.inject.Named`(Jakarta EE을 사용한다면) 또는 개발자가 스스로 작성한 애노테이션으로 셋팅할 수 있다. 그러면 애노테이션은 마커와 이름을 제공하는 역할로 동작할 것이다. 중요 diff --git a/src/site/markdown/mappers.md b/src/site/markdown/mappers.md index ad365ff92f..79a6582e10 100644 --- a/src/site/markdown/mappers.md +++ b/src/site/markdown/mappers.md @@ -135,7 +135,7 @@ By default, these two properties are null, so all interfaces in the given base p Discovered mappers will be named using Spring default naming strategy for autodetected components (see [the Spring reference document(Core Technologies -Naming autodetected components-)](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-scanning-name-generator)). That is, if no annotation is found, it will use the uncapitalized non-qualified class name of the mapper. But if either a `@Component` or a JSR-330 `@Named` annotation is found it will get the name from the annotation. -Notice that you can set the `annotation` attribute to `org.springframework.stereotype.Component`, `javax.inject.Named` (if you have JSE 6) or to your own annotation (that must be itself annotated) so the annotation will work both as a marker and as a name provider. +Notice that you can set the `annotation` attribute to `org.springframework.stereotype.Component`, `jakarta.inject.Named` (if you have JakartaEE) or to your own annotation (that must be itself annotated) so the annotation will work both as a marker and as a name provider. NOTE `` won't be able to scan and register mappers. Mappers are interfaces and, in order to register them to Spring, the scanner must know how to create a `MapperFactoryBean` for each interface it finds. diff --git a/src/site/zh_CN/markdown/mappers.md b/src/site/zh_CN/markdown/mappers.md index 0d5dff3ae7..d9cd92b532 100644 --- a/src/site/zh_CN/markdown/mappers.md +++ b/src/site/zh_CN/markdown/mappers.md @@ -137,7 +137,7 @@ public interface GoodsMapper { 被发现的映射器会按照 Spring 对自动发现组件的默认命名策略进行命名(参考 [the Spring reference document(Core Technologies -Naming autodetected components-)](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-scanning-name-generator) )。 也就是说,如果没有使用注解显式指定名称,将会使用映射器的首字母小写非全限定类名作为名称。但如果发现映射器具有 `@Component` 或 JSR-330 标准中 `@Named` 注解,会使用注解中的名称作为名称。 -提醒一下,你可以设置 `annotation` 属性为你自定义的注解,然后在你的注解上设置 `org.springframework.stereotype.Component` 或 `javax.inject.Named`(需要使用 Java SE 6 以上)注解,这样你的注解既可以作为标记,也可以作为一个名字提供器来使用了。 +提醒一下,你可以设置 `annotation` 属性为你自定义的注解,然后在你的注解上设置 `org.springframework.stereotype.Component` 或 `jakarta.inject.Named`(需要使用 Jakarta EE 以上)注解,这样你的注解既可以作为标记,也可以作为一个名字提供器来使用了。 提示 `` 无法发现并注册映射器。映射器的本质是接口,为了将它们注册到 Spring 中,发现器必须知道如何为找到的每个接口创建一个 `MapperFactoryBean`。 From 7c33fd0710b9474e6bd86dd367655d48a8d5a8f6 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 14:53:49 -0400 Subject: [PATCH 709/933] [layout] Move tests into standard maven directory layout --- src/test/{java => resources}/org/mybatis/spring/TestMapper.xml | 2 +- src/test/{java => resources}/org/mybatis/spring/TestMapper2.xml | 2 +- src/test/{java => resources}/org/mybatis/spring/TestMapper3.xml | 2 +- .../org/mybatis/spring/annotation/override.properties | 2 +- .../org/mybatis/spring/annotation/placeholders.properties | 2 +- .../org/mybatis/spring/annotation/scan.properties | 2 +- .../org/mybatis/spring/batch/applicationContext.xml | 2 +- .../org/mybatis/spring/batch/dao/EmployeeMapper.xml | 2 +- .../org/mybatis/spring/batch/db/database-schema.sql | 2 +- .../org/mybatis/spring/batch/db/database-test-data.sql | 2 +- .../org/mybatis/spring/config/annotation.xml | 2 +- .../org/mybatis/spring/config/base-package.xml | 2 +- .../org/mybatis/spring/config/default-scope.properties | 2 +- .../org/mybatis/spring/config/default-scope.xml | 2 +- .../org/mybatis/spring/config/factory-ref.xml | 2 +- .../org/mybatis/spring/config/lazy.properties | 2 +- src/test/{java => resources}/org/mybatis/spring/config/lazy.xml | 2 +- .../org/mybatis/spring/config/mapper-factory-bean-class.xml | 2 +- .../org/mybatis/spring/config/marker-and-annotation.xml | 2 +- .../org/mybatis/spring/config/marker-interface.xml | 2 +- .../org/mybatis/spring/config/name-generator.xml | 2 +- .../org/mybatis/spring/config/override.properties | 2 +- .../org/mybatis/spring/config/placeholders.properties | 2 +- .../spring/config/process-property-placeholders-false.xml | 2 +- .../spring/config/process-property-placeholders-true.xml | 2 +- .../org/mybatis/spring/config/template-ref.xml | 2 +- .../org/mybatis/spring/filter/config/application.properties | 2 +- .../org/mybatis/spring/filter/xml/appContextAnnoFilter.xml | 0 .../org/mybatis/spring/filter/xml/appContextAspectJFilter.xml | 0 .../org/mybatis/spring/filter/xml/appContextAssignFilter.xml | 0 .../org/mybatis/spring/filter/xml/appContextCombinedFilter.xml | 0 .../org/mybatis/spring/filter/xml/appContextCustFilter.xml | 0 .../org/mybatis/spring/filter/xml/appContextInvalidFilter.xml | 0 .../org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml | 0 .../org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml | 0 .../org/mybatis/spring/filter/xml/appContextPlaceHolder.xml | 0 .../org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml | 0 .../spring/filter/xml/appContextProcessPlaceHolderOff.xml | 0 .../org/mybatis/spring/filter/xml/appContextRegexFilter.xml | 0 .../org/mybatis/spring/filter/xml/default.properties | 2 +- .../{java => resources}/org/mybatis/spring/mybatis-config.xml | 2 +- .../mybatis/spring/sample/config/applicationContext-batch.xml | 2 +- .../spring/sample/config/applicationContext-infrastructure.xml | 2 +- .../org/mybatis/spring/sample/config/applicationContext-job.xml | 2 +- .../mybatis/spring/sample/config/applicationContext-mapper.xml | 2 +- .../spring/sample/config/applicationContext-namespace.xml | 2 +- .../mybatis/spring/sample/config/applicationContext-scanner.xml | 2 +- .../spring/sample/config/applicationContext-sqlsession.xml | 2 +- .../org/mybatis/spring/sample/db/database-schema.sql | 2 +- .../org/mybatis/spring/sample/db/database-test-data.sql | 2 +- .../org/mybatis/spring/sample/mapper/PersonMapper.xml | 2 +- .../org/mybatis/spring/sample/mapper/UserMapper.xml | 2 +- .../org/mybatis/spring/submitted/autowire/BarMapper.xml | 2 +- .../org/mybatis/spring/submitted/autowire/FooMapper.xml | 2 +- .../mybatis/spring/submitted/autowire/database-schema-bar.sql | 2 +- .../mybatis/spring/submitted/autowire/database-schema-foo.sql | 2 +- .../org/mybatis/spring/submitted/autowire/spring.xml | 2 +- .../mybatis/spring/submitted/webapp_placeholder/conf.properties | 2 +- .../org/mybatis/spring/submitted/webapp_placeholder/spring.xml | 2 +- .../org/mybatis/spring/submitted/xa/applicationContext.xml | 2 +- .../org/mybatis/spring/submitted/xa/database-schema.sql | 2 +- 61 files changed, 49 insertions(+), 49 deletions(-) rename src/test/{java => resources}/org/mybatis/spring/TestMapper.xml (95%) rename src/test/{java => resources}/org/mybatis/spring/TestMapper2.xml (93%) rename src/test/{java => resources}/org/mybatis/spring/TestMapper3.xml (93%) rename src/test/{java => resources}/org/mybatis/spring/annotation/override.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/annotation/placeholders.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/annotation/scan.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/batch/applicationContext.xml (98%) rename src/test/{java => resources}/org/mybatis/spring/batch/dao/EmployeeMapper.xml (97%) rename src/test/{java => resources}/org/mybatis/spring/batch/db/database-schema.sql (92%) rename src/test/{java => resources}/org/mybatis/spring/batch/db/database-test-data.sql (94%) rename src/test/{java => resources}/org/mybatis/spring/config/annotation.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/base-package.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/default-scope.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/config/default-scope.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/factory-ref.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/lazy.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/config/lazy.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/mapper-factory-bean-class.xml (95%) rename src/test/{java => resources}/org/mybatis/spring/config/marker-and-annotation.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/marker-interface.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/config/name-generator.xml (95%) rename src/test/{java => resources}/org/mybatis/spring/config/override.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/config/placeholders.properties (91%) rename src/test/{java => resources}/org/mybatis/spring/config/process-property-placeholders-false.xml (97%) rename src/test/{java => resources}/org/mybatis/spring/config/process-property-placeholders-true.xml (97%) rename src/test/{java => resources}/org/mybatis/spring/config/template-ref.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/filter/config/application.properties (92%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextAnnoFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextAspectJFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextAssignFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextCombinedFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextCustFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextInvalidFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextInvalidFilter1.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextInvalidFilter2.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextPlaceHolder.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextPlaceHolder1.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextProcessPlaceHolderOff.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/appContextRegexFilter.xml (100%) rename src/test/{java => resources}/org/mybatis/spring/filter/xml/default.properties (93%) rename src/test/{java => resources}/org/mybatis/spring/mybatis-config.xml (95%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-batch.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-infrastructure.xml (98%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-job.xml (98%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-mapper.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-namespace.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-scanner.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/sample/config/applicationContext-sqlsession.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/sample/db/database-schema.sql (94%) rename src/test/{java => resources}/org/mybatis/spring/sample/db/database-test-data.sql (93%) rename src/test/{java => resources}/org/mybatis/spring/sample/mapper/PersonMapper.xml (94%) rename src/test/{java => resources}/org/mybatis/spring/sample/mapper/UserMapper.xml (95%) rename src/test/{java => resources}/org/mybatis/spring/submitted/autowire/BarMapper.xml (94%) mode change 100755 => 100644 rename src/test/{java => resources}/org/mybatis/spring/submitted/autowire/FooMapper.xml (93%) rename src/test/{java => resources}/org/mybatis/spring/submitted/autowire/database-schema-bar.sql (92%) mode change 100755 => 100644 rename src/test/{java => resources}/org/mybatis/spring/submitted/autowire/database-schema-foo.sql (92%) mode change 100755 => 100644 rename src/test/{java => resources}/org/mybatis/spring/submitted/autowire/spring.xml (98%) rename src/test/{java => resources}/org/mybatis/spring/submitted/webapp_placeholder/conf.properties (92%) rename src/test/{java => resources}/org/mybatis/spring/submitted/webapp_placeholder/spring.xml (96%) rename src/test/{java => resources}/org/mybatis/spring/submitted/xa/applicationContext.xml (99%) rename src/test/{java => resources}/org/mybatis/spring/submitted/xa/database-schema.sql (92%) diff --git a/src/test/java/org/mybatis/spring/TestMapper.xml b/src/test/resources/org/mybatis/spring/TestMapper.xml similarity index 95% rename from src/test/java/org/mybatis/spring/TestMapper.xml rename to src/test/resources/org/mybatis/spring/TestMapper.xml index 6678c0ffa4..389d432dba 100644 --- a/src/test/java/org/mybatis/spring/TestMapper.xml +++ b/src/test/resources/org/mybatis/spring/TestMapper.xml @@ -1,7 +1,7 @@ @@ -325,12 +333,6 @@ 6.1.0 test - - org.aspectj - aspectjweaver - 1.9.22.1 - true - net.bytebuddy From a87843d9a933e8ff20aecc4f32e8de0fcd5af77c Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 14:55:53 -0400 Subject: [PATCH 713/933] [pom] Remove old exclusion no longer needed --- pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.xml b/pom.xml index 664e556103..9be4e08be3 100644 --- a/pom.xml +++ b/pom.xml @@ -286,10 +286,6 @@ nekohtml nekohtml
    - - junit - junit -
    From a2dfb40aa3ab57c0416d4bbb7b3a7a3d395d386b Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 14:56:04 -0400 Subject: [PATCH 714/933] [pom] Prefer standard directory layout --- pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pom.xml b/pom.xml index 9be4e08be3..fce0e4ef20 100644 --- a/pom.xml +++ b/pom.xml @@ -402,14 +402,6 @@ ${project.basedir}/src/main/resources - - - ${project.build.testSourceDirectory} - - **/*.java - - - org.apache.maven.plugins From 7d18e7a4ce4f897555527756fd37c7f14b0a5f78 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 14:56:22 -0400 Subject: [PATCH 715/933] [pom] Update deprecated surefire systemProperties to systemPropertyVariables --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fce0e4ef20..e7f4ab9dbb 100644 --- a/pom.xml +++ b/pom.xml @@ -407,7 +407,7 @@ org.apache.maven.plugins maven-surefire-plugin - + derby.stream.error.file ${project.build.directory}/derby.log @@ -416,7 +416,7 @@ com.atomikos.icatch.log_base_dir ${project.build.directory} - + From 3f0679a5be4700c9c2e7c261fe8a12801a7b0066 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 14:56:34 -0400 Subject: [PATCH 716/933] [pom] Use maven variable for directory --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7f4ab9dbb..5e4b090f48 100644 --- a/pom.xml +++ b/pom.xml @@ -434,7 +434,7 @@ ${project.build.directory}/site-src - src/site + ${project.basedir}/src/site true From b71197644ec340c2ea9623a28cf4e58f35369eb2 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:09:32 -0400 Subject: [PATCH 717/933] [docs] Remove legacy inheritDoc as @Overrides does same thing --- .../spring/MyBatisExceptionTranslator.java | 3 - .../mybatis/spring/SqlSessionFactoryBean.java | 15 --- .../mybatis/spring/SqlSessionTemplate.java | 92 ------------------- .../org/mybatis/spring/SqlSessionUtils.java | 18 ---- .../annotation/MapperScannerRegistrar.java | 9 -- .../spring/batch/MyBatisBatchItemWriter.java | 3 - .../MapperScannerBeanDefinitionParser.java | 11 --- .../spring/config/NamespaceHandler.java | 3 - .../spring/mapper/ClassPathMapperScanner.java | 6 -- .../spring/mapper/MapperFactoryBean.java | 12 --- .../mapper/MapperScannerConfigurer.java | 17 ---- .../spring/support/SqlSessionDaoSupport.java | 3 - .../transaction/SpringManagedTransaction.java | 15 --- .../SpringManagedTransactionFactory.java | 9 -- 14 files changed, 216 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index f7a8bb5825..09c33cb2bb 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -74,9 +74,6 @@ public MyBatisExceptionTranslator(Supplier exceptionTran } } - /** - * {@inheritDoc} - */ @Override public DataAccessException translateExceptionIfPossible(RuntimeException e) { if (e instanceof PersistenceException) { diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index c4032f142c..4ed4961282 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -564,9 +564,6 @@ private T[] appendArrays(T[] oldArrays, T[] newArrays, IntFunction gene } } - /** - * {@inheritDoc} - */ @Override public void afterPropertiesSet() throws Exception { notNull(dataSource, "Property 'dataSource' is required"); @@ -711,9 +708,6 @@ protected SqlSessionFactory buildSqlSessionFactory() throws Exception { return this.sqlSessionFactoryBuilder.build(targetConfiguration); } - /** - * {@inheritDoc} - */ @Override public SqlSessionFactory getObject() throws Exception { if (this.sqlSessionFactory == null) { @@ -723,25 +717,16 @@ public SqlSessionFactory getObject() throws Exception { return this.sqlSessionFactory; } - /** - * {@inheritDoc} - */ @Override public Class getObjectType() { return this.sqlSessionFactory == null ? SqlSessionFactory.class : this.sqlSessionFactory.getClass(); } - /** - * {@inheritDoc} - */ @Override public boolean isSingleton() { return true; } - /** - * {@inheritDoc} - */ @Override public void onApplicationEvent(ContextRefreshedEvent event) { if (failFast) { diff --git a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java index cb6eaf4bd6..16f9ebf80b 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java +++ b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java @@ -144,243 +144,151 @@ public PersistenceExceptionTranslator getPersistenceExceptionTranslator() { return this.exceptionTranslator; } - /** - * {@inheritDoc} - */ @Override public T selectOne(String statement) { return this.sqlSessionProxy.selectOne(statement); } - /** - * {@inheritDoc} - */ @Override public T selectOne(String statement, Object parameter) { return this.sqlSessionProxy.selectOne(statement, parameter); } - /** - * {@inheritDoc} - */ @Override public Map selectMap(String statement, String mapKey) { return this.sqlSessionProxy.selectMap(statement, mapKey); } - /** - * {@inheritDoc} - */ @Override public Map selectMap(String statement, Object parameter, String mapKey) { return this.sqlSessionProxy.selectMap(statement, parameter, mapKey); } - /** - * {@inheritDoc} - */ @Override public Map selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds) { return this.sqlSessionProxy.selectMap(statement, parameter, mapKey, rowBounds); } - /** - * {@inheritDoc} - */ @Override public Cursor selectCursor(String statement) { return this.sqlSessionProxy.selectCursor(statement); } - /** - * {@inheritDoc} - */ @Override public Cursor selectCursor(String statement, Object parameter) { return this.sqlSessionProxy.selectCursor(statement, parameter); } - /** - * {@inheritDoc} - */ @Override public Cursor selectCursor(String statement, Object parameter, RowBounds rowBounds) { return this.sqlSessionProxy.selectCursor(statement, parameter, rowBounds); } - /** - * {@inheritDoc} - */ @Override public List selectList(String statement) { return this.sqlSessionProxy.selectList(statement); } - /** - * {@inheritDoc} - */ @Override public List selectList(String statement, Object parameter) { return this.sqlSessionProxy.selectList(statement, parameter); } - /** - * {@inheritDoc} - */ @Override public List selectList(String statement, Object parameter, RowBounds rowBounds) { return this.sqlSessionProxy.selectList(statement, parameter, rowBounds); } - /** - * {@inheritDoc} - */ @Override public void select(String statement, ResultHandler handler) { this.sqlSessionProxy.select(statement, handler); } - /** - * {@inheritDoc} - */ @Override public void select(String statement, Object parameter, ResultHandler handler) { this.sqlSessionProxy.select(statement, parameter, handler); } - /** - * {@inheritDoc} - */ @Override public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) { this.sqlSessionProxy.select(statement, parameter, rowBounds, handler); } - /** - * {@inheritDoc} - */ @Override public int insert(String statement) { return this.sqlSessionProxy.insert(statement); } - /** - * {@inheritDoc} - */ @Override public int insert(String statement, Object parameter) { return this.sqlSessionProxy.insert(statement, parameter); } - /** - * {@inheritDoc} - */ @Override public int update(String statement) { return this.sqlSessionProxy.update(statement); } - /** - * {@inheritDoc} - */ @Override public int update(String statement, Object parameter) { return this.sqlSessionProxy.update(statement, parameter); } - /** - * {@inheritDoc} - */ @Override public int delete(String statement) { return this.sqlSessionProxy.delete(statement); } - /** - * {@inheritDoc} - */ @Override public int delete(String statement, Object parameter) { return this.sqlSessionProxy.delete(statement, parameter); } - /** - * {@inheritDoc} - */ @Override public T getMapper(Class type) { return getConfiguration().getMapper(type, this); } - /** - * {@inheritDoc} - */ @Override public void commit() { throw new UnsupportedOperationException("Manual commit is not allowed over a Spring managed SqlSession"); } - /** - * {@inheritDoc} - */ @Override public void commit(boolean force) { throw new UnsupportedOperationException("Manual commit is not allowed over a Spring managed SqlSession"); } - /** - * {@inheritDoc} - */ @Override public void rollback() { throw new UnsupportedOperationException("Manual rollback is not allowed over a Spring managed SqlSession"); } - /** - * {@inheritDoc} - */ @Override public void rollback(boolean force) { throw new UnsupportedOperationException("Manual rollback is not allowed over a Spring managed SqlSession"); } - /** - * {@inheritDoc} - */ @Override public void close() { throw new UnsupportedOperationException("Manual close is not allowed over a Spring managed SqlSession"); } - /** - * {@inheritDoc} - */ @Override public void clearCache() { this.sqlSessionProxy.clearCache(); } - /** - * {@inheritDoc} - */ @Override public Configuration getConfiguration() { return this.sqlSessionFactory.getConfiguration(); } - /** - * {@inheritDoc} - */ @Override public Connection getConnection() { return this.sqlSessionProxy.getConnection(); } - /** - * {@inheritDoc} - * - * @since 1.0.2 - */ @Override public List flushStatements() { return this.sqlSessionProxy.flushStatements(); diff --git a/src/main/java/org/mybatis/spring/SqlSessionUtils.java b/src/main/java/org/mybatis/spring/SqlSessionUtils.java index f36272f0d2..5dbea2862e 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionUtils.java +++ b/src/main/java/org/mybatis/spring/SqlSessionUtils.java @@ -241,18 +241,12 @@ public SqlSessionSynchronization(SqlSessionHolder holder, SqlSessionFactory sess this.sessionFactory = sessionFactory; } - /** - * {@inheritDoc} - */ @Override public int getOrder() { // order right before any Connection synchronization return DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 1; } - /** - * {@inheritDoc} - */ @Override public void suspend() { if (this.holderActive) { @@ -261,9 +255,6 @@ public void suspend() { } } - /** - * {@inheritDoc} - */ @Override public void resume() { if (this.holderActive) { @@ -272,9 +263,6 @@ public void resume() { } } - /** - * {@inheritDoc} - */ @Override public void beforeCommit(boolean readOnly) { // Connection commit or rollback will be handled by ConnectionSynchronization or @@ -300,9 +288,6 @@ public void beforeCommit(boolean readOnly) { } } - /** - * {@inheritDoc} - */ @Override public void beforeCompletion() { // Issue #18 Close SqlSession and deregister it now @@ -317,9 +302,6 @@ public void beforeCompletion() { } } - /** - * {@inheritDoc} - */ @Override public void afterCompletion(int status) { if (this.holderActive) { diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index 88155e15e0..beecd3199e 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -63,17 +63,11 @@ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, Re private ResourceLoader resourceLoader; - /** - * {@inheritDoc} - */ @Override public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } - /** - * {@inheritDoc} - */ @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AnnotationAttributes mapperScanAttrs = AnnotationAttributes @@ -249,9 +243,6 @@ private static String getDefaultBasePackage(AnnotationMetadata importingClassMet * @since 2.0.0 */ static class RepeatingRegistrar extends MapperScannerRegistrar { - /** - * {@inheritDoc} - */ @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AnnotationAttributes mapperScansAttrs = AnnotationAttributes diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index 1da81f0547..de10b752d6 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -133,9 +133,6 @@ public void afterPropertiesSet() { notNull(itemToParameterConverter, "A itemToParameterConverter is required."); } - /** - * {@inheritDoc} - */ @Override public void write(final Chunk items) { diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index 5858a2e3b6..e85706e16f 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -50,7 +50,6 @@ * @see ClassPathMapperScanner * @see MapperScannerConfigurer */ - public class MapperScannerBeanDefinitionParser extends AbstractBeanDefinitionParser { private static final String ATTRIBUTE_BASE_PACKAGE = "base-package"; @@ -65,11 +64,6 @@ public class MapperScannerBeanDefinitionParser extends AbstractBeanDefinitionPar private static final String ATTRIBUTE_PROCESS_PROPERTY_PLACEHOLDERS = "process-property-placeholders"; private static final String ATTRIBUTE_EXCLUDE_FILTER = "exclude-filter"; - /** - * {@inheritDoc} - * - * @since 2.0.2 - */ @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); @@ -147,11 +141,6 @@ private List> parseScanTypeFilters(Element element, ParserCo return typeFilters; } - /** - * {@inheritDoc} - * - * @since 2.0.2 - */ @Override protected boolean shouldGenerateIdAsFallback() { return true; diff --git a/src/main/java/org/mybatis/spring/config/NamespaceHandler.java b/src/main/java/org/mybatis/spring/config/NamespaceHandler.java index e3e777f5d2..410fa886d9 100644 --- a/src/main/java/org/mybatis/spring/config/NamespaceHandler.java +++ b/src/main/java/org/mybatis/spring/config/NamespaceHandler.java @@ -28,9 +28,6 @@ */ public class NamespaceHandler extends NamespaceHandlerSupport { - /** - * {@inheritDoc} - */ @Override public void init() { registerBeanDefinitionParser("scan", new MapperScannerBeanDefinitionParser()); diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 441f433162..0e755007db 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -354,17 +354,11 @@ private void processBeanDefinitions(Set beanDefinitions) { } } - /** - * {@inheritDoc} - */ @Override protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { return beanDefinition.getMetadata().isInterface() && beanDefinition.getMetadata().isIndependent(); } - /** - * {@inheritDoc} - */ @Override protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) { if (super.checkCandidate(beanName, beanDefinition)) { diff --git a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java index 89e4e1e415..6c16d862d1 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java @@ -65,9 +65,6 @@ public MapperFactoryBean(Class mapperInterface) { this.mapperInterface = mapperInterface; } - /** - * {@inheritDoc} - */ @Override protected void checkDaoConfig() { super.checkDaoConfig(); @@ -87,25 +84,16 @@ protected void checkDaoConfig() { } } - /** - * {@inheritDoc} - */ @Override public T getObject() throws Exception { return getSqlSession().getMapper(this.mapperInterface); } - /** - * {@inheritDoc} - */ @Override public Class getObjectType() { return this.mapperInterface; } - /** - * {@inheritDoc} - */ @Override public boolean isSingleton() { return true; diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 613d064ae7..aec74d4544 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -322,17 +322,11 @@ public void setMapperFactoryBeanClass(Class mapperF this.mapperFactoryBeanClass = mapperFactoryBeanClass; } - /** - * {@inheritDoc} - */ @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } - /** - * {@inheritDoc} - */ @Override public void setBeanName(String name) { this.beanName = name; @@ -376,27 +370,16 @@ public void setDefaultScope(String defaultScope) { this.defaultScope = defaultScope; } - /** - * {@inheritDoc} - */ @Override public void afterPropertiesSet() throws Exception { notNull(this.basePackage, "Property 'basePackage' is required"); } - /** - * {@inheritDoc} - */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { // left intentionally blank } - /** - * {@inheritDoc} - * - * @since 1.0.2 - */ @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { if (this.processPropertyPlaceHolders) { diff --git a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java index 0c312105be..c129bd6833 100644 --- a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java +++ b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java @@ -117,9 +117,6 @@ public SqlSessionTemplate getSqlSessionTemplate() { return this.sqlSessionTemplate; } - /** - * {@inheritDoc} - */ @Override protected void checkDaoConfig() { notNull(this.sqlSessionTemplate, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required"); diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java index 5bc038b51f..f2919e8b35 100644 --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java @@ -58,9 +58,6 @@ public SpringManagedTransaction(DataSource dataSource) { this.dataSource = dataSource; } - /** - * {@inheritDoc} - */ @Override public Connection getConnection() throws SQLException { if (this.connection == null) { @@ -85,9 +82,6 @@ private void openConnection() throws SQLException { + (this.isConnectionTransactional ? " " : " not ") + "be managed by Spring"); } - /** - * {@inheritDoc} - */ @Override public void commit() throws SQLException { if (this.connection != null && !this.isConnectionTransactional && !this.autoCommit) { @@ -96,9 +90,6 @@ public void commit() throws SQLException { } } - /** - * {@inheritDoc} - */ @Override public void rollback() throws SQLException { if (this.connection != null && !this.isConnectionTransactional && !this.autoCommit) { @@ -107,17 +98,11 @@ public void rollback() throws SQLException { } } - /** - * {@inheritDoc} - */ @Override public void close() throws SQLException { DataSourceUtils.releaseConnection(this.connection, this.dataSource); } - /** - * {@inheritDoc} - */ @Override public Integer getTimeout() throws SQLException { ConnectionHolder holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource); diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java index 32efd490f5..6135b13d4d 100644 --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java @@ -31,25 +31,16 @@ */ public class SpringManagedTransactionFactory implements TransactionFactory { - /** - * {@inheritDoc} - */ @Override public Transaction newTransaction(DataSource dataSource, TransactionIsolationLevel level, boolean autoCommit) { return new SpringManagedTransaction(dataSource); } - /** - * {@inheritDoc} - */ @Override public Transaction newTransaction(Connection conn) { throw new UnsupportedOperationException("New Spring transactions require a DataSource"); } - /** - * {@inheritDoc} - */ @Override public void setProperties(Properties props) { // not needed in this version From be8276180ff0c0808133b1cf2170166127df8fad Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:13:57 -0400 Subject: [PATCH 718/933] [ci] Update copyright dates --- .../java/org/mybatis/spring/MyBatisExceptionTranslator.java | 2 +- src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java | 2 +- src/main/java/org/mybatis/spring/SqlSessionTemplate.java | 2 +- src/main/java/org/mybatis/spring/SqlSessionUtils.java | 2 +- .../org/mybatis/spring/annotation/MapperScannerRegistrar.java | 2 +- .../java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java | 2 +- .../spring/config/MapperScannerBeanDefinitionParser.java | 2 +- src/main/java/org/mybatis/spring/config/NamespaceHandler.java | 2 +- src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java | 2 +- .../java/org/mybatis/spring/support/SqlSessionDaoSupport.java | 2 +- .../mybatis/spring/transaction/SpringManagedTransaction.java | 2 +- .../spring/transaction/SpringManagedTransactionFactory.java | 2 +- .../spring/asyncsynchronization/AsyncAfterCompletionHelper.java | 1 - 13 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index 09c33cb2bb..c2215925c1 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 4ed4961282..8a0a44c3d6 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java index 16f9ebf80b..130987488a 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java +++ b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/SqlSessionUtils.java b/src/main/java/org/mybatis/spring/SqlSessionUtils.java index 5dbea2862e..9c2804ec1f 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionUtils.java +++ b/src/main/java/org/mybatis/spring/SqlSessionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index beecd3199e..181273ea92 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index de10b752d6..d2fbbdc3e7 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index e85706e16f..33c93665f9 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/config/NamespaceHandler.java b/src/main/java/org/mybatis/spring/config/NamespaceHandler.java index 410fa886d9..12912c8dc6 100644 --- a/src/main/java/org/mybatis/spring/config/NamespaceHandler.java +++ b/src/main/java/org/mybatis/spring/config/NamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java index 6c16d862d1..a6fe818c65 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java index c129bd6833..d7f4dbe594 100644 --- a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java +++ b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java index f2919e8b35..f9e332dcab 100644 --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java index 6135b13d4d..371c574d54 100644 --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransactionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java index d6c2074882..9a5de457b8 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java @@ -87,7 +87,6 @@ public TransactionSynchronization createSynchronizationWithAsyncAfterComplete( Class[] interfaces = { TransactionSynchronization.class }; return (TransactionSynchronization) Proxy.newProxyInstance(synchronization.getClass().getClassLoader(), interfaces, new AsyncAfterCompletionInvocationHandler(synchronization)); - } } From f9f6d3bbaa2c6b829800cf1d3a4aae1a2b6306f5 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:40:40 -0400 Subject: [PATCH 719/933] [tests] Correct commented out test for junit 5 test still doesn't work so leave it commented out. --- .../spring/transaction/SpringTransactionManagerTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java b/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java index 3c22bcb864..66e7453c96 100644 --- a/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java +++ b/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,8 @@ void shouldNoOpWithTx() throws Exception { txManager.commit(status); } + // TODO Test does not compile + // @Disabled // @Test // public void shouldManageWithOtherDatasource() throws Exception { // DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); @@ -53,8 +55,8 @@ void shouldNoOpWithTx() throws Exception { // false); // transaction.commit(); // transaction.close(); - // assertEquals("should call commit on Connection", 1, connection.getNumberCommits()); - // assertTrue("should close the Connection", connection.isClosed()); + // assertEquals(1, connection.getNumberCommits(), "should call commit on Connection"); + // assertTrue(connection.isClosed(), "should close the Connection"); // // txManager.commit(status); // } From 2dd5732c501f51911733faa1299ff748b1f700b6 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:45:16 -0400 Subject: [PATCH 720/933] [test] Add comment about left open resource as spring closes it --- src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java index 59cabcd7c3..9f84fd5b18 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,6 +94,7 @@ void testRollback() { @Test void testExecutorType() { + // Do not close this, spring will close it SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); assertThat(template.getExecutorType()).isEqualTo(ExecutorType.BATCH); From 22d236c66129784af0d9d8407bc07998f2a497b9 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:45:20 -0400 Subject: [PATCH 721/933] [ci] Update copyright date --- .../spring/asyncsynchronization/AsyncAfterCompletionHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java index 9a5de457b8..73ace7f841 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 4cb0ae1f508ec05d66d01a4907e6c12ca67ff4c7 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:54:58 -0400 Subject: [PATCH 722/933] [tests] Update deprecated initMocks to openMocks --- .../org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java | 4 ++-- .../org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java | 4 ++-- .../batch/builder/MyBatisBatchItemWriterBuilderTest.java | 4 ++-- .../batch/builder/MyBatisCursorItemReaderBuilderTest.java | 4 ++-- .../batch/builder/MyBatisPagingItemReaderBuilderTest.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index 827328bbc9..5acbe63f31 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class MyBatisBatchItemWriterTest { @BeforeEach void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index b3a19914f5..0333db4f6c 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ class MyBatisCursorItemReaderTest { @BeforeEach void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index 4b8fe68203..5f50da82d1 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ class MyBatisBatchItemWriterBuilderTest { @BeforeEach void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); { Configuration configuration = new Configuration(); Environment environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index 35363172b6..95e0b04740 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class MyBatisCursorItemReaderBuilderTest { @BeforeEach void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.SIMPLE)).thenReturn(this.sqlSession); Mockito.when(this.cursor.iterator()).thenReturn(getFoos().iterator()); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index b936ede448..5dca993aaa 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ class MyBatisPagingItemReaderBuilderTest { @BeforeEach void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); Configuration configuration = new Configuration(); Environment environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); From e5f7aecf3d725cd0930d2314f8119f06bb8d77a8 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 15:55:18 -0400 Subject: [PATCH 723/933] [test] Update propertyplaceholderconfigurer to propertysourcesplaceholderconfigurer --- .../mybatis/spring/mapper/MapperScannerConfigurerTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index fc1ce5f4b3..a37fd27380 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -40,11 +40,11 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConstructorArgumentValues; -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.SimpleThreadScope; import org.springframework.core.env.MutablePropertySources; import org.springframework.mock.env.MockPropertySource; @@ -305,7 +305,7 @@ void testScanWithExplicitSqlSessionFactoryViaPlaceholder() { props.put("sqlSessionFactoryBeanNameProperty", "sqlSessionFactory2"); GenericBeanDefinition propertyDefinition = new GenericBeanDefinition(); - propertyDefinition.setBeanClass(PropertyPlaceholderConfigurer.class); + propertyDefinition.setBeanClass(PropertySourcesPlaceholderConfigurer.class); propertyDefinition.getPropertyValues().add("properties", props); applicationContext.registerBeanDefinition("propertiesPlaceholder", propertyDefinition); @@ -355,7 +355,7 @@ void testScanWithPropertyPlaceholders() { props.put("mybatis.lazy-initialization", "true"); GenericBeanDefinition propertyDefinition = new GenericBeanDefinition(); - propertyDefinition.setBeanClass(PropertyPlaceholderConfigurer.class); + propertyDefinition.setBeanClass(PropertySourcesPlaceholderConfigurer.class); propertyDefinition.getPropertyValues().add("properties", props); applicationContext.registerBeanDefinition("propertiesPlaceholder", propertyDefinition); From 8639ceb52092b8b42f4bc68bf3580a5ffec1947e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 16:04:44 -0400 Subject: [PATCH 724/933] [tests] Update to java 10 --- .../spring/AbstractMyBatisSpringTest.java | 10 +- .../mybatis/spring/ExecutorInterceptor.java | 2 +- .../MyBatisExceptionTranslatorTest.java | 50 +++++----- .../org/mybatis/spring/MyBatisSpringTest.java | 82 ++++++++-------- .../mybatis/spring/PooledMockDataSource.java | 2 +- .../spring/SqlSessionFactoryBeanTest.java | 95 +++++++++---------- .../spring/SqlSessionTemplateTest.java | 14 +-- .../java/org/mybatis/spring/TestMapper.java | 2 +- .../spring/annotation/MapperScanTest.java | 48 +++++----- .../annotation/factory/SimpleFactoryBean.java | 4 +- .../AsyncAfterCompletionHelper.java | 37 ++++---- .../batch/MyBatisBatchItemWriterTest.java | 6 +- .../batch/MyBatisCursorItemReaderTest.java | 10 +- .../mybatis/spring/batch/SpringBatchTest.java | 18 ++-- .../MyBatisBatchItemWriterBuilderTest.java | 73 +++++++------- .../MyBatisCursorItemReaderBuilderTest.java | 53 +++++------ .../MyBatisPagingItemReaderBuilderTest.java | 75 ++++++++------- .../mybatis/spring/batch/domain/Employee.java | 2 +- .../org/mybatis/spring/config/MyBean.java | 2 +- .../mybatis/spring/config/MyFactoryBean.java | 2 +- .../mybatis/spring/config/NamespaceTest.java | 37 ++++---- .../mybatis/spring/filter/ScanFilterTest.java | 4 +- .../spring/filter/config/AppConfig.java | 8 +- .../filter/customfilter/AnnoTypeFilter.java | 8 +- .../filter/customfilter/CustomTypeFilter.java | 2 +- .../spring/filter/xml/XmlScanFilterTest.java | 5 +- .../spring/mapper/AnnotatedMapper.java | 2 +- .../spring/mapper/MapperFactoryBeanTest.java | 33 ++++--- .../spring/mapper/MapperImplementation.java | 2 +- .../spring/mapper/MapperInterface.java | 2 +- .../mapper/MapperScannerConfigurerTest.java | 54 +++++------ .../spring/mapper/ScopedProxyMapper.java | 2 +- .../mapper/child/MapperChildInterface.java | 2 +- .../spring/sample/AbstractSampleJobTest.java | 26 +++-- .../spring/sample/AbstractSampleTest.java | 5 +- .../spring/sample/SampleBatchTest.java | 2 +- .../spring/sample/SampleEnableTest.java | 2 +- .../spring/sample/SampleJavaConfigTest.java | 7 +- .../sample/SampleJobJavaConfigTest.java | 2 +- .../spring/sample/SampleJobXmlConfigTest.java | 2 +- .../spring/sample/SampleSqlSessionTest.java | 5 +- .../batch/UserToPersonItemProcessor.java | 7 +- .../spring/sample/config/SampleConfig.java | 8 +- .../spring/sample/config/SampleJobConfig.java | 54 +++++------ .../mybatis/spring/sample/dao/UserDao.java | 2 +- .../spring/sample/dao/UserDaoImpl.java | 2 +- .../mybatis/spring/sample/domain/Person.java | 2 +- .../mybatis/spring/sample/domain/User.java | 4 +- .../spring/sample/mapper/UserMapper.java | 2 +- .../spring/sample/service/BarService.java | 2 +- .../spring/sample/service/FooService.java | 2 +- .../org/mybatis/spring/scan/ScanClass1.java | 2 +- .../org/mybatis/spring/scan/ScanClass2.java | 2 +- .../submitted/autowire/AutowireTest.java | 8 +- .../spring/submitted/autowire/BarMapper.java | 2 +- .../spring/submitted/autowire/FooMapper.java | 2 +- .../WebappPlaceholderTest.java | 2 +- .../org/mybatis/spring/submitted/xa/User.java | 2 +- .../spring/submitted/xa/UserMapper.java | 2 +- .../spring/submitted/xa/UserService.java | 2 +- .../spring/submitted/xa/UserServiceImpl.java | 7 +- .../spring/submitted/xa/UserServiceTest.java | 10 +- .../support/SqlSessionDaoSupportTest.java | 10 +- .../SpringTransactionManagerTest.java | 25 ++--- .../spring/type/DummyMapperFactoryBean.java | 7 +- .../mybatis/spring/type/DummyTypeHandler.java | 2 +- .../spring/type/DummyTypeHandler2.java | 2 +- .../spring/type/TypeHandlerFactory.java | 4 +- 68 files changed, 473 insertions(+), 502 deletions(-) diff --git a/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java b/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java index b3b34b4b0b..da41926a10 100644 --- a/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public abstract class AbstractMyBatisSpringTest { @BeforeAll public static void setupBase() throws Exception { // create an SqlSessionFactory that will use SpringManagedTransactions - SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + var factoryBean = new SqlSessionFactoryBean(); factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml")); // note running without SqlSessionFactoryBean.configLocation set => default configuration factoryBean.setDataSource(dataSource); @@ -111,7 +111,7 @@ protected void assertExecuteCount(int count) { protected void assertConnectionClosed(MockConnection connection) { try { - if ((connection != null) && !connection.isClosed()) { + if (connection != null && !connection.isClosed()) { fail("Connection is not closed"); } } catch (SQLException sqle) { @@ -121,10 +121,10 @@ protected void assertConnectionClosed(MockConnection connection) { protected MockConnection createMockConnection() { // this query must be the same as the query in TestMapper.xml - MockResultSet rs = new MockResultSet("SELECT 1"); + var rs = new MockResultSet("SELECT 1"); rs.addRow(new Object[] { 1 }); - MockConnection con = new MockConnection(); + var con = new MockConnection(); con.getPreparedStatementResultSetHandler().prepareResultSet("SELECT 1", rs); return con; diff --git a/src/test/java/org/mybatis/spring/ExecutorInterceptor.java b/src/test/java/org/mybatis/spring/ExecutorInterceptor.java index 1364f0e4d6..fe26fc9711 100644 --- a/src/test/java/org/mybatis/spring/ExecutorInterceptor.java +++ b/src/test/java/org/mybatis/spring/ExecutorInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java b/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java index 62db9e51cf..2a60d343ec 100644 --- a/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java +++ b/src/test/java/org/mybatis/spring/MyBatisExceptionTranslatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,10 @@ */ package org.mybatis.spring; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.times; import com.mockrunner.mock.jdbc.MockDataSource; @@ -25,7 +27,6 @@ import org.apache.ibatis.exceptions.PersistenceException; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.springframework.dao.DataAccessException; import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.jdbc.support.SQLExceptionTranslator; @@ -33,19 +34,19 @@ class MyBatisExceptionTranslatorTest { @Test void shouldNonPersistenceExceptionBeTranslatedToNull() { - MockDataSource mockDataSource = new MockDataSource(); - MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(mockDataSource, false); - DataAccessException e = translator.translateExceptionIfPossible(new RuntimeException()); + var mockDataSource = new MockDataSource(); + var translator = new MyBatisExceptionTranslator(mockDataSource, false); + var e = translator.translateExceptionIfPossible(new RuntimeException()); assertNull(e); } @Test void shouldSqlExceptionBeTranslatedToUncategorizedSqlException() { - String msg = "Error!"; - SQLException sqlException = new SQLException(msg); - SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); - MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); - DataAccessException e = translator.translateExceptionIfPossible(new PersistenceException(sqlException)); + var msg = "Error!"; + var sqlException = new SQLException(msg); + var sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + var translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + var e = translator.translateExceptionIfPossible(new PersistenceException(sqlException)); assertTrue(e instanceof UncategorizedSQLException); Mockito.verify(sqlExceptionTranslator, times(1)).translate(SQLException.class.getName() + ": " + msg + "\n", null, sqlException); @@ -53,20 +54,20 @@ void shouldSqlExceptionBeTranslatedToUncategorizedSqlException() { @Test void shouldPersistenceExceptionBeTranslatedToMyBatisSystemException() { - String msg = "Error!"; - SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); - MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); - DataAccessException e = translator.translateExceptionIfPossible(new PersistenceException(msg)); + var msg = "Error!"; + var sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + var translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + var e = translator.translateExceptionIfPossible(new PersistenceException(msg)); assertTrue(e instanceof MyBatisSystemException); assertEquals(msg, e.getMessage()); } @Test void shouldNestedPersistenceExceptionReportsMsgOfParentException() { - String msg = "Error!"; - SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); - MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); - DataAccessException e = translator + var msg = "Error!"; + var sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + var translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + var e = translator .translateExceptionIfPossible(new PersistenceException(msg, new PersistenceException("Inner error!"))); assertTrue(e instanceof MyBatisSystemException); assertEquals(msg, e.getMessage()); @@ -74,11 +75,10 @@ void shouldNestedPersistenceExceptionReportsMsgOfParentException() { @Test void shouldNestedPersistenceExceptionReportsMsgOfChildExceptionIfParentsMsgIsNull() { - String msg = "Error!"; - SQLExceptionTranslator sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); - MyBatisExceptionTranslator translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); - DataAccessException e = translator - .translateExceptionIfPossible(new PersistenceException(null, new PersistenceException(msg))); + var msg = "Error!"; + var sqlExceptionTranslator = Mockito.mock(SQLExceptionTranslator.class); + var translator = new MyBatisExceptionTranslator(() -> sqlExceptionTranslator, false); + var e = translator.translateExceptionIfPossible(new PersistenceException(null, new PersistenceException(msg))); assertTrue(e instanceof MyBatisSystemException); assertEquals(msg, e.getMessage()); } diff --git a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java index fda8ebf659..4e5f8d2827 100644 --- a/src/test/java/org/mybatis/spring/MyBatisSpringTest.java +++ b/src/test/java/org/mybatis/spring/MyBatisSpringTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class MyBatisSpringTest extends AbstractMyBatisSpringTest { @AfterEach void validateSessionClose() { // assume if the Executor is closed, the Session is too - if ((session != null) && !executorInterceptor.isExecutorClosed()) { + if (session != null && !executorInterceptor.isExecutorClosed()) { session = null; fail("SqlSession is not closed"); } else { @@ -140,8 +140,8 @@ void testSpringAPIWithMyBatisClose() { // Spring API should work with a MyBatis TransactionFactories @Test void testWithNonSpringTransactionFactory() { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); - Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); + var nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); try { @@ -162,8 +162,8 @@ void testWithNonSpringTransactionFactory() { // this should not work since the DS will be out of sync with MyBatis @Test void testNonSpringTxFactoryWithTx() throws Exception { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); - Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); + var nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); TransactionStatus status = null; @@ -186,12 +186,12 @@ void testNonSpringTxFactoryWithTx() throws Exception { // this should work since the DS is managed MyBatis @Test void testNonSpringTxFactoryNonSpringDSWithTx() throws java.sql.SQLException { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); - MockDataSource mockDataSource = new MockDataSource(); + var mockDataSource = new MockDataSource(); mockDataSource.setupConnection(createMockConnection()); - Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), mockDataSource); + var nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), mockDataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); TransactionStatus status; @@ -211,7 +211,7 @@ void testNonSpringTxFactoryNonSpringDSWithTx() throws java.sql.SQLException { // SqlSession uses its own connection // that connection will not have committed since no SQL was executed by the session - MockConnection mockConnection = (MockConnection) mockDataSource.getConnection(); + var mockConnection = (MockConnection) mockDataSource.getConnection(); assertThat(mockConnection.getNumberCommits()).as("should call commit on Connection").isEqualTo(0); assertThat(mockConnection.getNumberRollbacks()).as("should not call rollback on Connection").isEqualTo(0); assertCommitSession(); @@ -248,16 +248,16 @@ void testChangeExecutorTypeInTxRequiresNew() throws Exception { try { txManager.setDataSource(dataSource); - TransactionStatus status = txManager.getTransaction(new DefaultTransactionDefinition()); + var status = txManager.getTransaction(new DefaultTransactionDefinition()); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); // start a new tx while the other is in progress - DefaultTransactionDefinition txRequiresNew = new DefaultTransactionDefinition(); + var txRequiresNew = new DefaultTransactionDefinition(); txRequiresNew.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW"); - TransactionStatus status2 = txManager.getTransaction(txRequiresNew); + var status2 = txManager.getTransaction(txRequiresNew); - SqlSession session2 = SqlSessionUtils.getSqlSession(sqlSessionFactory, ExecutorType.BATCH, exceptionTranslator); + var session2 = SqlSessionUtils.getSqlSession(sqlSessionFactory, ExecutorType.BATCH, exceptionTranslator); SqlSessionUtils.closeSqlSession(session2, sqlSessionFactory); txManager.rollback(status2); @@ -277,12 +277,12 @@ void testChangeExecutorTypeInTxRequiresNew() throws Exception { @Test void testWithJtaTxManager() { - JtaTransactionManager jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class)); + var jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class)); - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = jtaManager.getTransaction(txDef); + var status = jtaManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); @@ -298,20 +298,20 @@ void testWithJtaTxManager() { @Test void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); - MockDataSource mockDataSource = new MockDataSource(); + var mockDataSource = new MockDataSource(); mockDataSource.setupConnection(createMockConnection()); - Environment nonSpring = new Environment("non-spring", new ManagedTransactionFactory(), mockDataSource); + var nonSpring = new Environment("non-spring", new ManagedTransactionFactory(), mockDataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); - JtaTransactionManager jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class)); + var jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class)); - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = jtaManager.getTransaction(txDef); + var status = jtaManager.getTransaction(txDef); try { session = SqlSessionUtils.getSqlSession(sqlSessionFactory); @@ -326,7 +326,7 @@ void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException { assertNoCommitJdbc(); assertCommitSession(); - MockConnection mockConnection = (MockConnection) mockDataSource.getConnection(); + var mockConnection = (MockConnection) mockDataSource.getConnection(); assertThat(mockConnection.getNumberCommits()).as("should call commit on Connection").isEqualTo(0); assertThat(mockConnection.getNumberRollbacks()).as("should not call rollback on Connection").isEqualTo(0); @@ -345,10 +345,10 @@ void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException { @Test void testWithTxSupports() { - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_SUPPORTS"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); @@ -363,10 +363,10 @@ void testWithTxSupports() { @Test void testRollbackWithTxSupports() { - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_SUPPORTS"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); @@ -381,10 +381,10 @@ void testRollbackWithTxSupports() { @Test void testWithTxRequired() { - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); @@ -399,10 +399,10 @@ void testWithTxRequired() { @Test void testSqlSessionCommitWithTx() { - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); session.getMapper(TestMapper.class).findTest(); @@ -429,7 +429,7 @@ void testWithInterleavedTx() { session.getMapper(TestMapper.class).findTest(); // this transaction should use another Connection - TransactionStatus status = txManager.getTransaction(new DefaultTransactionDefinition()); + var status = txManager.getTransaction(new DefaultTransactionDefinition()); // session continues using original connection session.getMapper(TestMapper.class).insertTest("test2"); @@ -463,16 +463,16 @@ void testSuspendAndResume() { try { txManager.setDataSource(dataSource); - TransactionStatus status = txManager.getTransaction(new DefaultTransactionDefinition()); + var status = txManager.getTransaction(new DefaultTransactionDefinition()); session = SqlSessionUtils.getSqlSession(sqlSessionFactory); // start a new tx while the other is in progress - DefaultTransactionDefinition txRequiresNew = new DefaultTransactionDefinition(); + var txRequiresNew = new DefaultTransactionDefinition(); txRequiresNew.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW"); - TransactionStatus status2 = txManager.getTransaction(txRequiresNew); + var status2 = txManager.getTransaction(txRequiresNew); - SqlSession session2 = SqlSessionUtils.getSqlSession(sqlSessionFactory); + var session2 = SqlSessionUtils.getSqlSession(sqlSessionFactory); assertThat(session).as("getSqlSession() should not return suspended SqlSession").isNotSameAs(session2); @@ -535,10 +535,10 @@ void testBatch() { void testBatchInTx() { setupBatchStatements(); - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory, ExecutorType.BATCH, exceptionTranslator); @@ -577,10 +577,10 @@ void testBatchWithError() { void testBatchInTxWithError() { setupBatchStatements(); - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); session = SqlSessionUtils.getSqlSession(sqlSessionFactory, ExecutorType.BATCH, exceptionTranslator); diff --git a/src/test/java/org/mybatis/spring/PooledMockDataSource.java b/src/test/java/org/mybatis/spring/PooledMockDataSource.java index b07eaf3600..6493d019c1 100644 --- a/src/test/java/org/mybatis/spring/PooledMockDataSource.java +++ b/src/test/java/org/mybatis/spring/PooledMockDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 33cfb618f8..f79f561c20 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -41,10 +41,7 @@ import org.apache.ibatis.plugin.Invocation; import org.apache.ibatis.plugin.Signature; import org.apache.ibatis.reflection.factory.DefaultObjectFactory; -import org.apache.ibatis.reflection.factory.ObjectFactory; import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; -import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory; -import org.apache.ibatis.scripting.LanguageDriverRegistry; import org.apache.ibatis.scripting.defaults.RawLanguageDriver; import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver; import org.apache.ibatis.session.Configuration; @@ -55,10 +52,8 @@ import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.EnumOrdinalTypeHandler; import org.apache.ibatis.type.JdbcType; -import org.apache.ibatis.type.TypeAliasRegistry; import org.apache.ibatis.type.TypeException; import org.apache.ibatis.type.TypeHandler; -import org.apache.ibatis.type.TypeHandlerRegistry; import org.junit.jupiter.api.Test; import org.mybatis.core.jdk.type.AtomicNumberTypeHandler; import org.mybatis.spring.transaction.SpringManagedTransactionFactory; @@ -152,11 +147,11 @@ void testDefaultConfiguration() throws Exception { void testDefaultConfigurationWithConfigurationProperties() throws Exception { setupFactoryBean(); - Properties configurationProperties = new Properties(); + var configurationProperties = new Properties(); configurationProperties.put("username", "dev"); factoryBean.setConfigurationProperties(configurationProperties); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertConfig(factory, SpringManagedTransactionFactory.class); assertThat(factory.getConfiguration().getVariables().size()).isEqualTo(1); assertThat(factory.getConfiguration().getVariables().get("username")).isEqualTo("dev"); @@ -166,14 +161,14 @@ void testDefaultConfigurationWithConfigurationProperties() throws Exception { void testSetConfiguration() throws Exception { setupFactoryBean(); - Configuration customConfiguration = new Configuration(); + var customConfiguration = new Configuration(); customConfiguration.setCacheEnabled(false); customConfiguration.setUseGeneratedKeys(true); customConfiguration.setDefaultExecutorType(ExecutorType.REUSE); customConfiguration.setVfsImpl(JBoss6VFS.class); factoryBean.setConfiguration(customConfiguration); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertThat(factory.getConfiguration().getEnvironment().getId()) .isEqualTo(SqlSessionFactoryBean.class.getSimpleName()); @@ -191,15 +186,15 @@ void testSetConfiguration() throws Exception { void testSpecifyVariablesOnly() throws Exception { setupFactoryBean(); - Configuration customConfiguration = new Configuration(); - Properties variables = new Properties(); + var customConfiguration = new Configuration(); + var variables = new Properties(); variables.put("username", "sa"); customConfiguration.setVariables(variables); factoryBean.setConfiguration(customConfiguration); factoryBean.setConfigurationProperties(null); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertThat(factory.getConfiguration().getVariables().size()).isEqualTo(1); assertThat(factory.getConfiguration().getVariables().get("username")).isEqualTo("sa"); @@ -209,19 +204,19 @@ void testSpecifyVariablesOnly() throws Exception { void testSpecifyVariablesAndConfigurationProperties() throws Exception { setupFactoryBean(); - Configuration customConfiguration = new Configuration(); - Properties variables = new Properties(); + var customConfiguration = new Configuration(); + var variables = new Properties(); variables.put("url", "jdbc:localhost/test"); variables.put("username", "sa"); customConfiguration.setVariables(variables); factoryBean.setConfiguration(customConfiguration); - Properties configurationProperties = new Properties(); + var configurationProperties = new Properties(); configurationProperties.put("username", "dev"); configurationProperties.put("password", "Passw0rd"); factoryBean.setConfigurationProperties(configurationProperties); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertThat(factory.getConfiguration().getVariables().size()).isEqualTo(3); assertThat(factory.getConfiguration().getVariables().get("url")).isEqualTo("jdbc:localhost/test"); @@ -233,15 +228,15 @@ void testSpecifyVariablesAndConfigurationProperties() throws Exception { void testSpecifyConfigurationPropertiesOnly() throws Exception { setupFactoryBean(); - Configuration customConfiguration = new Configuration(); + var customConfiguration = new Configuration(); customConfiguration.setVariables(null); factoryBean.setConfiguration(customConfiguration); - Properties configurationProperties = new Properties(); + var configurationProperties = new Properties(); configurationProperties.put("username", "dev"); factoryBean.setConfigurationProperties(configurationProperties); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertThat(factory.getConfiguration().getVariables().size()).isEqualTo(1); assertThat(factory.getConfiguration().getVariables().get("username")).isEqualTo("dev"); @@ -251,13 +246,13 @@ void testSpecifyConfigurationPropertiesOnly() throws Exception { void testNotSpecifyVariableAndConfigurationProperties() throws Exception { setupFactoryBean(); - Configuration customConfiguration = new Configuration(); + var customConfiguration = new Configuration(); customConfiguration.setVariables(null); factoryBean.setConfiguration(customConfiguration); factoryBean.setConfigurationProperties(null); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertThat(factory.getConfiguration().getVariables()).isNull(); } @@ -277,7 +272,7 @@ void testSetConfigLocation() throws Exception { factoryBean.setConfigLocation(new ClassPathResource("org/mybatis/spring/mybatis-config.xml")); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); assertThat(factory.getConfiguration().getEnvironment().getId()) .isEqualTo(SqlSessionFactoryBean.class.getSimpleName()); @@ -317,7 +312,7 @@ void testFragmentsAreReadWithMapperLocations() throws Exception { factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml")); - SqlSessionFactory factory = factoryBean.getObject(); + var factory = factoryBean.getObject(); // one for 'includedSql' and another for 'org.mybatis.spring.TestMapper.includedSql' assertThat(factory.getConfiguration().getSqlFragments().size()).isEqualTo(2); @@ -353,7 +348,7 @@ void testAddATypeHandler() throws Exception { setupFactoryBean(); factoryBean.setTypeHandlers(new DummyTypeHandler()); - TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); + var typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); } @@ -362,7 +357,7 @@ void testAddATypeAlias() throws Exception { setupFactoryBean(); factoryBean.setTypeAliases(DummyTypeAlias.class); - TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); + var typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias"); } @@ -371,7 +366,7 @@ void testSearchATypeAliasPackage() throws Exception { setupFactoryBean(); factoryBean.setTypeAliasesPackage("org.mybatis.spring.type, org.mybatis.spring.scan"); - TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); + var typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); System.out.println(typeAliasRegistry.getTypeAliases().keySet()); assertThat(typeAliasRegistry.getTypeAliases().size()).isEqualTo(89); typeAliasRegistry.resolveAlias("testAlias"); @@ -391,7 +386,7 @@ void testSearchATypeAliasPackageWithSuperType() throws Exception { factoryBean.setTypeAliasesSuperType(SuperType.class); factoryBean.setTypeAliasesPackage("org.mybatis.*.type"); - TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); + var typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias2"); typeAliasRegistry.resolveAlias("superType"); @@ -404,7 +399,7 @@ void testSearchATypeAliasPackageWithSamePackage() throws Exception { setupFactoryBean(); factoryBean.setTypeAliasesPackage("org.mybatis.spring.type, org.*.spring.type"); - TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); + var typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias"); typeAliasRegistry.resolveAlias("testAlias2"); typeAliasRegistry.resolveAlias("dummyTypeHandler"); @@ -416,7 +411,7 @@ void testSearchATypeHandlerPackage() throws Exception { setupFactoryBean(); factoryBean.setTypeHandlersPackage("org.mybatis.**.type"); - TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); + var typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); assertThat(typeHandlerRegistry.hasTypeHandler(BigDecimal.class)).isTrue(); assertThat(typeHandlerRegistry.getTypeHandler(UUID.class)).isInstanceOf(TypeHandlerFactory.InnerTypeHandler.class); @@ -429,7 +424,7 @@ void testSearchATypeHandlerPackageWithSamePackage() throws Exception { setupFactoryBean(); factoryBean.setTypeHandlersPackage("org.mybatis.spring.type, org.mybatis.*.type"); - TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); + var typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); assertThat(typeHandlerRegistry.hasTypeHandler(BigDecimal.class)).isTrue(); } @@ -439,7 +434,7 @@ void testDefaultEnumTypeHandler() throws Exception { setupFactoryBean(); factoryBean.setDefaultEnumTypeHandler(EnumOrdinalTypeHandler.class); - TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); + var typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.getTypeHandler(MyEnum.class)).isInstanceOf(EnumOrdinalTypeHandler.class); } @@ -448,7 +443,7 @@ void testSetObjectFactory() throws Exception { setupFactoryBean(); factoryBean.setObjectFactory(new TestObjectFactory()); - ObjectFactory objectFactory = factoryBean.getObject().getConfiguration().getObjectFactory(); + var objectFactory = factoryBean.getObject().getConfiguration().getObjectFactory(); assertThat(objectFactory).isInstanceOf(TestObjectFactory.class); } @@ -457,14 +452,14 @@ void testSetObjectWrapperFactory() throws Exception { setupFactoryBean(); factoryBean.setObjectWrapperFactory(new TestObjectWrapperFactory()); - ObjectWrapperFactory objectWrapperFactory = factoryBean.getObject().getConfiguration().getObjectWrapperFactory(); + var objectWrapperFactory = factoryBean.getObject().getConfiguration().getObjectWrapperFactory(); assertThat(objectWrapperFactory).isInstanceOf(TestObjectWrapperFactory.class); } @Test void testAddCache() { setupFactoryBean(); - PerpetualCache cache = new PerpetualCache("test-cache"); + var cache = new PerpetualCache("test-cache"); this.factoryBean.setCache(cache); assertThat(this.factoryBean.getCache().getId()).isEqualTo("test-cache"); } @@ -473,7 +468,7 @@ void testAddCache() { void testScriptingLanguageDriverEmpty() throws Exception { setupFactoryBean(); this.factoryBean.setScriptingLanguageDrivers(); - LanguageDriverRegistry registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); + var registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); assertThat(registry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); assertThat(registry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); } @@ -482,7 +477,7 @@ void testScriptingLanguageDriverEmpty() throws Exception { void testScriptingLanguageDriver() throws Exception { setupFactoryBean(); this.factoryBean.setScriptingLanguageDrivers(new MyLanguageDriver1(), new MyLanguageDriver2()); - LanguageDriverRegistry registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); + var registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); assertThat(registry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); assertThat(registry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); assertThat(registry.getDriver(MyLanguageDriver1.class)).isNotNull(); @@ -496,7 +491,7 @@ void testScriptingLanguageDriverWithDefault() throws Exception { setupFactoryBean(); this.factoryBean.setScriptingLanguageDrivers(new MyLanguageDriver1(), new MyLanguageDriver2()); this.factoryBean.setDefaultScriptingLanguageDriver(MyLanguageDriver1.class); - LanguageDriverRegistry registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); + var registry = this.factoryBean.getObject().getConfiguration().getLanguageRegistry(); assertThat(registry.getDefaultDriver()).isInstanceOf(MyLanguageDriver1.class); assertThat(registry.getDefaultDriverClass()).isEqualTo(MyLanguageDriver1.class); assertThat(registry.getDriver(MyLanguageDriver1.class)).isNotNull(); @@ -526,10 +521,10 @@ void testAppendableMethod() throws Exception { this.factoryBean.addTypeHandlers(null); this.factoryBean.addTypeAliases(null); this.factoryBean.addMapperLocations(null); - SqlSessionFactory factory = this.factoryBean.getObject(); - LanguageDriverRegistry languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); - TypeHandlerRegistry typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); - TypeAliasRegistry typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); + var factory = this.factoryBean.getObject(); + var languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); + var typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); + var typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); assertThat(languageDriverRegistry.getDriver(MyLanguageDriver1.class)).isNotNull(); assertThat(languageDriverRegistry.getDriver(MyLanguageDriver2.class)).isNotNull(); assertThat(typeHandlerRegistry.getTypeHandlers().stream().map(TypeHandler::getClass).map(Class::getSimpleName) @@ -555,10 +550,10 @@ void testAppendableMethodWithEmpty() throws Exception { this.factoryBean.addTypeHandlers(); this.factoryBean.addTypeAliases(); this.factoryBean.addMapperLocations(); - SqlSessionFactory factory = this.factoryBean.getObject(); - LanguageDriverRegistry languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); - TypeHandlerRegistry typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); - TypeAliasRegistry typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); + var factory = this.factoryBean.getObject(); + var languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); + var typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); + var typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); assertThat(languageDriverRegistry.getDriver(MyLanguageDriver1.class)).isNull(); assertThat(languageDriverRegistry.getDriver(MyLanguageDriver2.class)).isNull(); assertThat(typeHandlerRegistry.getTypeHandlers()).hasSize(40); @@ -575,10 +570,10 @@ void testAppendableMethodWithNull() throws Exception { this.factoryBean.addTypeHandlers(null); this.factoryBean.addTypeAliases(null); this.factoryBean.addMapperLocations(null); - SqlSessionFactory factory = this.factoryBean.getObject(); - LanguageDriverRegistry languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); - TypeHandlerRegistry typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); - TypeAliasRegistry typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); + var factory = this.factoryBean.getObject(); + var languageDriverRegistry = factory.getConfiguration().getLanguageRegistry(); + var typeHandlerRegistry = factory.getConfiguration().getTypeHandlerRegistry(); + var typeAliasRegistry = factory.getConfiguration().getTypeAliasRegistry(); assertThat(languageDriverRegistry.getDriver(MyLanguageDriver1.class)).isNull(); assertThat(languageDriverRegistry.getDriver(MyLanguageDriver2.class)).isNull(); assertThat(typeHandlerRegistry.getTypeHandlers()).hasSize(40); @@ -682,7 +677,7 @@ private static class MyTypeHandler2 extends MyBaseTypeHandler { private static class MyTypeHandler3 extends MyBaseTypeHandler { } - private static enum MyEnum { + private enum MyEnum { } } diff --git a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java index 9f84fd5b18..f89e7777c9 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java @@ -53,7 +53,7 @@ void tearDown() { @Test void testGetConnection() throws java.sql.SQLException { - java.sql.Connection conn = sqlSessionTemplate.getConnection(); + var conn = sqlSessionTemplate.getConnection(); // outside of an explicit tx, getConnection() will start a tx, get an open connection then // end the tx, which closes the connection @@ -67,7 +67,7 @@ void testGetConnectionInTx() throws java.sql.SQLException { try { status = txManager.getTransaction(new DefaultTransactionDefinition()); - java.sql.Connection conn = sqlSessionTemplate.getConnection(); + var conn = sqlSessionTemplate.getConnection(); assertThat(conn.isClosed()).isFalse(); @@ -95,10 +95,10 @@ void testRollback() { @Test void testExecutorType() { // Do not close this, spring will close it - SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); + var template = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH); assertThat(template.getExecutorType()).isEqualTo(ExecutorType.BATCH); - DataSourceTransactionManager manager = new DataSourceTransactionManager(dataSource); + var manager = new DataSourceTransactionManager(dataSource); TransactionStatus status = null; @@ -108,7 +108,7 @@ void testExecutorType() { // will synchronize the template with the current tx template.getConnection(); - SqlSessionHolder holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sqlSessionFactory); + var holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sqlSessionFactory); assertThat(holder.getExecutorType()).isEqualTo(ExecutorType.BATCH); } finally { @@ -168,10 +168,10 @@ void testTemplateWithNoTxSelect() { @Test void testWithTxRequired() { - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); sqlSessionTemplate.getMapper(TestMapper.class).findTest(); diff --git a/src/test/java/org/mybatis/spring/TestMapper.java b/src/test/java/org/mybatis/spring/TestMapper.java index 0a839fc57d..df5f0fa375 100644 --- a/src/test/java/org/mybatis/spring/TestMapper.java +++ b/src/test/java/org/mybatis/spring/TestMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java index 51338fff0e..6dbefd9491 100644 --- a/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java +++ b/src/test/java/org/mybatis/spring/annotation/MapperScanTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -220,7 +220,7 @@ void testCustomMapperFactoryBean() { @Test void testScanWithNameConflict() { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(Object.class); applicationContext.registerBeanDefinition("mapperInterface", definition); @@ -233,7 +233,7 @@ void testScanWithNameConflict() { } private void setupSqlSessionFactory() { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); definition.getPropertyValues().add("dataSource", new MockDataSource()); applicationContext.registerBeanDefinition("sqlSessionFactory", definition); @@ -263,9 +263,9 @@ void testScanWithExplicitSqlSessionFactory() { @Test void testScanWithExplicitSqlSessionTemplate() { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionTemplate.class); - ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues(); + var constructorArgs = new ConstructorArgumentValues(); constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory")); definition.setConstructorArgumentValues(constructorArgs); applicationContext.registerBeanDefinition("sqlSessionTemplate", definition); @@ -298,7 +298,7 @@ void testScanWithMapperScans() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); applicationContext.getBean("ds1Mapper"); @@ -311,7 +311,7 @@ void testScanWithDefaultMapperScanAndRepeat() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); applicationContext.getBean("ds1Mapper"); @@ -324,7 +324,7 @@ void testScanWithDefaultMapperScans() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); applicationContext.getBean("ds1Mapper"); @@ -337,7 +337,7 @@ void testLazyScanWithPropertySourcesPlaceholderConfigurer() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(0, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); applicationContext.getBean(Ds1Mapper.class); assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); @@ -350,7 +350,7 @@ void testLazyConfigWithPropertySource() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(0, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); applicationContext.getBean(Ds1Mapper.class); assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); @@ -369,25 +369,25 @@ void testScopedProxyMapperScanByDefaultScope() { for (String scopedProxyTargetBean : scopedProxyTargetBeans) { { - BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean); + var definition = applicationContext.getBeanDefinition(scopedProxyTargetBean); assertThat(definition.getBeanClassName()).isEqualTo("org.mybatis.spring.mapper.MapperFactoryBean"); assertThat(definition.getScope()).isEqualTo("thread"); } { - BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean.substring(13)); + var definition = applicationContext.getBeanDefinition(scopedProxyTargetBean.substring(13)); assertThat(definition.getBeanClassName()).isEqualTo("org.springframework.aop.scope.ScopedProxyFactoryBean"); assertThat(definition.getScope()).isEqualTo(""); } } { - Ds1Mapper mapper = applicationContext.getBean(Ds1Mapper.class); + var mapper = applicationContext.getBean(Ds1Mapper.class); assertThat(mapper.test()).isEqualTo("ds1"); } { - Ds2Mapper mapper = applicationContext.getBean(Ds2Mapper.class); + var mapper = applicationContext.getBean(Ds2Mapper.class); assertThat(mapper.test()).isEqualTo("ds2"); } - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); } @@ -397,10 +397,10 @@ void testProcessPropertyPlaceHoldersIsTrue() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); - MyBean myBean = applicationContext.getBean(MyBean.class); + var myBean = applicationContext.getBean(MyBean.class); assertThat(myBean.getName()).isEqualTo("MyBean!!"); } @@ -410,10 +410,10 @@ void testProcessPropertyPlaceHoldersIsFalse() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); - MyBean myBean = applicationContext.getBean(MyBean.class); + var myBean = applicationContext.getBean(MyBean.class); assertThat(myBean.getName()).isEqualTo("MyBean!!"); } @@ -479,7 +479,7 @@ public static class AppConfigWithMapperScans { public static class LazyConfigWithPropertySourcesPlaceholderConfigurer { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + var configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/annotation/scan.properties")); return configurer; } @@ -491,14 +491,14 @@ static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer public static class ProcessPropertyPlaceHoldersTrueConfiguration { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + var configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/annotation/placeholders.properties")); return configurer; } @Bean static PropertyOverrideConfigurer propertyOverrideConfigurer() { - PropertyOverrideConfigurer configurer = new PropertyOverrideConfigurer(); + var configurer = new PropertyOverrideConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/annotation/override.properties")); configurer.setIgnoreInvalidKeys(true); return configurer; @@ -515,14 +515,14 @@ MyBean myBean() { public static class ProcessPropertyPlaceHoldersFalseConfiguration { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + var configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/annotation/placeholders.properties")); return configurer; } @Bean static PropertyOverrideConfigurer propertyOverrideConfigurer() { - PropertyOverrideConfigurer configurer = new PropertyOverrideConfigurer(); + var configurer = new PropertyOverrideConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/annotation/override.properties")); return configurer; } diff --git a/src/test/java/org/mybatis/spring/annotation/factory/SimpleFactoryBean.java b/src/test/java/org/mybatis/spring/annotation/factory/SimpleFactoryBean.java index 412b87331a..5f496fdc64 100644 --- a/src/test/java/org/mybatis/spring/annotation/factory/SimpleFactoryBean.java +++ b/src/test/java/org/mybatis/spring/annotation/factory/SimpleFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,10 +37,12 @@ public SimpleFactoryBean(ApplicationContext context) { } } + @Override public Object getObject() { return new Object(); } + @Override public Class getObjectType() { return Object.class; } diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java index 73ace7f841..ec928f6655 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java @@ -46,29 +46,28 @@ static class AsyncAfterCompletionInvocationHandler implements InvocationHandler @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - if ("afterCompletion".equals(method.getName())) { - final Set retValSet = new HashSet<>(); - final Set exceptionSet = new HashSet<>(); - Thread thread = new Thread(() -> { - try { - retValSet.add(method.invoke(target, args)); - } catch (InvocationTargetException ite) { - exceptionSet.add(ite.getCause()); + if (!"afterCompletion".equals(method.getName())) { + return method.invoke(target, args); + } + final Set retValSet = new HashSet<>(); + final Set exceptionSet = new HashSet<>(); + var thread = new Thread(() -> { + try { + retValSet.add(method.invoke(target, args)); + } catch (InvocationTargetException ite) { + exceptionSet.add(ite.getCause()); - } catch (IllegalArgumentException | IllegalAccessException e) { - exceptionSet.add(e); + } catch (IllegalArgumentException | IllegalAccessException e) { + exceptionSet.add(e); - } - }); - thread.start(); - thread.join(); - if (exceptionSet.isEmpty()) { - return retValSet.iterator().next(); - } else { - throw exceptionSet.iterator().next(); } + }); + thread.start(); + thread.join(); + if (exceptionSet.isEmpty()) { + return retValSet.iterator().next(); } else { - return method.invoke(target, args); + throw exceptionSet.iterator().next(); } } diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index 5acbe63f31..c38083996d 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -71,7 +71,7 @@ void testZeroBatchResultShouldThrowException() { void testZeroUpdateCountShouldThrowException() { Chunk employees = Chunk.of(new Employee(), new Employee()); - BatchResult batchResult = new BatchResult(null, null); + var batchResult = new BatchResult(null, null); batchResult.setUpdateCounts(new int[] { 1, 0 }); List batchResults = Collections.singletonList(batchResult); @@ -85,7 +85,7 @@ void testItemToParameterConverterIsDefault() { this.writer.setAssertUpdates(false); this.writer.setStatementId("updateEmployee"); - Employee employee = new Employee(); + var employee = new Employee(); Chunk employees = Chunk.of(employee); writer.write(employees); @@ -103,7 +103,7 @@ void testSetItemToParameterConverter() { return parameter; }); - Employee employee = new Employee(); + var employee = new Employee(); Chunk employees = Chunk.of(employee); writer.write(employees); diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index 0333db4f6c..44f061ce62 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -61,13 +61,13 @@ void testCloseOnFailing() throws Exception { Mockito.when(this.sqlSession.selectCursor("selectFoo", Collections.singletonMap("id", 1))) .thenThrow(new RuntimeException("error.")); - MyBatisCursorItemReader itemReader = new MyBatisCursorItemReader<>(); + var itemReader = new MyBatisCursorItemReader(); itemReader.setSqlSessionFactory(this.sqlSessionFactory); itemReader.setQueryId("selectFoo"); itemReader.setParameterValues(Collections.singletonMap("id", 1)); itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); try { itemReader.open(executionContext); fail(); @@ -82,7 +82,7 @@ void testCloseOnFailing() throws Exception { @Test void testCloseBeforeOpen() { - MyBatisCursorItemReader itemReader = new MyBatisCursorItemReader<>(); + var itemReader = new MyBatisCursorItemReader(); itemReader.close(); } @@ -96,10 +96,6 @@ private static class Foo { Foo(String name) { this.name = name; } - - public String getName() { - return this.name; - } } } diff --git a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java index a27f0ad3a1..f2eb2034d4 100644 --- a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java +++ b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,8 +54,8 @@ class SpringBatchTest { @Test @Transactional void shouldDuplicateSalaryOfAllEmployees() throws Exception { - Chunk employees = new Chunk<>(); - Employee employee = pagingNoNestedItemReader.read(); + var employees = new Chunk(); + var employee = pagingNoNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); employees.add(employee); @@ -71,8 +71,8 @@ void shouldDuplicateSalaryOfAllEmployees() throws Exception { @Transactional void checkPagingReadingWithNestedInResultMap() throws Exception { // This test is here to show that PagingReader can return wrong result in case of nested result maps - Chunk employees = new Chunk<>(); - Employee employee = pagingNestedItemReader.read(); + var employees = new Chunk(); + var employee = pagingNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); employees.add(employee); @@ -89,8 +89,8 @@ void checkPagingReadingWithNestedInResultMap() throws Exception { void checkCursorReadingWithoutNestedInResultMap() throws Exception { cursorNoNestedItemReader.doOpen(); try { - Chunk employees = new Chunk<>(); - Employee employee = cursorNoNestedItemReader.read(); + var employees = new Chunk(); + var employee = cursorNoNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); employees.add(employee); @@ -110,8 +110,8 @@ void checkCursorReadingWithoutNestedInResultMap() throws Exception { void checkCursorReadingWithNestedInResultMap() throws Exception { cursorNestedItemReader.doOpen(); try { - Chunk employees = new Chunk<>(); - Employee employee = cursorNestedItemReader.read(); + var employees = new Chunk(); + var employee = cursorNestedItemReader.read(); while (employee != null) { employee.setSalary(employee.getSalary() * 2); employees.add(employee); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index 5f50da82d1..6076ba4da5 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -38,7 +38,6 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mybatis.spring.SqlSessionTemplate; -import org.mybatis.spring.batch.MyBatisBatchItemWriter; import org.springframework.batch.item.Chunk; /** @@ -63,14 +62,14 @@ class MyBatisBatchItemWriterBuilderTest { void setUp() { MockitoAnnotations.openMocks(this); { - Configuration configuration = new Configuration(); - Environment environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); + var configuration = new Configuration(); + var environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); configuration.setEnvironment(environment); Mockito.when(this.sqlSessionFactory.getConfiguration()).thenReturn(configuration); Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.BATCH)).thenReturn(this.sqlSession); } { - BatchResult result = new BatchResult(null, null); + var result = new BatchResult(null, null); result.setUpdateCounts(new int[] { 1 }); Mockito.when(this.sqlSession.flushStatements()).thenReturn(Collections.singletonList(result)); } @@ -80,14 +79,14 @@ void setUp() { void testConfigurationUsingSqlSessionFactory() { // @formatter:off - MyBatisBatchItemWriter itemWriter = new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .statementId("updateFoo") - .build(); - // @formatter:on + var itemWriter = new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .statementId("updateFoo") + .build(); + // @formatter:on itemWriter.afterPropertiesSet(); - Chunk foos = getFoos(); + var foos = getFoos(); itemWriter.write(foos); @@ -101,14 +100,14 @@ void testConfigurationUsingSqlSessionFactory() { void testConfigurationUsingSqlSessionTemplate() { // @formatter:off - MyBatisBatchItemWriter itemWriter = new MyBatisBatchItemWriterBuilder() - .sqlSessionTemplate(new SqlSessionTemplate(this.sqlSessionFactory, ExecutorType.BATCH)) - .statementId("updateFoo") - .build(); - // @formatter:on + var itemWriter = new MyBatisBatchItemWriterBuilder() + .sqlSessionTemplate(new SqlSessionTemplate(this.sqlSessionFactory, ExecutorType.BATCH)) + .statementId("updateFoo") + .build(); + // @formatter:on itemWriter.afterPropertiesSet(); - Chunk foos = getFoos(); + var foos = getFoos(); itemWriter.write(foos); @@ -124,15 +123,15 @@ void testConfigurationAssertUpdatesIsFalse() { Mockito.when(this.sqlSession.flushStatements()).thenReturn(Collections.emptyList()); // @formatter:off - MyBatisBatchItemWriter itemWriter = new MyBatisBatchItemWriterBuilder() - .sqlSessionTemplate(new SqlSessionTemplate(this.sqlSessionFactory, ExecutorType.BATCH)) - .statementId("updateFoo") - .assertUpdates(false) - .build(); - // @formatter:on + var itemWriter = new MyBatisBatchItemWriterBuilder() + .sqlSessionTemplate(new SqlSessionTemplate(this.sqlSessionFactory, ExecutorType.BATCH)) + .statementId("updateFoo") + .assertUpdates(false) + .build(); + // @formatter:on itemWriter.afterPropertiesSet(); - Chunk foos = getFoos(); + var foos = getFoos(); itemWriter.write(foos); @@ -146,20 +145,20 @@ void testConfigurationAssertUpdatesIsFalse() { void testConfigurationSetItemToParameterConverter() { // @formatter:off - MyBatisBatchItemWriter itemWriter = new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .statementId("updateFoo") - .itemToParameterConverter(item -> { - Map parameter = new HashMap<>(); - parameter.put("item", item); - parameter.put("now", LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); - return parameter; - }) - .build(); - // @formatter:on + var itemWriter = new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .statementId("updateFoo") + .itemToParameterConverter(item -> { + Map parameter = new HashMap<>(); + parameter.put("item", item); + parameter.put("now", LocalDateTime.now(Clock.fixed(Instant.ofEpochMilli(0), ZoneId.systemDefault()))); + return parameter; + }) + .build(); + // @formatter:on itemWriter.afterPropertiesSet(); - Chunk foos = getFoos(); + var foos = getFoos(); itemWriter.write(foos); @@ -183,10 +182,6 @@ private static class Foo { Foo(String name) { this.name = name; } - - public String getName() { - return this.name; - } } } diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index 95e0b04740..dbad275cd8 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -31,7 +31,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mybatis.spring.batch.MyBatisCursorItemReader; import org.springframework.batch.item.ExecutionContext; /** @@ -68,16 +67,16 @@ void setUp() { void testConfiguration() throws Exception { // @formatter:off - MyBatisCursorItemReader itemReader = new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .build(); - // @formatter:on + var itemReader = new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); @@ -95,17 +94,17 @@ void testConfiguration() throws Exception { void testConfigurationSaveStateIsFalse() throws Exception { // @formatter:off - MyBatisCursorItemReader itemReader = new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .saveState(false) - .build(); - // @formatter:on + var itemReader = new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .saveState(false) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); @@ -121,17 +120,17 @@ void testConfigurationSaveStateIsFalse() throws Exception { void testConfigurationMaxItemCount() throws Exception { // @formatter:off - MyBatisCursorItemReader itemReader = new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .maxItemCount(2) - .build(); - // @formatter:on + var itemReader = new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .maxItemCount(2) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index 5dca993aaa..e1f1961f04 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -35,7 +35,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mybatis.spring.batch.MyBatisPagingItemReader; import org.springframework.batch.item.ExecutionContext; /** @@ -60,8 +59,8 @@ class MyBatisPagingItemReaderBuilderTest { void setUp() { MockitoAnnotations.openMocks(this); - Configuration configuration = new Configuration(); - Environment environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); + var configuration = new Configuration(); + var environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); configuration.setEnvironment(environment); Mockito.when(this.sqlSessionFactory.getConfiguration()).thenReturn(configuration); Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.BATCH)).thenReturn(this.sqlSession); @@ -77,16 +76,16 @@ void setUp() { @Test void testConfiguration() throws Exception { // @formatter:off - MyBatisPagingItemReader itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); @@ -103,17 +102,17 @@ void testConfiguration() throws Exception { @Test void testConfigurationSaveStateIsFalse() throws Exception { // @formatter:off - MyBatisPagingItemReader itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .saveState(false) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .saveState(false) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); @@ -127,17 +126,17 @@ void testConfigurationSaveStateIsFalse() throws Exception { @Test void testConfigurationMaxItemCount() throws Exception { // @formatter:off - MyBatisPagingItemReader itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .maxItemCount(2) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .maxItemCount(2) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); @@ -152,14 +151,14 @@ void testConfigurationMaxItemCount() throws Exception { @Test void testConfigurationPageSize() throws Exception { // @formatter:off - MyBatisPagingItemReader itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .pageSize(2) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .pageSize(2) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); Map parameters = new HashMap<>(); @@ -170,7 +169,7 @@ void testConfigurationPageSize() throws Exception { parameters.put("_skiprows", 0); Mockito.when(this.sqlSession.selectList("selectFoo", parameters)).thenReturn(getFoos()); - ExecutionContext executionContext = new ExecutionContext(); + var executionContext = new ExecutionContext(); itemReader.open(executionContext); Assertions.assertThat(itemReader.read()).extracting(Foo::getName).isEqualTo("foo1"); diff --git a/src/test/java/org/mybatis/spring/batch/domain/Employee.java b/src/test/java/org/mybatis/spring/batch/domain/Employee.java index 6cd26f9d80..228e9f2828 100644 --- a/src/test/java/org/mybatis/spring/batch/domain/Employee.java +++ b/src/test/java/org/mybatis/spring/batch/domain/Employee.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/config/MyBean.java b/src/test/java/org/mybatis/spring/config/MyBean.java index c597da2455..baa49e5c54 100644 --- a/src/test/java/org/mybatis/spring/config/MyBean.java +++ b/src/test/java/org/mybatis/spring/config/MyBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/config/MyFactoryBean.java b/src/test/java/org/mybatis/spring/config/MyFactoryBean.java index 7227f811f4..a6bb655ce2 100644 --- a/src/test/java/org/mybatis/spring/config/MyFactoryBean.java +++ b/src/test/java/org/mybatis/spring/config/MyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/config/NamespaceTest.java b/src/test/java/org/mybatis/spring/config/NamespaceTest.java index 3a6293d921..3ec0616ebb 100644 --- a/src/test/java/org/mybatis/spring/config/NamespaceTest.java +++ b/src/test/java/org/mybatis/spring/config/NamespaceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ void testInterfaceScan() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(5, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); // all interfaces with methods should be loaded @@ -220,7 +220,7 @@ void testLazy() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(0, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); // all interfaces with methods should be loaded @@ -247,27 +247,26 @@ void testDefaultScope() { for (String scopedProxyTargetBean : scopedProxyTargetBeans) { { - BeanDefinition definition = applicationContext.getBeanFactory().getBeanDefinition(scopedProxyTargetBean); + var definition = applicationContext.getBeanFactory().getBeanDefinition(scopedProxyTargetBean); assertThat(definition.getBeanClassName()).isEqualTo("org.mybatis.spring.mapper.MapperFactoryBean"); assertThat(definition.getScope()).isEqualTo("thread"); } { - BeanDefinition definition = applicationContext.getBeanFactory() - .getBeanDefinition(scopedProxyTargetBean.substring(13)); + var definition = applicationContext.getBeanFactory().getBeanDefinition(scopedProxyTargetBean.substring(13)); assertThat(definition.getBeanClassName()).isEqualTo("org.springframework.aop.scope.ScopedProxyFactoryBean"); assertThat(definition.getScope()).isEqualTo(""); } } { - ScopedProxyMapper mapper = applicationContext.getBean(ScopedProxyMapper.class); + var mapper = applicationContext.getBean(ScopedProxyMapper.class); assertThat(mapper.test()).isEqualTo("test"); } { - AnnotatedMapper mapper = applicationContext.getBean(AnnotatedMapper.class); + var mapper = applicationContext.getBean(AnnotatedMapper.class); assertThat(mapper.test()).isEqualTo("main"); } - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); } @@ -279,10 +278,10 @@ void processPropertyPlaceHoldersIsTrue() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(5, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); - MyBean myBean = applicationContext.getBean("myBean", MyBean.class); + var myBean = applicationContext.getBean("myBean", MyBean.class); assertThat(myBean.getName()).isEqualTo("MyBean!!"); } @@ -295,19 +294,19 @@ void processPropertyPlaceHoldersIsFalse() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(5, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); - MyBean myBean = applicationContext.getBean("myBean", MyBean.class); + var myBean = applicationContext.getBean("myBean", MyBean.class); assertThat(myBean.getName()).isEqualTo("MyBean!!"); } private GenericApplicationContext setupSqlSessionTemplate() { - GenericApplicationContext genericApplicationContext = setupSqlSessionFactory(); - GenericBeanDefinition definition = new GenericBeanDefinition(); + var genericApplicationContext = setupSqlSessionFactory(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionTemplate.class); - ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues(); + var constructorArgs = new ConstructorArgumentValues(); constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory")); definition.setConstructorArgumentValues(constructorArgs); genericApplicationContext.registerBeanDefinition("sqlSessionTemplate", definition); @@ -316,13 +315,13 @@ private GenericApplicationContext setupSqlSessionTemplate() { private GenericApplicationContext setupSqlSessionFactory() { - GenericApplicationContext genericApplicationContext = new GenericApplicationContext(); + var genericApplicationContext = new GenericApplicationContext(); - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); definition.getPropertyValues().add("dataSource", new MockDataSource()); - DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); + var factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("sqlSessionFactory", definition); genericApplicationContext.registerBeanDefinition("sqlSessionFactory", definition); diff --git a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 76a96a7baf..1cb984c765 100644 --- a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -214,7 +214,7 @@ private void startContext(Class config) { } private void setupSqlSessionFactory(String name) { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); definition.getPropertyValues().add("dataSource", new MockDataSource()); applicationContext.registerBeanDefinition(name, definition); diff --git a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java index f331e2d8ce..88990b6ca9 100644 --- a/src/test/java/org/mybatis/spring/filter/config/AppConfig.java +++ b/src/test/java/org/mybatis/spring/filter/config/AppConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ public static class AspectJFilterConfig { public static class CombinedFilterConfig { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + var configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/filter/config/application.properties")); return configurer; } @@ -115,7 +115,7 @@ public static class RegexFilterWithPlaceHolderConfig { public static class RegexFilterWithPlaceHolderConfig1 { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + var configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/filter/config/application.properties")); return configurer; } @@ -127,7 +127,7 @@ static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer public static class ProcessPropertyPlaceHoldersOffConfig { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); + var configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("/org/mybatis/spring/filter/config/application.properties")); return configurer; } diff --git a/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java b/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java index e32715a1c7..2b3ee06b7d 100644 --- a/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/AnnoTypeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,11 @@ */ package org.mybatis.spring.filter.customfilter; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE }) diff --git a/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java b/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java index 52f8e05875..c149c13aef 100644 --- a/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java +++ b/src/test/java/org/mybatis/spring/filter/customfilter/CustomTypeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java index 237e3d1d8d..f0fd88e5fd 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,7 +155,8 @@ private void startContext(String config) { } private void closeContext() { - if (null != applicationContext) + if (null != applicationContext) { applicationContext.close(); + } } } diff --git a/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java b/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java index 129fdf3420..b1f6686bf7 100644 --- a/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java +++ b/src/test/java/org/mybatis/spring/mapper/AnnotatedMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java index 25aa1e7759..9654f43a04 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import com.mockrunner.mock.jdbc.MockDataSource; import org.apache.ibatis.mapping.Environment; -import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -59,13 +58,13 @@ void testBasicUsage() throws Exception { void testAddToConfigTrue() throws Exception { // the default SqlSessionFactory in AbstractMyBatisSpringTest is created with an explicitly set // MapperLocations list, so create a new factory here that tests auto-loading the config - SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + var factoryBean = new SqlSessionFactoryBean(); factoryBean.setDatabaseIdProvider(null); // mapperLocations properties defaults to null factoryBean.setDataSource(dataSource); factoryBean.setPlugins(executorInterceptor); - SqlSessionFactory sqlSessionFactory = factoryBean.getObject(); + var sqlSessionFactory = factoryBean.getObject(); find(new SqlSessionTemplate(sqlSessionFactory), true); assertCommit(); // SqlSesssionTemplate autocommits @@ -80,11 +79,11 @@ void testAddToConfigFalse() throws Throwable { // the default SqlSessionFactory in AbstractMyBatisSpringTest is created with an explicitly // set MapperLocations list, so create a new factory here that tests auto-loading the // config - SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + var factoryBean = new SqlSessionFactoryBean(); // mapperLocations properties defaults to null factoryBean.setDataSource(dataSource); - SqlSessionFactory sqlSessionFactory = factoryBean.getObject(); + var sqlSessionFactory = factoryBean.getObject(); assertThrows(org.apache.ibatis.binding.BindingException.class, () -> find(new SqlSessionTemplate(sqlSessionFactory), false)); @@ -100,7 +99,7 @@ void testAddToConfigFalse() throws Throwable { @Test void testWithTx() throws Exception { - TransactionStatus status = txManager.getTransaction(new DefaultTransactionDefinition()); + var status = txManager.getTransaction(new DefaultTransactionDefinition()); find(); @@ -115,8 +114,8 @@ void testWithTx() throws Exception { // transaction @Test void testWithNonSpringTransactionFactory() throws Exception { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); - Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); + var nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); try { @@ -135,8 +134,8 @@ void testWithNonSpringTransactionFactory() throws Exception { // this should error @Test void testNonSpringTxMgrWithTx() throws Exception { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); - Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); + var nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), dataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); TransactionStatus status = null; @@ -162,15 +161,15 @@ void testNonSpringTxMgrWithTx() throws Exception { // similar to testNonSpringTxFactoryNonSpringDSWithTx() in MyBatisSpringTest @Test void testNonSpringWithTx() throws Exception { - Environment original = sqlSessionFactory.getConfiguration().getEnvironment(); + var original = sqlSessionFactory.getConfiguration().getEnvironment(); - MockDataSource mockDataSource = new MockDataSource(); + var mockDataSource = new MockDataSource(); mockDataSource.setupConnection(createMockConnection()); - Environment nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), mockDataSource); + var nonSpring = new Environment("non-spring", new JdbcTransactionFactory(), mockDataSource); sqlSessionFactory.getConfiguration().setEnvironment(nonSpring); - SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory); + var sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory); TransactionStatus status; @@ -186,7 +185,7 @@ void testNonSpringWithTx() throws Exception { assertSingleConnection(); // SqlSessionTemplate uses its own connection - MockConnection mockConnection = (MockConnection) mockDataSource.getConnection(); + var mockConnection = (MockConnection) mockDataSource.getConnection(); assertThat(mockConnection.getNumberCommits()).as("should call commit on Connection").isEqualTo(1); assertThat(mockConnection.getNumberRollbacks()).as("should not call rollback on Connection").isEqualTo(0); assertCommitSession(); @@ -207,7 +206,7 @@ private void find(SqlSessionTemplate sqlSessionTemplate) throws Exception { private void find(SqlSessionTemplate sqlSessionTemplate, boolean addToConfig) throws Exception { // recreate the mapper for each test since sqlSessionTemplate or the underlying // SqlSessionFactory could change for each test - MapperFactoryBean mapper = new MapperFactoryBean<>(); + var mapper = new MapperFactoryBean(); mapper.setMapperInterface(TestMapper.class); mapper.setSqlSessionTemplate(sqlSessionTemplate); mapper.setAddToConfig(addToConfig); diff --git a/src/test/java/org/mybatis/spring/mapper/MapperImplementation.java b/src/test/java/org/mybatis/spring/mapper/MapperImplementation.java index b5ad8bec2e..409bd04607 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperImplementation.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperImplementation.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/mapper/MapperInterface.java b/src/test/java/org/mybatis/spring/mapper/MapperInterface.java index d9c5dc970d..545f3a62f8 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperInterface.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperInterface.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java index a37fd27380..c2de7a5c02 100644 --- a/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java +++ b/src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java @@ -23,7 +23,6 @@ import com.mockrunner.mock.jdbc.MockDataSource; import java.util.List; -import java.util.Properties; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -46,7 +45,6 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.SimpleThreadScope; -import org.springframework.core.env.MutablePropertySources; import org.springframework.mock.env.MockPropertySource; import org.springframework.stereotype.Component; @@ -60,7 +58,7 @@ void setupContext() { // add the mapper scanner as a bean definition rather than explicitly setting a // postProcessor on the context so initialization follows the same code path as reading from // an XML config file - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(MapperScannerConfigurer.class); definition.getPropertyValues().add("basePackage", "org.mybatis.spring.mapper"); applicationContext.registerBeanDefinition("mapperScanner", definition); @@ -98,7 +96,7 @@ void assertNoMapperClass() { void testInterfaceScan() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(5, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); @@ -126,7 +124,7 @@ void testInterfaceScan() { @Test void testNameGenerator() { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(BeanNameGenerator.class); applicationContext.registerBeanDefinition("beanNameGenerator", definition); @@ -193,29 +191,29 @@ void testScopedProxyMapperScan() { startContext(); { - BeanDefinition definition = applicationContext.getBeanDefinition("scopedProxyMapper"); + var definition = applicationContext.getBeanDefinition("scopedProxyMapper"); assertThat(definition.getBeanClassName()).isEqualTo("org.springframework.aop.scope.ScopedProxyFactoryBean"); assertThat(definition.getScope()).isEqualTo(""); } { - BeanDefinition definition = applicationContext.getBeanDefinition("scopedTarget.scopedProxyMapper"); + var definition = applicationContext.getBeanDefinition("scopedTarget.scopedProxyMapper"); assertThat(definition.getBeanClassName()).isEqualTo("org.mybatis.spring.mapper.MapperFactoryBean"); assertThat(definition.getScope()).isEqualTo("thread"); } { - ScopedProxyMapper mapper = applicationContext.getBean(ScopedProxyMapper.class); + var mapper = applicationContext.getBean(ScopedProxyMapper.class); assertThat(mapper.test()).isEqualTo("test"); } { - ScopedProxyMapper mapper = applicationContext.getBean("scopedTarget.scopedProxyMapper", ScopedProxyMapper.class); + var mapper = applicationContext.getBean("scopedTarget.scopedProxyMapper", ScopedProxyMapper.class); assertThat(mapper.test()).isEqualTo("test"); } { - ScopedProxyMapper mapper = applicationContext.getBean("scopedProxyMapper", ScopedProxyMapper.class); + var mapper = applicationContext.getBean("scopedProxyMapper", ScopedProxyMapper.class); assertThat(mapper.test()).isEqualTo("test"); } - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); } @@ -233,26 +231,26 @@ void testScopedProxyMapperScanByDefault() { for (String scopedProxyTargetBean : scopedProxyTargetBeans) { { - BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean); + var definition = applicationContext.getBeanDefinition(scopedProxyTargetBean); assertThat(definition.getBeanClassName()).isEqualTo("org.mybatis.spring.mapper.MapperFactoryBean"); assertThat(definition.getScope()).isEqualTo("thread"); } { - BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean.substring(13)); + var definition = applicationContext.getBeanDefinition(scopedProxyTargetBean.substring(13)); assertThat(definition.getBeanClassName()).isEqualTo("org.springframework.aop.scope.ScopedProxyFactoryBean"); assertThat(definition.getScope()).isEqualTo(""); } } { - ScopedProxyMapper mapper = applicationContext.getBean(ScopedProxyMapper.class); + var mapper = applicationContext.getBean(ScopedProxyMapper.class); assertThat(mapper.test()).isEqualTo("test"); } { - AnnotatedMapper mapper = applicationContext.getBean(AnnotatedMapper.class); + var mapper = applicationContext.getBean(AnnotatedMapper.class); assertThat(mapper.test()).isEqualTo("main"); } - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); } @@ -274,9 +272,9 @@ void testScanWithExplicitSqlSessionFactory() { @Test void testScanWithExplicitSqlSessionTemplate() { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionTemplate.class); - ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues(); + var constructorArgs = new ConstructorArgumentValues(); constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory")); definition.setConstructorArgumentValues(constructorArgs); applicationContext.registerBeanDefinition("sqlSessionTemplate", definition); @@ -301,10 +299,10 @@ void testScanWithExplicitSqlSessionFactoryViaPlaceholder() { applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add("sqlSessionFactoryBeanName", "${sqlSessionFactoryBeanNameProperty}"); - Properties props = new java.util.Properties(); + var props = new java.util.Properties(); props.put("sqlSessionFactoryBeanNameProperty", "sqlSessionFactory2"); - GenericBeanDefinition propertyDefinition = new GenericBeanDefinition(); + var propertyDefinition = new GenericBeanDefinition(); propertyDefinition.setBeanClass(PropertySourcesPlaceholderConfigurer.class); propertyDefinition.getPropertyValues().add("properties", props); @@ -321,7 +319,7 @@ void testScanWithExplicitSqlSessionFactoryViaPlaceholder() { @Test void testScanWithNameConflict() { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(Object.class); applicationContext.registerBeanDefinition("mapperInterface", definition); @@ -333,7 +331,7 @@ void testScanWithNameConflict() { @Test void testScanWithPropertyPlaceholders() { - GenericBeanDefinition definition = (GenericBeanDefinition) applicationContext.getBeanDefinition("mapperScanner"); + var definition = (GenericBeanDefinition) applicationContext.getBeanDefinition("mapperScanner"); // use a property placeholder for basePackage definition.getPropertyValues().removePropertyValue("basePackage"); @@ -349,12 +347,12 @@ void testScanWithPropertyPlaceholders() { definition.getPropertyValues().removePropertyValue("configLocation"); definition.getPropertyValues().add("configLocation", "${configLocationProperty}"); - Properties props = new java.util.Properties(); + var props = new java.util.Properties(); props.put("basePackageProperty", "org.mybatis.spring.mapper"); props.put("configLocationProperty", "classpath:org/mybatis/spring/mybatis-config.xml"); props.put("mybatis.lazy-initialization", "true"); - GenericBeanDefinition propertyDefinition = new GenericBeanDefinition(); + var propertyDefinition = new GenericBeanDefinition(); propertyDefinition.setBeanClass(PropertySourcesPlaceholderConfigurer.class); propertyDefinition.getPropertyValues().add("properties", props); @@ -362,7 +360,7 @@ void testScanWithPropertyPlaceholders() { startContext(); - SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); + var sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class); System.out.println(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()); assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); @@ -376,7 +374,7 @@ void testScanWithPropertyPlaceholders() { // make sure the configLocation was setup correctly // mybatis-config.xml changes the executor from the default SIMPLE type - SqlSessionFactory sessionFactory = (SqlSessionFactory) applicationContext.getBean("sqlSessionFactory"); + var sessionFactory = (SqlSessionFactory) applicationContext.getBean("sqlSessionFactory"); assertThat(sessionFactory.getConfiguration().getDefaultExecutorType()).isSameAs(ExecutorType.REUSE); } @@ -406,7 +404,7 @@ void testMapperBeanAttribute() { @Test void testMapperBeanOnConditionalProperties() { - MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources(); + var propertySources = applicationContext.getEnvironment().getPropertySources(); propertySources.addLast(new MockPropertySource().withProperty("mapper.condition", "true")); startContext(); @@ -417,7 +415,7 @@ void testMapperBeanOnConditionalProperties() { } private void setupSqlSessionFactory(String name) { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); definition.getPropertyValues().add("dataSource", new MockDataSource()); applicationContext.registerBeanDefinition(name, definition); diff --git a/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java b/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java index c07ec1a0d3..6294408eee 100644 --- a/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java +++ b/src/test/java/org/mybatis/spring/mapper/ScopedProxyMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/mapper/child/MapperChildInterface.java b/src/test/java/org/mybatis/spring/mapper/child/MapperChildInterface.java index a540f16613..51b4523ce8 100644 --- a/src/test/java/org/mybatis/spring/mapper/child/MapperChildInterface.java +++ b/src/test/java/org/mybatis/spring/mapper/child/MapperChildInterface.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java index 8f17d16183..b076e29469 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,11 @@ */ package org.mybatis.spring.sample; -import java.util.List; -import java.util.Map; - import javax.sql.DataSource; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -42,17 +38,17 @@ abstract class AbstractSampleJobTest { @Test void testJob() throws Exception { - JobExecution jobExecution = jobLauncherTestUtils.launchJob(); + var jobExecution = jobLauncherTestUtils.launchJob(); Assertions.assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode()); - List> persons = jdbcTemplate.queryForList("SELECT * FROM persons ORDER BY person_id", + var persons = jdbcTemplate.queryForList("SELECT * FROM persons ORDER BY person_id", EmptySqlParameterSource.INSTANCE); Assertions.assertEquals(5, persons.size()); - Object operationBy = persons.get(0).get("OPERATION_BY"); - Object operationAt = persons.get(0).get("OPERATION_AT"); + var operationBy = persons.get(0).get("OPERATION_BY"); + var operationAt = persons.get(0).get("OPERATION_AT"); { - Map person = persons.get(0); + var person = persons.get(0); Assertions.assertEquals(0, person.get("PERSON_ID")); Assertions.assertEquals("Pocoyo", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); @@ -60,7 +56,7 @@ void testJob() throws Exception { Assertions.assertNotNull(operationAt); } { - Map person = persons.get(1); + var person = persons.get(1); Assertions.assertEquals(1, person.get("PERSON_ID")); Assertions.assertEquals("Pato", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); @@ -68,7 +64,7 @@ void testJob() throws Exception { Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } { - Map person = persons.get(2); + var person = persons.get(2); Assertions.assertEquals(2, person.get("PERSON_ID")); Assertions.assertEquals("Eli", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); @@ -76,7 +72,7 @@ void testJob() throws Exception { Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } { - Map person = persons.get(3); + var person = persons.get(3); Assertions.assertEquals(3, person.get("PERSON_ID")); Assertions.assertEquals("Valentina", person.get("FIRST_NAME")); Assertions.assertNull(person.get("LAST_NAME")); @@ -84,7 +80,7 @@ void testJob() throws Exception { Assertions.assertEquals(operationAt, person.get("OPERATION_AT")); } { - Map person = persons.get(4); + var person = persons.get(4); Assertions.assertEquals(4, person.get("PERSON_ID")); Assertions.assertEquals("Taro", person.get("FIRST_NAME")); Assertions.assertEquals("Yamada", person.get("LAST_NAME")); @@ -99,7 +95,7 @@ void testJob() throws Exception { static class LocalContext { @Bean JobLauncherTestUtils jobLauncherTestUtils(Job job) { - JobLauncherTestUtils utils = new JobLauncherTestUtils(); + var utils = new JobLauncherTestUtils(); utils.setJob(job); return utils; } diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java index 577f555305..3c3309e2f7 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -import org.mybatis.spring.sample.domain.User; import org.mybatis.spring.sample.service.FooService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -31,7 +30,7 @@ abstract class AbstractSampleTest { @Test final void testFooService() { - User user = this.fooService.doSomeBusinessStuff("u1"); + var user = this.fooService.doSomeBusinessStuff("u1"); assertThat(user).isNotNull(); assertThat(user.getName()).isEqualTo("Pocoyo"); } diff --git a/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java b/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java index 1e2d7febff..3c0c49629d 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleBatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java b/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java index 1555387e33..f11d76a370 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleEnableTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java index fd7b4526be..61b1c890e8 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJavaConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; import org.mybatis.spring.sample.config.SampleConfig; -import org.mybatis.spring.sample.domain.User; import org.mybatis.spring.sample.service.FooService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -38,13 +37,13 @@ class SampleJavaConfigTest { @Test void test() { - User user = fooService.doSomeBusinessStuff("u1"); + var user = fooService.doSomeBusinessStuff("u1"); assertThat(user.getName()).isEqualTo("Pocoyo"); } @Test void testWithMapperFactoryBean() { - User user = fooServiceWithMapperFactoryBean.doSomeBusinessStuff("u1"); + var user = fooServiceWithMapperFactoryBean.doSomeBusinessStuff("u1"); assertThat(user.getName()).isEqualTo("Pocoyo"); } diff --git a/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java index 7f6c32c699..82713606b6 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJobJavaConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java b/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java index 7dfe2f3691..937adcbacd 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleJobXmlConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java index c8750d6cc9..da0cbfedb2 100644 --- a/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java +++ b/src/test/java/org/mybatis/spring/sample/SampleSqlSessionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -import org.mybatis.spring.sample.domain.User; import org.mybatis.spring.sample.service.BarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -37,7 +36,7 @@ class SampleSqlSessionTest { @Test void testFooService() { - User user = this.barService.doSomeBusinessStuff("u1"); + var user = this.barService.doSomeBusinessStuff("u1"); assertThat(user).isNotNull(); assertThat(user.getName()).isEqualTo("Pocoyo"); } diff --git a/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java b/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java index 293b04b068..b09e21f13d 100644 --- a/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java +++ b/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,11 @@ public class UserToPersonItemProcessor implements ItemProcessor { @Override public Person process(final User user) throws Exception { - final String[] names = user.getName().split(" "); + final var names = user.getName().split(" "); if (names.length == 1) { return new Person(names[0], null); - } else { - return new Person(names[0], names[1]); } + return new Person(names[0], names[1]); } } diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java index 20ff578288..c5419b54de 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public PlatformTransactionManager transactionalManager() { @Bean public SqlSessionFactory sqlSessionFactory() throws Exception { - SqlSessionFactoryBean ss = new SqlSessionFactoryBean(); + var ss = new SqlSessionFactoryBean(); ss.setDataSource(dataSource()); ss.setMapperLocations(new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml")); return ss.getObject(); @@ -56,13 +56,13 @@ public SqlSessionFactory sqlSessionFactory() throws Exception { @Bean public UserMapper userMapper() throws Exception { // when using javaconfig a template requires less lines than a MapperFactoryBean - SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); + var sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory()); return sqlSessionTemplate.getMapper(UserMapper.class); } @Bean public UserMapper userMapperWithFactory() throws Exception { - MapperFactoryBean mapperFactoryBean = new MapperFactoryBean<>(); + var mapperFactoryBean = new MapperFactoryBean(); mapperFactoryBean.setMapperInterface(UserMapper.class); mapperFactoryBean.setSqlSessionFactory(sqlSessionFactory()); mapperFactoryBean.afterPropertiesSet(); diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java index d951605dc9..8c6fbd8e12 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,11 +69,11 @@ public PlatformTransactionManager transactionManager(DataSource dataSource) { @Bean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { - PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); - SqlSessionFactoryBean ss = new SqlSessionFactoryBean(); + var resourcePatternResolver = new PathMatchingResourcePatternResolver(); + var ss = new SqlSessionFactoryBean(); ss.setDataSource(dataSource); ss.setMapperLocations(resourcePatternResolver.getResources("org/mybatis/spring/sample/mapper/*.xml")); - org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration(); + var configuration = new org.apache.ibatis.session.Configuration(); configuration.setDefaultExecutorType(ExecutorType.BATCH); ss.setConfiguration(configuration); return ss.getObject(); @@ -82,11 +82,11 @@ public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Excepti @Bean public MyBatisCursorItemReader reader(SqlSessionFactory sqlSessionFactory) { // @formatter:off - return new MyBatisCursorItemReaderBuilder() - .sqlSessionFactory(sqlSessionFactory) - .queryId("org.mybatis.spring.sample.mapper.UserMapper.getUsers") - .build(); - // @formatter:on + return new MyBatisCursorItemReaderBuilder() + .sqlSessionFactory(sqlSessionFactory) + .queryId("org.mybatis.spring.sample.mapper.UserMapper.getUsers") + .build(); + // @formatter:on } @Bean @@ -97,12 +97,12 @@ public UserToPersonItemProcessor processor() { @Bean public MyBatisBatchItemWriter writer(SqlSessionFactory sqlSessionFactory) { // @formatter:off - return new MyBatisBatchItemWriterBuilder() - .sqlSessionFactory(sqlSessionFactory) - .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") - .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) - .build(); - // @formatter:on + return new MyBatisBatchItemWriterBuilder() + .sqlSessionFactory(sqlSessionFactory) + .statementId("org.mybatis.spring.sample.mapper.PersonMapper.createPerson") + .itemToParameterConverter(createItemToParameterMapConverter("batch_java_config_user", LocalDateTime.now())) + .build(); + // @formatter:on } public static Converter> createItemToParameterMapConverter(String operationBy, @@ -119,24 +119,24 @@ public static Converter> createItemToParameterMapConv @Bean public Job importUserJob(JobRepository jobRepository, Step step1) { // @formatter:off - return new JobBuilder("importUserJob", jobRepository) - .flow(step1) - .end() - .build(); - // @formatter:on + return new JobBuilder("importUserJob", jobRepository) + .flow(step1) + .end() + .build(); + // @formatter:on } @Bean public Step step1(JobRepository jobRepository, PlatformTransactionManager transactionManager, ItemReader reader, ItemProcessor processor, ItemWriter writer) { // @formatter:off - return new StepBuilder("step1", jobRepository) - .chunk(10, transactionManager) - .reader(reader) - .processor(processor) - .writer(writer) - .build(); - // @formatter:on + return new StepBuilder("step1", jobRepository) + .chunk(10, transactionManager) + .reader(reader) + .processor(processor) + .writer(writer) + .build(); + // @formatter:on } } diff --git a/src/test/java/org/mybatis/spring/sample/dao/UserDao.java b/src/test/java/org/mybatis/spring/sample/dao/UserDao.java index 4ce3693efa..39e0ce608d 100644 --- a/src/test/java/org/mybatis/spring/sample/dao/UserDao.java +++ b/src/test/java/org/mybatis/spring/sample/dao/UserDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/dao/UserDaoImpl.java b/src/test/java/org/mybatis/spring/sample/dao/UserDaoImpl.java index 27276f1f8e..794d142752 100644 --- a/src/test/java/org/mybatis/spring/sample/dao/UserDaoImpl.java +++ b/src/test/java/org/mybatis/spring/sample/dao/UserDaoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/domain/Person.java b/src/test/java/org/mybatis/spring/sample/domain/Person.java index ec5a9eea2a..71c1352d3d 100644 --- a/src/test/java/org/mybatis/spring/sample/domain/Person.java +++ b/src/test/java/org/mybatis/spring/sample/domain/Person.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/domain/User.java b/src/test/java/org/mybatis/spring/sample/domain/User.java index 346d6e10e3..95fc9df6f1 100644 --- a/src/test/java/org/mybatis/spring/sample/domain/User.java +++ b/src/test/java/org/mybatis/spring/sample/domain/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public void setName(String name) { @Override public String toString() { - StringBuilder buf = new StringBuilder(30); + var buf = new StringBuilder(30); buf.append("{"); buf.append(id); buf.append(", "); diff --git a/src/test/java/org/mybatis/spring/sample/mapper/UserMapper.java b/src/test/java/org/mybatis/spring/sample/mapper/UserMapper.java index 13252a5242..0308a28a6e 100644 --- a/src/test/java/org/mybatis/spring/sample/mapper/UserMapper.java +++ b/src/test/java/org/mybatis/spring/sample/mapper/UserMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/service/BarService.java b/src/test/java/org/mybatis/spring/sample/service/BarService.java index 24182f91ab..640e37e12c 100644 --- a/src/test/java/org/mybatis/spring/sample/service/BarService.java +++ b/src/test/java/org/mybatis/spring/sample/service/BarService.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/sample/service/FooService.java b/src/test/java/org/mybatis/spring/sample/service/FooService.java index 8bd39db806..1ff450b2f6 100644 --- a/src/test/java/org/mybatis/spring/sample/service/FooService.java +++ b/src/test/java/org/mybatis/spring/sample/service/FooService.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/scan/ScanClass1.java b/src/test/java/org/mybatis/spring/scan/ScanClass1.java index 6734fd7732..169ad00c85 100644 --- a/src/test/java/org/mybatis/spring/scan/ScanClass1.java +++ b/src/test/java/org/mybatis/spring/scan/ScanClass1.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/scan/ScanClass2.java b/src/test/java/org/mybatis/spring/scan/ScanClass2.java index e139e2d940..5c73725f03 100644 --- a/src/test/java/org/mybatis/spring/scan/ScanClass2.java +++ b/src/test/java/org/mybatis/spring/scan/ScanClass2.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java b/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java index d8b0a0d92f..5c348c0698 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/AutowireTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +24,14 @@ class AutowireTest { @Test void shouldReturnMapper() { - try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + try (var context = new ClassPathXmlApplicationContext( "classpath:org/mybatis/spring/submitted/autowire/spring.xml")) { - FooMapper fooMapper = (FooMapper) context.getBean("fooMapper"); + var fooMapper = (FooMapper) context.getBean("fooMapper"); assertThat(fooMapper).isNotNull(); fooMapper.executeFoo(); - BarMapper barMapper = (BarMapper) context.getBean("barMapper"); + var barMapper = (BarMapper) context.getBean("barMapper"); assertThat(barMapper).isNotNull(); barMapper.executeBar(); } diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/BarMapper.java b/src/test/java/org/mybatis/spring/submitted/autowire/BarMapper.java index 35d9dc7177..6ecced0f0e 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/BarMapper.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/BarMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java b/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java index 71b2bd84af..b711bbbf9b 100644 --- a/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java +++ b/src/test/java/org/mybatis/spring/submitted/autowire/FooMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java index 838bdf1966..c50cdb94a9 100644 --- a/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java +++ b/src/test/java/org/mybatis/spring/submitted/webapp_placeholder/WebappPlaceholderTest.java @@ -41,7 +41,7 @@ class WebappPlaceholderTest { @Test void testName() { Assertions.assertEquals(0, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); - Mapper mapper = applicationContext.getBean(Mapper.class); + var mapper = applicationContext.getBean(Mapper.class); assertThat(mapper).isNotNull(); Assertions.assertEquals(1, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size()); } diff --git a/src/test/java/org/mybatis/spring/submitted/xa/User.java b/src/test/java/org/mybatis/spring/submitted/xa/User.java index 8915696f92..c27dabaa95 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/User.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserMapper.java b/src/test/java/org/mybatis/spring/submitted/xa/UserMapper.java index f630b7bbfd..151969e96f 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserMapper.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserService.java b/src/test/java/org/mybatis/spring/submitted/xa/UserService.java index 5110a91c37..f28c790cbd 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserService.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java index 38e715d524..967d6a6c21 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,10 +44,9 @@ public void saveWithFailure(User user) { @Override public boolean checkUserExists(int id) { - if (userMapperMaster.select(id) != null) - return true; - if (userMapperSlave.select(id) != null) + if ((userMapperMaster.select(id) != null) || (userMapperSlave.select(id) != null)) { return true; + } return false; } } diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java index 60a59ab50e..3c2fc2ff4b 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,14 +39,14 @@ class UserServiceTest { @Test void testCommit() { - User user = new User(1, "Pocoyo"); + var user = new User(1, "Pocoyo"); userService.saveWithNoFailure(user); assertThat(userService.checkUserExists(user.getId())).isTrue(); } @Test void testRollback() { - User user = new User(2, "Pocoyo"); + var user = new User(2, "Pocoyo"); try { userService.saveWithFailure(user); } catch (RuntimeException ignore) { @@ -58,7 +58,7 @@ void testRollback() { @Test void testCommitWithExistingTx() throws Exception { userTransaction.begin(); - User user = new User(3, "Pocoyo"); + var user = new User(3, "Pocoyo"); userService.saveWithNoFailure(user); userTransaction.commit(); assertThat(userService.checkUserExists(user.getId())).isTrue(); @@ -71,7 +71,7 @@ void testCommitWithExistingTx() throws Exception { @Test void testRollbackWithExistingTx() throws Exception { userTransaction.begin(); - User user = new User(5, "Pocoyo"); + var user = new User(5, "Pocoyo"); userService.saveWithNoFailure(user); userTransaction.rollback(); assertThat(userService.checkUserExists(user.getId())).isFalse(); diff --git a/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java b/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java index 403d900053..eb4a64c6a3 100644 --- a/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java +++ b/src/test/java/org/mybatis/spring/support/SqlSessionDaoSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ void closeConnection() throws SQLException { @Test void testWithSqlSessionTemplate() { - SqlSessionTemplate sessionTemplate = new SqlSessionTemplate(sqlSessionFactory); + var sessionTemplate = new SqlSessionTemplate(sqlSessionFactory); sqlSessionDaoSupport.setSqlSessionTemplate(sessionTemplate); sqlSessionDaoSupport.afterPropertiesSet(); @@ -66,7 +66,7 @@ void testWithSqlSessionFactory() { @Test void testWithBothFactoryAndTemplate() { - SqlSessionTemplate sessionTemplate = new SqlSessionTemplate(sqlSessionFactory); + var sessionTemplate = new SqlSessionTemplate(sqlSessionFactory); sqlSessionDaoSupport.setSqlSessionTemplate(sessionTemplate); sqlSessionDaoSupport.setSqlSessionFactory(sqlSessionFactory); sqlSessionDaoSupport.afterPropertiesSet(); @@ -98,7 +98,7 @@ void testAutowireWithTwoFactories() { private void setupContext() { applicationContext = new GenericApplicationContext(); - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(MockSqlSessionDao.class); applicationContext.registerBeanDefinition("dao", definition); @@ -114,7 +114,7 @@ private void startContext() { } private void setupSqlSessionFactory(String name) { - GenericBeanDefinition definition = new GenericBeanDefinition(); + var definition = new GenericBeanDefinition(); definition.setBeanClass(SqlSessionFactoryBean.class); definition.getPropertyValues().add("dataSource", dataSource); diff --git a/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java b/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java index 66e7453c96..5c233a039b 100644 --- a/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java +++ b/src/test/java/org/mybatis/spring/transaction/SpringTransactionManagerTest.java @@ -19,20 +19,18 @@ import org.junit.jupiter.api.Test; import org.mybatis.spring.AbstractMyBatisSpringTest; -import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.DefaultTransactionDefinition; class SpringTransactionManagerTest extends AbstractMyBatisSpringTest { @Test void shouldNoOpWithTx() throws Exception { - DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(); + var txDef = new DefaultTransactionDefinition(); txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED"); - TransactionStatus status = txManager.getTransaction(txDef); + var status = txManager.getTransaction(txDef); - SpringManagedTransactionFactory transactionFactory = new SpringManagedTransactionFactory(); - SpringManagedTransaction transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, - null, false); + var transactionFactory = new SpringManagedTransactionFactory(); + var transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, null, false); transaction.getConnection(); transaction.commit(); transaction.close(); @@ -63,9 +61,8 @@ void shouldNoOpWithTx() throws Exception { @Test void shouldManageWithNoTx() throws Exception { - SpringManagedTransactionFactory transactionFactory = new SpringManagedTransactionFactory(); - SpringManagedTransaction transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, - null, false); + var transactionFactory = new SpringManagedTransactionFactory(); + var transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, null, false); transaction.getConnection(); transaction.commit(); transaction.close(); @@ -75,9 +72,8 @@ void shouldManageWithNoTx() throws Exception { @Test void shouldNotCommitWithNoTxAndAutocommitIsOn() throws Exception { - SpringManagedTransactionFactory transactionFactory = new SpringManagedTransactionFactory(); - SpringManagedTransaction transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, - null, false); + var transactionFactory = new SpringManagedTransactionFactory(); + var transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, null, false); connection.setAutoCommit(true); transaction.getConnection(); transaction.commit(); @@ -88,9 +84,8 @@ void shouldNotCommitWithNoTxAndAutocommitIsOn() throws Exception { @Test void shouldIgnoreAutocommit() throws Exception { - SpringManagedTransactionFactory transactionFactory = new SpringManagedTransactionFactory(); - SpringManagedTransaction transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, - null, true); + var transactionFactory = new SpringManagedTransactionFactory(); + var transaction = (SpringManagedTransaction) transactionFactory.newTransaction(dataSource, null, true); transaction.getConnection(); transaction.commit(); transaction.close(); diff --git a/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java b/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java index 831193d59d..7682d2b3d2 100644 --- a/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java +++ b/src/test/java/org/mybatis/spring/type/DummyMapperFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ public class DummyMapperFactoryBean extends MapperFactoryBean { public DummyMapperFactoryBean() { - super(); } public DummyMapperFactoryBean(Class mapperInterface) { @@ -48,11 +47,11 @@ protected void checkDaoConfig() { @Override public T getObject() throws Exception { - MapperFactoryBean mapperFactoryBean = new MapperFactoryBean<>(); + var mapperFactoryBean = new MapperFactoryBean(); mapperFactoryBean.setMapperInterface(getMapperInterface()); mapperFactoryBean.setAddToConfig(isAddToConfig()); mapperFactoryBean.setSqlSessionFactory(getCustomSessionFactoryForClass()); - T object = mapperFactoryBean.getObject(); + var object = mapperFactoryBean.getObject(); mapperInstanceCount.incrementAndGet(); return object; } diff --git a/src/test/java/org/mybatis/spring/type/DummyTypeHandler.java b/src/test/java/org/mybatis/spring/type/DummyTypeHandler.java index f42b49dca6..421db96c51 100644 --- a/src/test/java/org/mybatis/spring/type/DummyTypeHandler.java +++ b/src/test/java/org/mybatis/spring/type/DummyTypeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/type/DummyTypeHandler2.java b/src/test/java/org/mybatis/spring/type/DummyTypeHandler2.java index 72d5b873da..581ba77a21 100644 --- a/src/test/java/org/mybatis/spring/type/DummyTypeHandler2.java +++ b/src/test/java/org/mybatis/spring/type/DummyTypeHandler2.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/mybatis/spring/type/TypeHandlerFactory.java b/src/test/java/org/mybatis/spring/type/TypeHandlerFactory.java index 3cfbc572f2..2f563c208a 100644 --- a/src/test/java/org/mybatis/spring/type/TypeHandlerFactory.java +++ b/src/test/java/org/mybatis/spring/type/TypeHandlerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ public interface TypeHandlerFactory { static TypeHandler handler1() { - return new TypeHandler() { + return new TypeHandler<>() { @Override public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) { From 6d64d357e17ba7fd14d17114b9d89776a761f11f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 16:11:14 -0400 Subject: [PATCH 725/933] [source] Cleanup source code --- .../spring/MyBatisExceptionTranslator.java | 11 ++++--- .../mybatis/spring/SqlSessionFactoryBean.java | 24 +++++++------- .../mybatis/spring/SqlSessionTemplate.java | 8 ++--- .../org/mybatis/spring/SqlSessionUtils.java | 33 ++++++++----------- .../annotation/MapperScannerRegistrar.java | 30 ++++++++--------- .../spring/batch/MyBatisBatchItemWriter.java | 11 +++---- .../MyBatisBatchItemWriterBuilder.java | 4 +-- .../MyBatisCursorItemReaderBuilder.java | 4 +-- .../MyBatisPagingItemReaderBuilder.java | 4 +-- .../MapperScannerBeanDefinitionParser.java | 30 ++++++++--------- .../spring/mapper/ClassPathMapperScanner.java | 23 +++++++------ .../spring/mapper/MapperFactoryBean.java | 3 +- .../mapper/MapperScannerConfigurer.java | 19 +++++------ .../spring/support/SqlSessionDaoSupport.java | 2 +- .../transaction/SpringManagedTransaction.java | 2 +- 15 files changed, 96 insertions(+), 112 deletions(-) diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index c2215925c1..9f389d117d 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -79,7 +79,7 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { if (e instanceof PersistenceException) { // Batch exceptions come inside another PersistenceException // recursion has a risk of infinite loop so better make another if - String msg = e.getMessage(); + var msg = e.getMessage(); if (e.getCause() instanceof PersistenceException) { e = (PersistenceException) e.getCause(); if (msg == null) { @@ -88,11 +88,12 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { } if (e.getCause() instanceof SQLException) { this.initExceptionTranslator(); - String task = e.getMessage() + "\n"; - SQLException se = (SQLException) e.getCause(); - DataAccessException dae = this.exceptionTranslator.translate(task, null, se); + var task = e.getMessage() + "\n"; + var se = (SQLException) e.getCause(); + var dae = this.exceptionTranslator.translate(task, null, se); return dae != null ? dae : new UncategorizedSQLException(task, null, se); - } else if (e.getCause() instanceof TransactionException) { + } + if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } return new MyBatisSystemException(msg, e); diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 8a0a44c3d6..282bbdf333 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -64,7 +64,6 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.core.type.ClassMetadata; import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; @@ -553,14 +552,13 @@ public void addTypeAliases(Class... typeAliases) { private T[] appendArrays(T[] oldArrays, T[] newArrays, IntFunction generator) { if (oldArrays == null) { return newArrays; + } + if (newArrays == null) { + return oldArrays; } else { - if (newArrays == null) { - return oldArrays; - } else { - List newList = new ArrayList<>(Arrays.asList(oldArrays)); - newList.addAll(Arrays.asList(newArrays)); - return newList.toArray(generator.apply(0)); - } + List newList = new ArrayList<>(Arrays.asList(oldArrays)); + newList.addAll(Arrays.asList(newArrays)); + return newList.toArray(generator.apply(0)); } } @@ -690,8 +688,8 @@ protected SqlSessionFactory buildSqlSessionFactory() throws Exception { continue; } try { - XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(), - targetConfiguration, mapperLocation.toString(), targetConfiguration.getSqlFragments()); + var xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(), targetConfiguration, + mapperLocation.toString(), targetConfiguration.getSqlFragments()); xmlMapperBuilder.parse(); } catch (Exception e) { throw new IOException("Failed to parse mapping resource: '" + mapperLocation + "'", e); @@ -737,14 +735,14 @@ public void onApplicationEvent(ContextRefreshedEvent event) { private Set> scanClasses(String packagePatterns, Class assignableType) throws IOException { Set> classes = new HashSet<>(); - String[] packagePatternArray = tokenizeToStringArray(packagePatterns, + var packagePatternArray = tokenizeToStringArray(packagePatterns, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); for (String packagePattern : packagePatternArray) { - Resource[] resources = RESOURCE_PATTERN_RESOLVER.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + var resources = RESOURCE_PATTERN_RESOLVER.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(packagePattern) + "/**/*.class"); for (Resource resource : resources) { try { - ClassMetadata classMetadata = METADATA_READER_FACTORY.getMetadataReader(resource).getClassMetadata(); + var classMetadata = METADATA_READER_FACTORY.getMetadataReader(resource).getClassMetadata(); Class clazz = Resources.classForName(classMetadata.getClassName()); if (assignableType == null || assignableType.isAssignableFrom(clazz)) { classes.add(clazz); diff --git a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java index 130987488a..ca1a6405b5 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java +++ b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java @@ -327,10 +327,10 @@ public void destroy() throws Exception { private class SqlSessionInterceptor implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - SqlSession sqlSession = getSqlSession(SqlSessionTemplate.this.sqlSessionFactory, - SqlSessionTemplate.this.executorType, SqlSessionTemplate.this.exceptionTranslator); + var sqlSession = getSqlSession(SqlSessionTemplate.this.sqlSessionFactory, SqlSessionTemplate.this.executorType, + SqlSessionTemplate.this.exceptionTranslator); try { - Object result = method.invoke(sqlSession, args); + var result = method.invoke(sqlSession, args); if (!isSqlSessionTransactional(sqlSession, SqlSessionTemplate.this.sqlSessionFactory)) { // force commit even on non-dirty sessions because some databases require // a commit/rollback before calling close() @@ -338,7 +338,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl } return result; } catch (Throwable t) { - Throwable unwrapped = unwrapThrowable(t); + var unwrapped = unwrapThrowable(t); if (SqlSessionTemplate.this.exceptionTranslator != null && unwrapped instanceof PersistenceException) { // release the connection to avoid a deadlock if the translator is no loaded. See issue #22 closeSqlSession(sqlSession, SqlSessionTemplate.this.sqlSessionFactory); diff --git a/src/main/java/org/mybatis/spring/SqlSessionUtils.java b/src/main/java/org/mybatis/spring/SqlSessionUtils.java index 9c2804ec1f..bc629960d9 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionUtils.java +++ b/src/main/java/org/mybatis/spring/SqlSessionUtils.java @@ -18,14 +18,12 @@ import static org.springframework.util.Assert.notNull; import org.apache.ibatis.exceptions.PersistenceException; -import org.apache.ibatis.mapping.Environment; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.logging.Logger; import org.mybatis.logging.LoggerFactory; import org.mybatis.spring.transaction.SpringManagedTransactionFactory; -import org.springframework.dao.DataAccessException; import org.springframework.dao.TransientDataAccessResourceException; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.jdbc.datasource.DataSourceUtils; @@ -68,7 +66,7 @@ private SqlSessionUtils() { * {@code SpringManagedTransactionFactory} */ public static SqlSession getSqlSession(SqlSessionFactory sessionFactory) { - ExecutorType executorType = sessionFactory.getConfiguration().getDefaultExecutorType(); + var executorType = sessionFactory.getConfiguration().getDefaultExecutorType(); return getSqlSession(sessionFactory, executorType, null); } @@ -99,9 +97,9 @@ public static SqlSession getSqlSession(SqlSessionFactory sessionFactory, Executo notNull(sessionFactory, NO_SQL_SESSION_FACTORY_SPECIFIED); notNull(executorType, NO_EXECUTOR_TYPE_SPECIFIED); - SqlSessionHolder holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); + var holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); - SqlSession session = sessionHolder(executorType, holder); + var session = sessionHolder(executorType, holder); if (session != null) { return session; } @@ -134,7 +132,7 @@ private static void registerSessionHolder(SqlSessionFactory sessionFactory, Exec PersistenceExceptionTranslator exceptionTranslator, SqlSession session) { SqlSessionHolder holder; if (TransactionSynchronizationManager.isSynchronizationActive()) { - Environment environment = sessionFactory.getConfiguration().getEnvironment(); + var environment = sessionFactory.getConfiguration().getEnvironment(); if (environment.getTransactionFactory() instanceof SpringManagedTransactionFactory) { LOGGER.debug(() -> "Registering transaction synchronization for SqlSession [" + session + "]"); @@ -145,14 +143,12 @@ private static void registerSessionHolder(SqlSessionFactory sessionFactory, Exec .registerSynchronization(new SqlSessionSynchronization(holder, sessionFactory)); holder.setSynchronizedWithTransaction(true); holder.requested(); + } else if (TransactionSynchronizationManager.getResource(environment.getDataSource()) == null) { + LOGGER.debug(() -> "SqlSession [" + session + + "] was not registered for synchronization because DataSource is not transactional"); } else { - if (TransactionSynchronizationManager.getResource(environment.getDataSource()) == null) { - LOGGER.debug(() -> "SqlSession [" + session - + "] was not registered for synchronization because DataSource is not transactional"); - } else { - throw new TransientDataAccessResourceException( - "SqlSessionFactory must be using a SpringManagedTransactionFactory in order to use Spring transaction synchronization"); - } + throw new TransientDataAccessResourceException( + "SqlSessionFactory must be using a SpringManagedTransactionFactory in order to use Spring transaction synchronization"); } } else { LOGGER.debug(() -> "SqlSession [" + session @@ -191,8 +187,8 @@ public static void closeSqlSession(SqlSession session, SqlSessionFactory session notNull(session, NO_SQL_SESSION_SPECIFIED); notNull(sessionFactory, NO_SQL_SESSION_FACTORY_SPECIFIED); - SqlSessionHolder holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); - if ((holder != null) && (holder.getSqlSession() == session)) { + var holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); + if (holder != null && holder.getSqlSession() == session) { LOGGER.debug(() -> "Releasing transactional SqlSession [" + session + "]"); holder.released(); } else { @@ -215,9 +211,9 @@ public static boolean isSqlSessionTransactional(SqlSession session, SqlSessionFa notNull(session, NO_SQL_SESSION_SPECIFIED); notNull(sessionFactory, NO_SQL_SESSION_FACTORY_SPECIFIED); - SqlSessionHolder holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); + var holder = (SqlSessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); - return (holder != null) && (holder.getSqlSession() == session); + return holder != null && holder.getSqlSession() == session; } /** @@ -277,8 +273,7 @@ public void beforeCommit(boolean readOnly) { this.holder.getSqlSession().commit(); } catch (PersistenceException p) { if (this.holder.getPersistenceExceptionTranslator() != null) { - DataAccessException translated = this.holder.getPersistenceExceptionTranslator() - .translateExceptionIfPossible(p); + var translated = this.holder.getPersistenceExceptionTranslator().translateExceptionIfPossible(p); if (translated != null) { throw translated; } diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index 181273ea92..f1de1b3c1e 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -70,7 +70,7 @@ public void setResourceLoader(ResourceLoader resourceLoader) { @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { - AnnotationAttributes mapperScanAttrs = AnnotationAttributes + var mapperScanAttrs = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName())); if (mapperScanAttrs != null) { registerBeanDefinitions(importingClassMetadata, mapperScanAttrs, registry, @@ -81,7 +81,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes annoAttrs, BeanDefinitionRegistry registry, String beanName) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); + var builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); builder.addPropertyValue("processPropertyPlaceHolders", annoAttrs.getBoolean("processPropertyPlaceHolders")); Class annotationClass = annoAttrs.getClass("annotationClass"); @@ -104,20 +104,18 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a builder.addPropertyValue("mapperFactoryBeanClass", mapperFactoryBeanClass); } - String sqlSessionTemplateRef = annoAttrs.getString("sqlSessionTemplateRef"); + var sqlSessionTemplateRef = annoAttrs.getString("sqlSessionTemplateRef"); if (StringUtils.hasText(sqlSessionTemplateRef)) { builder.addPropertyValue("sqlSessionTemplateBeanName", annoAttrs.getString("sqlSessionTemplateRef")); } - String sqlSessionFactoryRef = annoAttrs.getString("sqlSessionFactoryRef"); + var sqlSessionFactoryRef = annoAttrs.getString("sqlSessionFactoryRef"); if (StringUtils.hasText(sqlSessionFactoryRef)) { builder.addPropertyValue("sqlSessionFactoryBeanName", annoAttrs.getString("sqlSessionFactoryRef")); } - List basePackages = new ArrayList<>(); - - basePackages.addAll(Arrays.stream(annoAttrs.getStringArray("basePackages")).filter(StringUtils::hasText) - .collect(Collectors.toList())); + List basePackages = new ArrayList<>(Arrays.stream(annoAttrs.getStringArray("basePackages")) + .filter(StringUtils::hasText).collect(Collectors.toList())); basePackages.addAll(Arrays.stream(annoAttrs.getClassArray("basePackageClasses")).map(ClassUtils::getPackageName) .collect(Collectors.toList())); @@ -126,7 +124,7 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a basePackages.add(getDefaultBasePackage(annoMeta)); } - AnnotationAttributes[] excludeFilterArray = annoAttrs.getAnnotationArray("excludeFilters"); + var excludeFilterArray = annoAttrs.getAnnotationArray("excludeFilters"); if (excludeFilterArray.length > 0) { List typeFilters = new ArrayList<>(); List> rawTypeFilters = new ArrayList<>(); @@ -142,12 +140,12 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a builder.addPropertyValue("rawExcludeFilters", rawTypeFilters); } - String lazyInitialization = annoAttrs.getString("lazyInitialization"); + var lazyInitialization = annoAttrs.getString("lazyInitialization"); if (StringUtils.hasText(lazyInitialization)) { builder.addPropertyValue("lazyInitialization", lazyInitialization); } - String defaultScope = annoAttrs.getString("defaultScope"); + var defaultScope = annoAttrs.getString("defaultScope"); if (!AbstractBeanDefinition.SCOPE_DEFAULT.equals(defaultScope)) { builder.addPropertyValue("defaultScope", defaultScope); } @@ -173,7 +171,7 @@ private List> parseFiltersHasPatterns(AnnotationAttributes f List> rawTypeFilters = new ArrayList<>(); FilterType filterType = filterAttributes.getEnum("type"); - String[] expressionArray = filterAttributes.getStringArray("pattern"); + var expressionArray = filterAttributes.getStringArray("pattern"); for (String expression : expressionArray) { switch (filterType) { case REGEX: @@ -210,7 +208,7 @@ private List typeFiltersFor(AnnotationAttributes filterAttributes) { Assert.isAssignable(Annotation.class, filterClass, "Specified an unsupported type in 'ANNOTATION' exclude filter of @MapperScan"); @SuppressWarnings("unchecked") - Class annoClass = (Class) filterClass; + var annoClass = (Class) filterClass; typeFilters.add(new AnnotationTypeFilter(annoClass)); break; case ASSIGNABLE_TYPE: @@ -245,11 +243,11 @@ private static String getDefaultBasePackage(AnnotationMetadata importingClassMet static class RepeatingRegistrar extends MapperScannerRegistrar { @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { - AnnotationAttributes mapperScansAttrs = AnnotationAttributes + var mapperScansAttrs = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(MapperScans.class.getName())); if (mapperScansAttrs != null) { - AnnotationAttributes[] annotations = mapperScansAttrs.getAnnotationArray("value"); - for (int i = 0; i < annotations.length; i++) { + var annotations = mapperScansAttrs.getAnnotationArray("value"); + for (var i = 0; i < annotations.length; i++) { registerBeanDefinitions(importingClassMetadata, annotations[i], registry, generateBaseBeanName(importingClassMetadata, i)); } diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index d2fbbdc3e7..9999275ba2 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -18,9 +18,6 @@ import static org.springframework.util.Assert.isTrue; import static org.springframework.util.Assert.notNull; -import java.util.List; - -import org.apache.ibatis.executor.BatchResult; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; @@ -143,7 +140,7 @@ public void write(final Chunk items) { sqlSessionTemplate.update(statementId, itemToParameterConverter.convert(item)); } - List results = sqlSessionTemplate.flushStatements(); + var results = sqlSessionTemplate.flushStatements(); if (assertUpdates) { if (results.size() != 1) { @@ -151,10 +148,10 @@ public void write(final Chunk items) { + "Expected 1 but number of BatchResult objects returned was " + results.size()); } - int[] updateCounts = results.get(0).getUpdateCounts(); + var updateCounts = results.get(0).getUpdateCounts(); - for (int i = 0; i < updateCounts.length; i++) { - int value = updateCounts[i]; + for (var i = 0; i < updateCounts.length; i++) { + var value = updateCounts[i]; if (value == 0) { throw new EmptyResultDataAccessException("Item " + i + " of " + updateCounts.length + " did not update any rows: [" + items.getItems().get(i) + "]", 1); diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java index f833454b84..6270175fb4 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,7 +120,7 @@ public MyBatisBatchItemWriterBuilder itemToParameterConverter(Converter * @return the writer */ public MyBatisBatchItemWriter build() { - MyBatisBatchItemWriter writer = new MyBatisBatchItemWriter<>(); + var writer = new MyBatisBatchItemWriter(); writer.setSqlSessionTemplate(this.sqlSessionTemplate); writer.setSqlSessionFactory(this.sqlSessionFactory); writer.setStatementId(this.statementId); diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java index da81b4e227..11d0eec554 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,7 +140,7 @@ public MyBatisCursorItemReaderBuilder maxItemCount(int maxItemCount) { * @return the reader */ public MyBatisCursorItemReader build() { - MyBatisCursorItemReader reader = new MyBatisCursorItemReader<>(); + var reader = new MyBatisCursorItemReader(); reader.setSqlSessionFactory(this.sqlSessionFactory); reader.setQueryId(this.queryId); reader.setParameterValues(this.parameterValues); diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java index 4428318c79..e4504b6559 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,7 +156,7 @@ public MyBatisPagingItemReaderBuilder maxItemCount(int maxItemCount) { * @return the reader */ public MyBatisPagingItemReader build() { - MyBatisPagingItemReader reader = new MyBatisPagingItemReader<>(); + var reader = new MyBatisPagingItemReader(); reader.setSqlSessionFactory(this.sqlSessionFactory); reader.setQueryId(this.queryId); reader.setParameterValues(this.parameterValues); diff --git a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java index 33c93665f9..3ad4365cfd 100644 --- a/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java +++ b/src/main/java/org/mybatis/spring/config/MapperScannerBeanDefinitionParser.java @@ -31,12 +31,10 @@ import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.beans.factory.xml.XmlReaderContext; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** * A {#code BeanDefinitionParser} that handles the element scan of the MyBatis. namespace @@ -66,33 +64,33 @@ public class MapperScannerBeanDefinitionParser extends AbstractBeanDefinitionPar @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); + var builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class); - ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); + var classLoader = ClassUtils.getDefaultClassLoader(); - String processPropertyPlaceHolders = element.getAttribute(ATTRIBUTE_PROCESS_PROPERTY_PLACEHOLDERS); + var processPropertyPlaceHolders = element.getAttribute(ATTRIBUTE_PROCESS_PROPERTY_PLACEHOLDERS); builder.addPropertyValue("processPropertyPlaceHolders", !StringUtils.hasText(processPropertyPlaceHolders) || Boolean.parseBoolean(processPropertyPlaceHolders)); try { - String annotationClassName = element.getAttribute(ATTRIBUTE_ANNOTATION); + var annotationClassName = element.getAttribute(ATTRIBUTE_ANNOTATION); if (StringUtils.hasText(annotationClassName)) { @SuppressWarnings("unchecked") Class annotationClass = (Class) classLoader .loadClass(annotationClassName); builder.addPropertyValue("annotationClass", annotationClass); } - String markerInterfaceClassName = element.getAttribute(ATTRIBUTE_MARKER_INTERFACE); + var markerInterfaceClassName = element.getAttribute(ATTRIBUTE_MARKER_INTERFACE); if (StringUtils.hasText(markerInterfaceClassName)) { Class markerInterface = classLoader.loadClass(markerInterfaceClassName); builder.addPropertyValue("markerInterface", markerInterface); } - String nameGeneratorClassName = element.getAttribute(ATTRIBUTE_NAME_GENERATOR); + var nameGeneratorClassName = element.getAttribute(ATTRIBUTE_NAME_GENERATOR); if (StringUtils.hasText(nameGeneratorClassName)) { Class nameGeneratorClass = classLoader.loadClass(nameGeneratorClassName); - BeanNameGenerator nameGenerator = BeanUtils.instantiateClass(nameGeneratorClass, BeanNameGenerator.class); + var nameGenerator = BeanUtils.instantiateClass(nameGeneratorClass, BeanNameGenerator.class); builder.addPropertyValue("nameGenerator", nameGenerator); } - String mapperFactoryBeanClassName = element.getAttribute(ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS); + var mapperFactoryBeanClassName = element.getAttribute(ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS); if (StringUtils.hasText(mapperFactoryBeanClassName)) { @SuppressWarnings("unchecked") Class mapperFactoryBeanClass = (Class) classLoader @@ -101,13 +99,13 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa } // parse raw exclude-filter in - List> rawExcludeFilters = parseScanTypeFilters(element, parserContext); + var rawExcludeFilters = parseScanTypeFilters(element, parserContext); if (!rawExcludeFilters.isEmpty()) { builder.addPropertyValue("rawExcludeFilters", rawExcludeFilters); } } catch (Exception ex) { - XmlReaderContext readerContext = parserContext.getReaderContext(); + var readerContext = parserContext.getReaderContext(); readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause()); } @@ -125,11 +123,11 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa private List> parseScanTypeFilters(Element element, ParserContext parserContext) { List> typeFilters = new ArrayList<>(); - NodeList nodeList = element.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node node = nodeList.item(i); + var nodeList = element.getChildNodes(); + for (var i = 0; i < nodeList.getLength(); i++) { + var node = nodeList.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { - String localName = parserContext.getDelegate().getLocalName(node); + var localName = parserContext.getDelegate().getLocalName(node); if (ATTRIBUTE_EXCLUDE_FILTER.equals(localName)) { Map filter = new HashMap<>(16); filter.put("type", ((Element) node).getAttribute("type")); diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 0e755007db..62955111e1 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -208,7 +208,7 @@ public void setDefaultScope(String defaultScope) { * that extends a markerInterface or/and those annotated with the annotationClass */ public void registerFilters() { - boolean acceptAllInterfaces = true; + var acceptAllInterfaces = true; // if specified, use the given annotation and / or marker interface if (this.annotationClass != null) { @@ -234,7 +234,7 @@ protected boolean matchClassName(String className) { // exclude package-info.java addExcludeFilter((metadataReader, metadataReaderFactory) -> { - String className = metadataReader.getClassMetadata().getClassName(); + var className = metadataReader.getClassMetadata().getClassName(); return className.endsWith("package-info"); }); @@ -252,7 +252,7 @@ protected boolean matchClassName(String className) { */ @Override public Set doScan(String... basePackages) { - Set beanDefinitions = super.doScan(basePackages); + var beanDefinitions = super.doScan(basePackages); if (beanDefinitions.isEmpty()) { if (printWarnLogIfNotFoundMappers) { @@ -268,10 +268,10 @@ public Set doScan(String... basePackages) { private void processBeanDefinitions(Set beanDefinitions) { AbstractBeanDefinition definition; - BeanDefinitionRegistry registry = getRegistry(); + var registry = getRegistry(); for (BeanDefinitionHolder holder : beanDefinitions) { definition = (AbstractBeanDefinition) holder.getBeanDefinition(); - boolean scopedProxy = false; + var scopedProxy = false; if (ScopedProxyFactoryBean.class.getName().equals(definition.getBeanClassName())) { definition = (AbstractBeanDefinition) Optional .ofNullable(((RootBeanDefinition) definition).getDecoratedDefinition()) @@ -279,7 +279,7 @@ private void processBeanDefinitions(Set beanDefinitions) { "The target bean definition of scoped proxy bean not found. Root bean definition[" + holder + "]")); scopedProxy = true; } - String beanClassName = definition.getBeanClassName(); + var beanClassName = definition.getBeanClassName(); LOGGER.debug(() -> "Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + beanClassName + "' mapperInterface"); @@ -301,7 +301,7 @@ private void processBeanDefinitions(Set beanDefinitions) { definition.getPropertyValues().add("addToConfig", this.addToConfig); - boolean explicitFactoryUsed = false; + var explicitFactoryUsed = false; if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) { definition.getPropertyValues().add("sqlSessionFactory", new RuntimeBeanReference(this.sqlSessionFactoryBeanName)); @@ -344,7 +344,7 @@ private void processBeanDefinitions(Set beanDefinitions) { } if (!definition.isSingleton()) { - BeanDefinitionHolder proxyHolder = ScopedProxyUtils.createScopedProxy(holder, registry, true); + var proxyHolder = ScopedProxyUtils.createScopedProxy(holder, registry, true); if (registry.containsBeanDefinition(proxyHolder.getBeanName())) { registry.removeBeanDefinition(proxyHolder.getBeanName()); } @@ -363,11 +363,10 @@ protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) { if (super.checkCandidate(beanName, beanDefinition)) { return true; - } else { - LOGGER.warn(() -> "Skipping MapperFactoryBean with name '" + beanName + "' and '" - + beanDefinition.getBeanClassName() + "' mapperInterface" + ". Bean already defined with the same name!"); - return false; } + LOGGER.warn(() -> "Skipping MapperFactoryBean with name '" + beanName + "' and '" + + beanDefinition.getBeanClassName() + "' mapperInterface" + ". Bean already defined with the same name!"); + return false; } } diff --git a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java index a6fe818c65..f95b721314 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java @@ -18,7 +18,6 @@ import static org.springframework.util.Assert.notNull; import org.apache.ibatis.executor.ErrorContext; -import org.apache.ibatis.session.Configuration; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.support.SqlSessionDaoSupport; import org.springframework.beans.factory.FactoryBean; @@ -71,7 +70,7 @@ protected void checkDaoConfig() { notNull(this.mapperInterface, "Property 'mapperInterface' is required"); - Configuration configuration = getSqlSession().getConfiguration(); + var configuration = getSqlSession().getConfiguration(); if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) { try { configuration.addMapper(this.mapperInterface); diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index aec74d4544..eaf7c6f3b1 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -27,11 +27,9 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.BeanUtils; -import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyResourceConfigurer; import org.springframework.beans.factory.config.TypedStringValue; @@ -386,7 +384,7 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { processPropertyPlaceHolders(); } - ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry, getEnvironment()); + var scanner = new ClassPathMapperScanner(registry, getEnvironment()); scanner.setAddToConfig(this.addToConfig); scanner.setAnnotationClass(this.annotationClass); scanner.setMarkerInterface(this.markerInterface); @@ -399,7 +397,7 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { scanner.setBeanNameGenerator(this.nameGenerator); scanner.setMapperFactoryBeanClass(this.mapperFactoryBeanClass); if (StringUtils.hasText(lazyInitialization)) { - scanner.setLazyInitialization(Boolean.valueOf(lazyInitialization)); + scanner.setLazyInitialization(Boolean.parseBoolean(lazyInitialization)); } if (StringUtils.hasText(defaultScope)) { scanner.setDefaultScope(defaultScope); @@ -420,13 +418,13 @@ private void processPropertyPlaceHolders() { false, false); if (!prcs.isEmpty() && applicationContext instanceof ConfigurableApplicationContext) { - BeanDefinition mapperScannerBean = ((ConfigurableApplicationContext) applicationContext).getBeanFactory() + var mapperScannerBean = ((ConfigurableApplicationContext) applicationContext).getBeanFactory() .getBeanDefinition(beanName); // PropertyResourceConfigurer does not expose any methods to explicitly perform // property placeholder substitution. Instead, create a BeanFactory that just // contains this mapper scanner and post process the factory. - DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); + var factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition(beanName, mapperScannerBean); for (PropertyResourceConfigurer prc : prcs.values()) { @@ -457,17 +455,18 @@ private Environment getEnvironment() { } private String getPropertyValue(String propertyName, PropertyValues values) { - PropertyValue property = values.getPropertyValue(propertyName); + var property = values.getPropertyValue(propertyName); if (property == null) { return null; } - Object value = property.getValue(); + var value = property.getValue(); if (value == null) { return null; - } else if (value instanceof String) { + } + if (value instanceof String) { return value.toString(); } else if (value instanceof TypedStringValue) { return ((TypedStringValue) value).getValue(); @@ -478,7 +477,7 @@ private String getPropertyValue(String propertyName, PropertyValues values) { @SuppressWarnings("unchecked") private List> getPropertyValueForTypeFilter(String propertyName, PropertyValues values) { - PropertyValue property = values.getPropertyValue(propertyName); + var property = values.getPropertyValue(propertyName); Object value; if (property == null || (value = property.getValue()) == null || !(value instanceof List)) { return null; diff --git a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java index d7f4dbe594..0eeeab17c6 100644 --- a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java +++ b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java @@ -78,7 +78,7 @@ protected SqlSessionTemplate createSqlSessionTemplate(SqlSessionFactory sqlSessi * @return a factory of SqlSession */ public final SqlSessionFactory getSqlSessionFactory() { - return (this.sqlSessionTemplate != null ? this.sqlSessionTemplate.getSqlSessionFactory() : null); + return this.sqlSessionTemplate != null ? this.sqlSessionTemplate.getSqlSessionFactory() : null; } /** diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java index f9e332dcab..1b6cd04832 100644 --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java @@ -105,7 +105,7 @@ public void close() throws SQLException { @Override public Integer getTimeout() throws SQLException { - ConnectionHolder holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource); + var holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource); if (holder != null && holder.hasTimeout()) { return holder.getTimeToLiveInSeconds(); } From 998b614b1827cde2a835b93e6a6634920f07e578 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 16:31:33 -0400 Subject: [PATCH 726/933] [tests] More cleanup --- .../asyncsynchronization/AsyncAfterCompletionHelper.java | 3 +-- .../java/org/mybatis/spring/submitted/xa/UserServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java index ec928f6655..6ad1f3d5df 100644 --- a/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java +++ b/src/test/java/org/mybatis/spring/asyncsynchronization/AsyncAfterCompletionHelper.java @@ -66,9 +66,8 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg thread.join(); if (exceptionSet.isEmpty()) { return retValSet.iterator().next(); - } else { - throw exceptionSet.iterator().next(); } + throw exceptionSet.iterator().next(); } } diff --git a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java index 967d6a6c21..c98a1e1cd9 100644 --- a/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java +++ b/src/test/java/org/mybatis/spring/submitted/xa/UserServiceImpl.java @@ -44,7 +44,7 @@ public void saveWithFailure(User user) { @Override public boolean checkUserExists(int id) { - if ((userMapperMaster.select(id) != null) || (userMapperSlave.select(id) != null)) { + if (userMapperMaster.select(id) != null || userMapperSlave.select(id) != null) { return true; } return false; From b625cae84c35d79f3e0ed3bf0a77e594e621107f Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 16:40:11 -0400 Subject: [PATCH 727/933] [test] Restore the getName as no real reason to remove yes its not used, neither is the internal object name. If cleanup keeps running it will just remove more and more which makes its usage unclear. Add comment instead --- .../mybatis/spring/batch/MyBatisCursorItemReaderTest.java | 5 +++++ .../batch/builder/MyBatisBatchItemWriterBuilderTest.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index 44f061ce62..965fa84336 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -90,12 +90,17 @@ private List getFoos() { return Arrays.asList(new Foo("foo1"), new Foo("foo2"), new Foo("foo3")); } + // Note: Do not cleanup this 'foo' class private static class Foo { private final String name; Foo(String name) { this.name = name; } + + public String getName() { + return this.name; + } } } diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index 6076ba4da5..a39fc45e93 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -176,12 +176,17 @@ private Chunk getFoos() { return Chunk.of(new Foo("foo1"), new Foo("foo2"), new Foo("foo3")); } + // Note: Do not cleanup this 'foo' class private static class Foo { private final String name; Foo(String name) { this.name = name; } + + public String getName() { + return this.name; + } } } From 1df5bcd86ac0aafc26c6884e678f231606d81d4b Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 16:43:34 -0400 Subject: [PATCH 728/933] [cleanup] More cleanup --- .../java/org/mybatis/spring/SqlSessionFactoryBean.java | 7 +++---- .../mybatis/spring/annotation/MapperScannerRegistrar.java | 1 + .../org/mybatis/spring/mapper/MapperScannerConfigurer.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 282bbdf333..ed97f2e130 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -555,11 +555,10 @@ private T[] appendArrays(T[] oldArrays, T[] newArrays, IntFunction gene } if (newArrays == null) { return oldArrays; - } else { - List newList = new ArrayList<>(Arrays.asList(oldArrays)); - newList.addAll(Arrays.asList(newArrays)); - return newList.toArray(generator.apply(0)); } + List newList = new ArrayList<>(Arrays.asList(oldArrays)); + newList.addAll(Arrays.asList(newArrays)); + return newList.toArray(generator.apply(0)); } @Override diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index f1de1b3c1e..66d4b9f418 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -61,6 +61,7 @@ */ public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware { + // Note: Do not move resourceLoader via cleanup private ResourceLoader resourceLoader; @Override diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index eaf7c6f3b1..dd2146308f 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -468,11 +468,11 @@ private String getPropertyValue(String propertyName, PropertyValues values) { } if (value instanceof String) { return value.toString(); - } else if (value instanceof TypedStringValue) { + } + if (value instanceof TypedStringValue) { return ((TypedStringValue) value).getValue(); - } else { - return null; } + return null; } @SuppressWarnings("unchecked") From eb2de4d06841fef7aea46d9fb3ba8d67661e7a4e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 16:53:27 -0400 Subject: [PATCH 729/933] [todo] Add a note about code that seems to be incorrectly written --- src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index ed97f2e130..6a268ced8f 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -565,6 +565,7 @@ private T[] appendArrays(T[] oldArrays, T[] newArrays, IntFunction gene public void afterPropertiesSet() throws Exception { notNull(dataSource, "Property 'dataSource' is required"); notNull(sqlSessionFactoryBuilder, "Property 'sqlSessionFactoryBuilder' is required"); + // TODO Review this statement as it seems off! state((configuration == null && configLocation == null) || !(configuration != null && configLocation != null), "Property 'configuration' and 'configLocation' can not specified with together"); From 392fbc526aca9767a5ab884554ab3f5d5faa3776 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 17:04:28 -0400 Subject: [PATCH 730/933] [maven-release-plugin] prepare release mybatis-spring-3.0.4 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5e4b090f48..ae5d712085 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 3.0.4-SNAPSHOT + 3.0.4 mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -80,7 +80,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.4 https://github.com/mybatis/spring/ @@ -122,7 +122,7 @@ 5.10.3 - 1700476361 + 1723410193 true From 1ba4458ac8eb5310173214515c34318b0d91325a Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 17:04:31 -0400 Subject: [PATCH 731/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index ae5d712085..5e7a6107a7 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 3.0.4 + 3.0.5-SNAPSHOT mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -80,7 +80,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.4 + HEAD https://github.com/mybatis/spring/ @@ -122,7 +122,7 @@ 5.10.3 - 1723410193 + 1723410271 true From 13146053664f0cc3b9873632ffe68ddf66ab8e73 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 11 Aug 2024 17:18:41 -0400 Subject: [PATCH 732/933] [javadocs] Fix since tag --- src/main/java/org/mybatis/spring/annotation/MapperScan.java | 2 +- .../org/mybatis/spring/annotation/MapperScannerRegistrar.java | 4 ++-- .../org/mybatis/spring/mapper/MapperScannerConfigurer.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index e533833492..270036ba15 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -200,7 +200,7 @@ /** * Specifies which types are not eligible for mapper scanning. * - * @since 3.0.3 + * @since 3.0.4 * * @return array of customized mapper excludeFilter */ diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java index 66d4b9f418..81ecd2f1ff 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java @@ -166,7 +166,7 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a * @param filterAttributes * AnnotationAttributes of excludeFilters * - * @since 3.0.3 + * @since 3.0.4 */ private List> parseFiltersHasPatterns(AnnotationAttributes filterAttributes) { @@ -196,7 +196,7 @@ private List> parseFiltersHasPatterns(AnnotationAttributes f * @param filterAttributes * AnnotationAttributes of excludeFilters * - * @since 3.0.3 + * @since 3.0.4 */ private List typeFiltersFor(AnnotationAttributes filterAttributes) { diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index dd2146308f..f220ce4dee 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -209,7 +209,7 @@ public void setMarkerInterface(Class superClass) { *

    * The scanner will exclude types that define with excludeFilters. * - * @since 3.0.3 + * @since 3.0.4 * * @param excludeFilters * list of TypeFilter @@ -223,7 +223,7 @@ public void setExcludeFilters(List excludeFilters) { *

    * After parsed, it will be added to excludeFilters. * - * @since 3.0.3 + * @since 3.0.4 * * @param rawExcludeFilters * list of rawExcludeFilter From ff7cf8e778debd5cf7477088bdd43237505982d9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 10:34:15 +0000 Subject: [PATCH 733/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5e7a6107a7..72d0c720c7 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.1.2 org.mybatis.spring - 5.10.3 + 5.11.0 1723410271 From a643fe352012592698491f5cd51a3bd29c6c294c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 12:28:10 +0000 Subject: [PATCH 734/933] Update spring core to v6.1.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 72d0c720c7..645bbd9eb3 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.16 - 6.1.11 + 6.1.12 3.3.2 5.1.2 org.mybatis.spring From 1f49423328056cd736e28833402dbc1976821961 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:22:13 +0000 Subject: [PATCH 735/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.14.19 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 645bbd9eb3..e86ad6e5f7 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.14.18 + 1.14.19 test From c545fd2563e20fba2f02c8c476c85578777f0a36 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:58:43 +0000 Subject: [PATCH 736/933] Update dependency net.bytebuddy:byte-buddy to v1.14.19 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e86ad6e5f7..4735a75c86 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.14.18 + 1.14.19 test From 024e97aca7951b8e913cc33b43567063619e24e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 17 Aug 2024 22:45:44 +0000 Subject: [PATCH 737/933] Update dependency maven to v3.9.9 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index fd51663748..01aa6654cd 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -16,5 +16,5 @@ # under the License. wrapperVersion=3.3.2 distributionType=source -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar From 95316f02b090cdc431085d8dcecdc24c49bef688 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 20:24:21 +0000 Subject: [PATCH 738/933] Update dependency org.springframework.boot:spring-boot-autoconfigure to v3.3.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4735a75c86..ef5ea6acee 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.16 6.1.12 - 3.3.2 + 3.3.3 5.1.2 org.mybatis.spring From 4cc4fd2c21fb74475b773f0003dc555ab3d57ded Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 06:52:40 +0000 Subject: [PATCH 739/933] Update dependency net.bytebuddy:byte-buddy to v1.15.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef5ea6acee..71a4443fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.14.19 + 1.15.0 test From 9577d68a92a6bc8303fa4ceb17db95df5ac6351e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 06:52:44 +0000 Subject: [PATCH 740/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef5ea6acee..1cab7e76a3 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.14.19 + 1.15.0 test From 9e3e8189cc14893b1cf69f13f6501f999360e612 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:39:07 +0000 Subject: [PATCH 741/933] Update dependency org.mockito:mockito-core to v5.13.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a32ba09a49..0fdd0721c3 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.12.0 + 5.13.0 test From 8749e8ea172b5e86791d996af602d5aff9502671 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:52:58 +0000 Subject: [PATCH 742/933] Update dependency net.bytebuddy:byte-buddy to v1.15.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0fdd0721c3..c5fdc4f861 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.15.0 + 1.15.1 test From c617575672dcbf3488b7fb7199a0ba5cdeb37f54 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:53:01 +0000 Subject: [PATCH 743/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0fdd0721c3..b499de7aee 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.15.0 + 1.15.1 test From b3c7bd06bb97ed4711861825e9a6878c12a8b45c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:38:07 +0000 Subject: [PATCH 744/933] Update spring core to v6.1.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 48bbd13e4a..55a6f9e5d4 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.16 - 6.1.12 + 6.1.13 3.3.3 5.1.2 org.mybatis.spring From c633fef8ca8945b67037f5ad04a533d725719605 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:56:06 +0000 Subject: [PATCH 745/933] Update dependency org.springframework.boot:spring-boot-autoconfigure to v3.3.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 55a6f9e5d4..b73d6f3bf1 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.16 6.1.13 - 3.3.3 + 3.3.4 5.1.2 org.mybatis.spring From dca666c61402383d8e1c77a2cb1bda98edb4b3b7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:38:09 +0000 Subject: [PATCH 746/933] Update dependency net.bytebuddy:byte-buddy to v1.15.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b73d6f3bf1..edb636ff16 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.15.1 + 1.15.2 test From d1fa3c5814219181a60f0db2089342ae2ea2d57d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:38:13 +0000 Subject: [PATCH 747/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b73d6f3bf1..5686a8deac 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.15.1 + 1.15.2 test From df04fa2096beef70e47aaaa2e00192986ba53bc4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:58:57 +0000 Subject: [PATCH 748/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b73d6f3bf1..a0fc68bed0 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.1.2 org.mybatis.spring - 5.11.0 + 5.11.1 1723410271 From 68fb6f360ada6e8dddebc9baf9819d2514e9f585 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:46:45 +0000 Subject: [PATCH 749/933] Update dependency net.bytebuddy:byte-buddy to v1.15.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 532946158c..25fc644d11 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.15.2 + 1.15.3 test From ea1d9cd246888c0391275e81ec1830241ec299ab Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:46:49 +0000 Subject: [PATCH 750/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 532946158c..14fdd92d7f 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.15.2 + 1.15.3 test From c81eaba97e8dbc07fc1321bbe29531e25ef72ca7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:38:33 +0000 Subject: [PATCH 751/933] Update dependency org.mockito:mockito-core to v5.14.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1784c8ef1..c8f0adb7b8 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.13.0 + 5.14.0 test From 2fe17f7b21b52fc9708be95646cdd3e55681c9d0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:03:47 +0000 Subject: [PATCH 752/933] Update dependency org.mockito:mockito-core to v5.14.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c8f0adb7b8..64c3b64fdf 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.14.0 + 5.14.1 test From 4fb32941ff959e3b767aa8c6d127104614d824b3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:01:50 +0000 Subject: [PATCH 753/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 64c3b64fdf..b23ce53260 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.1.2 org.mybatis.spring - 5.11.1 + 5.11.2 1723410271 From 2988cf0c61451d3d52e8d9ffeadcde1659eebe4f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:49:30 +0000 Subject: [PATCH 754/933] Update dependency net.bytebuddy:byte-buddy to v1.15.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b23ce53260..50cf0ebb89 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.15.3 + 1.15.4 test From 50046b0d6bcb2cea5fd833a21c8da80cf008eafb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:49:33 +0000 Subject: [PATCH 755/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b23ce53260..49eaf80ef0 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.15.3 + 1.15.4 test From bf0aef3b8ab9a6f45d247e3d874949d4deb43106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=94=E6=98=9F=E5=A5=BD=E5=B8=82=E6=B0=91?= <39870481+cpupg@users.noreply.github.com> Date: Fri, 11 Oct 2024 23:44:14 +0800 Subject: [PATCH 756/933] fix i18n link error in site. change zh to zh_cn in zh_cn/markdown/index.md --- src/site/zh_CN/markdown/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/zh_CN/markdown/index.md b/src/site/zh_CN/markdown/index.md index 3ffbbaaa03..c993cff09c 100644 --- a/src/site/zh_CN/markdown/index.md +++ b/src/site/zh_CN/markdown/index.md @@ -47,7 +47,7 @@ Andrius Juozapaitis, Giovanni Cuccu, Raj Nagappan 和 Tomas Pinos 的贡献;

  • Español
  • 日本語
  • 한국어
  • -
  • 简体中文
  • +
  • 简体中文
  • 想用自己的母语阅读这篇文档吗?那就用你的母语翻译它吧! From f80a018bc31bd4db90963ea3bd1a95f215cf772a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:05:01 +0000 Subject: [PATCH 757/933] Update dependency org.mockito:mockito-core to v5.14.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c1c0178cc9..c41f8d4ca6 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.14.1 + 5.14.2 test From e6e584373c40835841fec9b532a9c1023cdbad38 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:39:13 +0000 Subject: [PATCH 758/933] Update dependency net.bytebuddy:byte-buddy to v1.15.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c41f8d4ca6..17327a6ed2 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.15.4 + 1.15.5 test From c1b21a14a608048e53401c31401ca70b26c8c57d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:39:17 +0000 Subject: [PATCH 759/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c41f8d4ca6..83f647312e 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.15.4 + 1.15.5 test From a46c9c8bc97d6a767a51993c9cd4d52f33191f2d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:15:05 +0000 Subject: [PATCH 760/933] Update spring core to v6.1.14 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a8cea233d..4d8898047b 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.16 - 6.1.13 + 6.1.14 3.3.4 5.1.2 org.mybatis.spring From 3f85978fbd1d3921d001e7e6ebf51ff475521cfb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:33:34 +0000 Subject: [PATCH 761/933] Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4d8898047b..b17f6889bc 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.1.2 org.mybatis.spring - 5.11.2 + 5.11.3 1723410271 From e8315863e975064a5a4419e6a2f143a882254af5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 09:16:23 +0000 Subject: [PATCH 762/933] Update dependency net.bytebuddy:byte-buddy to v1.15.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b17f6889bc..6442374a62 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.15.5 + 1.15.7 test From b1f94216d235acd40263fdeac3b785067986305c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 09:16:26 +0000 Subject: [PATCH 763/933] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b17f6889bc..c5a55609ce 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.15.5 + 1.15.7 test From 2204f9e1467dc588b0652574ec1066b4422ff5d7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:11:08 +0000 Subject: [PATCH 764/933] Update dependency org.springframework.boot:spring-boot-autoconfigure to v3.3.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 90dd0f2ad5..03ce3ebc68 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.16 6.1.14 - 3.3.4 + 3.3.5 5.1.2 org.mybatis.spring From bcb8cf38e3e6593c2a58485236b8a3c936f2afbb Mon Sep 17 00:00:00 2001 From: dongsseop2 Date: Fri, 1 Nov 2024 18:15:12 +0900 Subject: [PATCH 765/933] chore: fix typos --- src/site/ko/markdown/README.md | 2 +- src/site/ko/markdown/batch.md | 56 ++++++++++++------------- src/site/ko/markdown/factorybean.md | 20 ++++----- src/site/ko/markdown/getting-started.md | 16 +++---- src/site/ko/markdown/index.md | 18 ++++---- src/site/ko/markdown/mappers.md | 42 +++++++++---------- src/site/ko/markdown/sqlsession.md | 28 ++++++------- src/site/ko/markdown/transactions.md | 18 ++++---- src/site/ko/markdown/using-api.md | 2 +- 9 files changed, 101 insertions(+), 101 deletions(-) diff --git a/src/site/ko/markdown/README.md b/src/site/ko/markdown/README.md index 4e31a121bc..03cf1d3fa2 100644 --- a/src/site/ko/markdown/README.md +++ b/src/site/ko/markdown/README.md @@ -1,6 +1,6 @@ # 목차 -이 페이지는 GitHub에서 인덱스를 렌더링하기위한 것입니다. +이 페이지는 GitHub에서 인덱스를 렌더링하기 위한 것입니다. > **NOTE:** > diff --git a/src/site/ko/markdown/batch.md b/src/site/ko/markdown/batch.md index 87b11c2600..cdcd9d0b5b 100644 --- a/src/site/ko/markdown/batch.md +++ b/src/site/ko/markdown/batch.md @@ -1,15 +1,15 @@ # Spring Batch -마이바티스 스프링 연동모듈의 1.1.0버전에서는 스프링 배치 애플리케이션을 만들기 위해 세개의 빈을 제공한다. -세개의 빈은 `MyBatisPagingItemReader` 와 `MyBatisCursorItemReader` 와 MyBatisBatchItemWriter이다. +마이바티스 스프링 연동 모듈의 1.1.0버전에서는 스프링 배치 애플리케이션을 만들기 위해 세 개의 빈을 제공한다. +세 개의 빈은 `MyBatisPagingItemReader` 와 `MyBatisCursorItemReader` 와 MyBatisBatchItemWriter이다. 또한 2.0.0 버전에서는 Java Configuration 을 지원하는 다음의 세 가지 Builder class 를 제공한다. `MyBatisPagingItemReaderBuilder`, `MyBatisCursorItemReaderBuilder` 그리고 `MyBatisBatchItemWriterBuilder` 이다. 중요 이 문서는 [스프링 배치](http://static.springsource.org/spring-batch/) 에 대한 것으로 마이바티스 배치 `SqlSession` 을 다루지는 않는다. -배치 세션에 대해서는 [SqlSession 사용](sqlsession.html) 에서 좀더 다루었다. +배치 세션에 대해서는 [SqlSession 사용](sqlsession.html) 에서 좀 더 다루었다. # MyBatisPagingItemReader @@ -17,15 +17,15 @@ 요청된 데이터를 가져오기 위해 `setQueryId` 프로퍼티에 명시된 쿼리를 실행한다. 쿼리는 `setPageSize` 프로퍼티에 명시된 크기만큼 데이터를 가져오도록 실행된다. -`read()` 메서드를 사용하면 필요할 때 현재 위치에서 정해진 수 만큼 더 추가 데이터를 가져온다. -reader는 몇가지의 표준적인 쿼리 파라미터를 제공하고 명명된 쿼리의 SQL은 요청된 크기만큼의 데이터를 만들기 위해 파라미터의 일부 혹은 모두 사용한다. -여기서 사용가능한 파라미터이다. +`read()` 메서드를 사용하면 필요할 때 현재 위치에서 정해진 수만큼 더 추가 데이터를 가져온다. +reader는 몇 가지의 표준적인 쿼리 파라미터를 제공하고 명명된 쿼리의 SQL은 요청된 크기만큼의 데이터를 만들기 위해 파라미터의 일부 혹은 모두 사용한다. +여기서 사용 가능한 파라미터이다. * `_page`: 읽을 페이지 수(0부터 시작) * `_pagesize`: 페이지의 크기, 이를테면 리턴하는 로우 수 * `_skiprows`: `_page` 와 `_pagesize`를 곱한 결과 -각각의 파라미터는 selet구문에서 다음처럼 매핑될 수 있다. +각각의 파라미터는 selet구문에서 다음처럼 매핑 될 수 있다. ```xml select * from Bar -- this should run on database Bar, but actually runs on Foo. - \ No newline at end of file + diff --git a/src/test/resources/org/mybatis/spring/submitted/autowire/FooMapper.xml b/src/test/resources/org/mybatis/spring/submitted/autowire/FooMapper.xml index e67a953870..5e4f07f9a5 100644 --- a/src/test/resources/org/mybatis/spring/submitted/autowire/FooMapper.xml +++ b/src/test/resources/org/mybatis/spring/submitted/autowire/FooMapper.xml @@ -21,4 +21,4 @@ - \ No newline at end of file + From 379daf3b0fc91f4a450d8d35ddd0f397c17e5c00 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Wed, 8 Jan 2025 20:00:30 -0500 Subject: [PATCH 797/933] [mvn] Update maven wrapper --- .mvn/extensions.xml | 2 +- .mvn/settings.xml | 2 +- .mvn/wrapper/MavenWrapperDownloader.java | 3 +-- pom.xml | 2 +- src/site/site.xml | 2 +- .../org/mybatis/spring/annotation/override.properties | 2 +- .../resources/org/mybatis/spring/annotation/scan.properties | 2 +- .../org/mybatis/spring/config/default-scope.properties | 2 +- src/test/resources/org/mybatis/spring/config/lazy.properties | 2 +- .../resources/org/mybatis/spring/config/override.properties | 2 +- .../org/mybatis/spring/filter/config/application.properties | 2 +- .../resources/org/mybatis/spring/filter/xml/default.properties | 2 +- .../org/mybatis/spring/submitted/autowire/BarMapper.xml | 2 +- .../org/mybatis/spring/submitted/autowire/FooMapper.xml | 2 +- 14 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index aeaad3ef68..8a33a856cd 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -1,7 +1,7 @@ 1723410271 From 8c2fdbc246ea48764d72934e921e89ae58a7666b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 19:39:02 +0000 Subject: [PATCH 814/933] chore(deps): update dependency org.slf4j:slf4j-simple to v2.0.17 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b4ce40fd1b..af4f881dda 100644 --- a/pom.xml +++ b/pom.xml @@ -246,7 +246,7 @@ org.slf4j slf4j-simple - 2.0.16 + 2.0.17 test From 6e0e3e27de6178f4e648710b9a8125a281558916 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 12:55:24 +0000 Subject: [PATCH 815/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index af4f881dda..1b35cf9ad7 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.1 + 1.17.2 test From cc6937dcd17797a9c0eb8b3d84d78e6e98c07042 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 12:55:27 +0000 Subject: [PATCH 816/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index af4f881dda..c29beed6e1 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.1 + 1.17.2 test From 86b3177bd6252912dd5d76830e352ce67efd4d2f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 19:45:54 +0000 Subject: [PATCH 817/933] chore(deps): update dependency org.mockito:mockito-core to v5.16.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index af4f881dda..8ed323d49d 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.15.2 + 5.16.0 test From 7da464813bb258d7d7004edb3388c09fb319b159 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 07:41:29 +0000 Subject: [PATCH 818/933] chore(deps): update dependency org.aspectj:aspectjweaver to v1.9.23 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b9732ef63f..820d120e6b 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ org.aspectj aspectjweaver - 1.9.22.1 + 1.9.23 compile true From e74ef3ed17b9870c85f575562a526a7798ee2254 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 07:41:32 +0000 Subject: [PATCH 819/933] fix(deps): update spring core to v6.2.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b9732ef63f..6ee12c41d8 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.3 + 6.2.4 3.4.3 5.2.1 org.mybatis.spring From 2c64093578f713688515fa94577c31c3cfadbbed Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 19:01:38 +0000 Subject: [PATCH 820/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.12.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b9732ef63f..ddaa3c0094 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.1 org.mybatis.spring - 5.12.0 + 5.12.1 1723410271 From 44ad2bc94c347674987017ced6caf57b6b6e76b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 21:49:06 +0000 Subject: [PATCH 821/933] chore(deps): update dependency org.mockito:mockito-core to v5.16.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a5daab297..fb3b3cfba5 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.16.0 + 5.16.1 test From 6771711e47f6f1dc6343742f3662021e0bf28720 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:08:10 +0000 Subject: [PATCH 822/933] fix(deps): update spring batch to v5.2.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fb3b3cfba5..0e81f14778 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ 3.5.19 6.2.4 3.4.3 - 5.2.1 + 5.2.2 org.mybatis.spring 5.12.1 From 925e3aca4185575a0d90fc5f706c4a440d31dfce Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 20:09:59 +0000 Subject: [PATCH 823/933] fix(deps): update spring core to v6.2.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0e81f14778..2518ed6b98 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.4 + 6.2.5 3.4.3 5.2.2 org.mybatis.spring From 659284191fca6c5a698b190e6d62e70ce7e72ab1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 07:10:00 +0000 Subject: [PATCH 824/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.4.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2518ed6b98..8556f39317 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.5 - 3.4.3 + 3.4.4 5.2.2 org.mybatis.spring From d20a11609c7b318951d95d9d66db958a333054f0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:28:53 +0000 Subject: [PATCH 825/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8556f39317..047c6aafdb 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.2 + 1.17.3 test From 269ad85ea7cb8cbb26fcb2aaf2fb66bd8520f6bc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:28:56 +0000 Subject: [PATCH 826/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8556f39317..e335ac8675 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.2 + 1.17.3 test From fad46275227f00fd3ef23a7967860e0406bfc8c4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 03:29:03 +0000 Subject: [PATCH 827/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 329b240102..e2e0589faa 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.3 + 1.17.4 test From ea64da97c29b6431bf5159e0b94b76780f701008 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 03:29:07 +0000 Subject: [PATCH 828/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 329b240102..792b86c51b 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.3 + 1.17.4 test From aab8529e576991fc075ad8319676cf7f96e5ca33 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 11:32:56 +0000 Subject: [PATCH 829/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eda49d3f9d..8df38a1650 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.4 + 1.17.5 test From 3ebebd4bfe350f0d4160dc89b51dd40a481a5da5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 11:32:59 +0000 Subject: [PATCH 830/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eda49d3f9d..0a105e5e46 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.4 + 1.17.5 test From 7f9137a1278c3ea6ed05407b1aa53ddd3d06022b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 14:36:54 +0000 Subject: [PATCH 831/933] chore(deps): update dependency org.mockito:mockito-core to v5.17.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 30d4793613..9cbd9c8e4d 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.16.1 + 5.17.0 test From fe34bf2d11e69b92c3db0428491f19002593de8f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 15:44:00 +0000 Subject: [PATCH 832/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.12.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9cbd9c8e4d..0d6f8b033f 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.2 org.mybatis.spring - 5.12.1 + 5.12.2 1723410271 From 18d3153d845b57a0f55eec974b7db135b9f1e9fa Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 12 Apr 2025 03:29:09 +0000 Subject: [PATCH 833/933] chore(deps): update dependency org.aspectj:aspectjweaver to v1.9.24 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9cbd9c8e4d..aae33cf44c 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ org.aspectj aspectjweaver - 1.9.23 + 1.9.24 compile true From 84fa1cf96cc00cb0c3877772eb3b29ba0cc2aa10 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 10:58:41 +0000 Subject: [PATCH 834/933] fix(deps): update spring core to v6.2.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84cd1a29da..e8e5f03522 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.5 + 6.2.6 3.4.4 5.2.2 org.mybatis.spring From 0aa7ad788dbf0cdf6831fe126200aed4f577e609 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:33:12 +0000 Subject: [PATCH 835/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.4.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e8e5f03522..a72c9582e2 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.6 - 3.4.4 + 3.4.5 5.2.2 org.mybatis.spring From 970999054b7b40dc790d7906420fde976f7cb8ad Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 03:30:23 +0000 Subject: [PATCH 836/933] fix(deps): update dependency org.mybatis:mybatis-parent to v49 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a72c9582e2..825fa88cf1 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.mybatis mybatis-parent - 48 + 49 From e2ee6af43bbbdcbe071ee5f66acca449ee26639c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 17:35:09 +0000 Subject: [PATCH 837/933] chore(deps): update dependency org.jboss.byteman:byteman-bmunit to v4.0.25 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a72c9582e2..237edfc2ac 100644 --- a/pom.xml +++ b/pom.xml @@ -191,7 +191,7 @@ org.jboss.byteman byteman-bmunit - 4.0.24 + 4.0.25 test From d51629f09f268156fd7d984ead68c33631508de4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 13:25:33 +0000 Subject: [PATCH 838/933] fix(deps): update spring core to v6.2.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e87d38a96..65fa32d47a 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.6 + 6.2.7 3.4.5 5.2.2 org.mybatis.spring From e1fc10e6192bea2ff13a32bb5a82d77c038b6ce8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 19:45:37 +0000 Subject: [PATCH 839/933] chore(deps): update dependency org.mockito:mockito-core to v5.18.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 65fa32d47a..0b61f0fada 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.17.0 + 5.18.0 test From 1934d773aadafb2dcbdf07ae7d570169478c98f9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 17:58:24 +0000 Subject: [PATCH 840/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.4.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b61f0fada..4281e8fc59 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.7 - 3.4.5 + 3.4.6 5.2.2 org.mybatis.spring From a2e6e0e4dff35d4dc8b8fd4cd60f0409e4b8be3c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 01:45:48 +0000 Subject: [PATCH 841/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4281e8fc59..2fa5417fd2 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.7 - 3.4.6 + 3.5.0 5.2.2 org.mybatis.spring From b615e53b7b8bfe9f68350204b912bba6db26babb Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 3 May 2025 15:25:46 -0400 Subject: [PATCH 842/933] [gha] Drop jdk 23 and use 24 ga --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 715d7525fa..69dbd87088 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: matrix: cache: [maven] distribution: [temurin] - java: [17, 21, 23, 24-ea] + java: [17, 21, 24, 25-ea] os: [macos-latest, ubuntu-latest, windows-latest] fail-fast: false max-parallel: 4 From 5ae74f64f073e1e4fa662b9fb6e94e51fb691dae Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 3 May 2025 15:25:58 -0400 Subject: [PATCH 843/933] [gha] Cleanup site action --- .github/workflows/site.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 9b99a2b626..99583387a6 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -5,6 +5,9 @@ on: branches: - site +permissions: + contents: write + jobs: build: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') @@ -20,7 +23,6 @@ jobs: - name: Build site run: ./mvnw site site:stage -DskipTests -Dlicense.skip=true -B -V --no-transfer-progress --settings ./.mvn/settings.xml env: - CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NVD_API_KEY: ${{ secrets.NVD_API_KEY }} - name: Deploy Site to gh-pages @@ -28,4 +30,3 @@ jobs: with: branch: gh-pages folder: target/staging - ssh-key: ${{ secrets.DEPLOY_KEY }} From 77bee6c3c7b964c4d0cccc0a9a78b95fa0ca9546 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 3 May 2025 15:26:08 -0400 Subject: [PATCH 844/933] [mvn] Bump maven profiler to 3.3 --- .mvn/extensions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 8a33a856cd..b6c32576a7 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -20,6 +20,6 @@ fr.jcgay.maven maven-profiler - 3.2 + 3.3 From 058cf5e5221291521aa5d414185f7af0530a2ab7 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sat, 3 May 2025 15:26:17 -0400 Subject: [PATCH 845/933] [mvn] Update for central --- .mvn/settings.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.mvn/settings.xml b/.mvn/settings.xml index 503a653bd5..b8e9a63f79 100644 --- a/.mvn/settings.xml +++ b/.mvn/settings.xml @@ -22,7 +22,7 @@ - ossrh + central ${env.CI_DEPLOY_USERNAME} ${env.CI_DEPLOY_PASSWORD} @@ -39,7 +39,6 @@ github - ${env.CI_DEPLOY_USERNAME} ${env.GITHUB_TOKEN} From eac3b171f587c80d811dee0d965049e4a3432dd2 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 26 May 2025 22:38:02 -0400 Subject: [PATCH 846/933] [gha] Update explicit permissions --- .github/workflows/ci.yaml | 2 ++ .github/workflows/codeql.yaml | 2 +- .github/workflows/coveralls.yaml | 2 ++ .github/workflows/sonar.yaml | 2 ++ .github/workflows/sonatype.yaml | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 69dbd87088..1acc3c74e2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,6 +2,8 @@ name: Java CI on: [workflow_dispatch, push, pull_request] +permissions: read-all + jobs: test: runs-on: ${{ matrix.os }} diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 50a5b42388..3040637b68 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -31,8 +31,8 @@ jobs: uses: actions/setup-java@v4 with: cache: maven - java-version: 21 distribution: 'temurin' + java-version: 21 - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 297681d58d..94480dd396 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -2,6 +2,8 @@ name: Coveralls on: [push, pull_request] +permissions: read-all + jobs: coveralls: if: github.repository_owner == 'mybatis' diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 7fda0dbe1b..ca15fbdced 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -5,6 +5,8 @@ on: branches: - master +permissions: read-all + jobs: build: if: github.repository_owner == 'mybatis' diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index c3d8119e13..da1d658141 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -5,6 +5,8 @@ on: branches: - master +permissions: read-all + jobs: build: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') From 73a1de7e3ee23fed82c7be55ad65108fd09f4ef2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 15:21:26 +0000 Subject: [PATCH 847/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fa5417fd2..84d756af15 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.2 org.mybatis.spring - 5.12.2 + 5.13.0 1723410271 From 1a0ba5428a1a02baf7300156cda89976381d5ea4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 31 May 2025 20:42:53 +0000 Subject: [PATCH 848/933] fix(deps): update dependency org.mybatis:mybatis-parent to v50 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fa5417fd2..8bbdce2357 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.mybatis mybatis-parent - 49 + 50 From d4717ac8351a6aa3d24eaaaaa332db5ab91be6d5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 6 Jun 2025 20:54:22 +0000 Subject: [PATCH 849/933] chore(deps): update dependency maven to v3.9.10 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 01aa6654cd..0d35f6dbbc 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -16,5 +16,5 @@ # under the License. wrapperVersion=3.3.2 distributionType=source -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.10/apache-maven-3.9.10-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar From a08c6f502c1fad2c91a4336e3523ea21c54e32e8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 08:38:07 +0000 Subject: [PATCH 850/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bcb92c5aec..2583b2412c 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.2 org.mybatis.spring - 5.13.0 + 5.13.1 1723410271 From 34b01ccc4b9d638e7faab538a6689acd0278222a Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Tue, 10 Jun 2025 03:09:32 +0900 Subject: [PATCH 851/933] [maven-release-plugin] prepare release mybatis-spring-3.0.5 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2583b2412c..4192ec5c7e 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 3.0.5-SNAPSHOT + 3.0.5 mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -80,7 +80,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-3.0.5 https://github.com/mybatis/spring/ @@ -122,7 +122,7 @@ 5.13.1 - 1723410271 + 1749492532 true From 5ac7b6853673c813a52eb52fe0ace70ec43a1fd5 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Tue, 10 Jun 2025 03:09:37 +0900 Subject: [PATCH 852/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4192ec5c7e..6275e62496 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 3.0.5 + 3.0.6-SNAPSHOT mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -80,7 +80,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-3.0.5 + HEAD https://github.com/mybatis/spring/ @@ -122,7 +122,7 @@ 5.13.1 - 1749492532 + 1749492577 true From 965a0ccfcceeef6f386fafa9218130f07781a361 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:13:58 +0000 Subject: [PATCH 853/933] fix(deps): update spring core to v6.2.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6275e62496..803dce1b80 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.7 + 6.2.8 3.5.0 5.2.2 org.mybatis.spring From 61b970aaf452e7119eaeebd258a240fe3b16fe7e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 17:51:46 +0000 Subject: [PATCH 854/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 803dce1b80..abb916b3ad 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.5 + 1.17.6 test From 390921d24824ccdce57b314e5ac6ebb676b32a8a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 17:51:50 +0000 Subject: [PATCH 855/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 803dce1b80..e7e81c4767 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.5 + 1.17.6 test From a3c3fe2e4e254c80ebc80c61ca21e47530268198 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 22:03:19 +0000 Subject: [PATCH 856/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c419e06af0..4cf6f5ffb0 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.8 - 3.5.0 + 3.5.2 5.2.2 org.mybatis.spring From ef7aadea8793de554c9cb0975fd1338cdee5f16a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 06:40:35 +0000 Subject: [PATCH 857/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4cf6f5ffb0..2f31daf235 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.8 - 3.5.2 + 3.5.3 5.2.2 org.mybatis.spring From 02aebae0cc904abd379a79472eab2d0c395b39f4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Jun 2025 13:37:55 +0000 Subject: [PATCH 858/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2f31daf235..4c4097906c 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.2 org.mybatis.spring - 5.13.1 + 5.13.2 1749492577 From f54434de9a5bb5dcbc56e0bebf9b31ce994587d7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 17:52:04 +0000 Subject: [PATCH 859/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c4097906c..5eb4c38aa7 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.2 org.mybatis.spring - 5.13.2 + 5.13.3 1749492577 From 8659d43a3c5fc58a850595b672e430f13d78e227 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 23:43:19 +0000 Subject: [PATCH 860/933] chore(deps): update dependency maven to v3.9.11 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 0d35f6dbbc..b06697c613 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -16,5 +16,5 @@ # under the License. wrapperVersion=3.3.2 distributionType=source -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.10/apache-maven-3.9.10-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar From f5d327504436798cb8218425b59041f6b4a2ada8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:10:54 +0000 Subject: [PATCH 861/933] fix(deps): update spring core to v6.2.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5eb4c38aa7..865760087b 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.8 + 6.2.9 3.5.3 5.2.2 org.mybatis.spring From c49eb169d96653f2659c99452463725f5df15544 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 10:48:26 +0000 Subject: [PATCH 862/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 865760087b..11479ae2f2 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.2 org.mybatis.spring - 5.13.3 + 5.13.4 1749492577 From b2cbe031c413774c55f1251291860a63b940c86e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 24 Jul 2025 14:32:45 +0000 Subject: [PATCH 863/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 11479ae2f2..5d1cc9d217 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.9 - 3.5.3 + 3.5.4 5.2.2 org.mybatis.spring From 04a3351b78529aaa665557fcbac719ee4bdb09df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:28:56 +0000 Subject: [PATCH 864/933] chore(deps): update dependency org.assertj:assertj-core to v3.27.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d1cc9d217..5fd255fae7 100644 --- a/pom.xml +++ b/pom.xml @@ -260,7 +260,7 @@ org.assertj assertj-core - 3.27.3 + 3.27.4 test From 579bd2ed513002cbc4f61f48aa50cb9ad3ba423d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 13:14:55 +0000 Subject: [PATCH 865/933] chore(deps): update actions/checkout action to v5 --- .github/workflows/ci.yaml | 2 +- .github/workflows/codeql.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/site.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1acc3c74e2..78ed1c4db4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} uses: actions/setup-java@v4 with: diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 3040637b68..6fc9ec0d66 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Java uses: actions/setup-java@v4 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 94480dd396..9e1863a032 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -9,7 +9,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 99583387a6..91af53ef5b 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -13,7 +13,7 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index ca15fbdced..5c76582abb 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -12,7 +12,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index da1d658141..6c098ec19c 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -12,7 +12,7 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Java uses: actions/setup-java@v4 with: From 7d8fb1e42b82232b39da486a2269a1fde189dd06 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:20:47 +0000 Subject: [PATCH 866/933] fix(deps): update spring core to v6.2.10 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5fd255fae7..058262bb32 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.9 + 6.2.10 3.5.4 5.2.2 org.mybatis.spring From d964a13667721dbd7100b7ef3054be96e668ad69 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:13:08 +0000 Subject: [PATCH 867/933] chore(deps): update dependency org.mockito:mockito-core to v5.19.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5fd255fae7..8cb6730f4c 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.18.0 + 5.19.0 test From 4e0e5039195f5425ca1b592f9946c42c19446823 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Aug 2025 02:14:55 +0000 Subject: [PATCH 868/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0232e1976f..e13029f88b 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.6 + 1.17.7 test From f59fcb15472d9ecd5a043f7e10ad373fd2531cde Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Aug 2025 02:14:58 +0000 Subject: [PATCH 869/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0232e1976f..f7ded0b303 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.6 + 1.17.7 test From d5c55a601faf7558b465a6694b8c1591bd88a282 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 04:49:34 +0000 Subject: [PATCH 870/933] chore(deps): update actions/setup-java action to v5 --- .github/workflows/ci.yaml | 2 +- .github/workflows/codeql.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/site.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 78ed1c4db4..fa9e1d17ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: cache: ${{ matrix.cache }} distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 6fc9ec0d66..1855cb9df9 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v5 - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: cache: maven distribution: 'temurin' diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 9e1863a032..54044db381 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: cache: maven distribution: temurin diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 91af53ef5b..cfd7c23c72 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: cache: maven distribution: temurin diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 5c76582abb..25c0b88ec5 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -17,7 +17,7 @@ jobs: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: cache: maven distribution: temurin diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 6c098ec19c..23bf66596a 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: cache: maven distribution: temurin From ebcff9f6e8b2653cf0a3c2e83cb369289ae962fc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 17:08:55 +0000 Subject: [PATCH 871/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2e0824606..3352884ae4 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.10 - 3.5.4 + 3.5.5 5.2.2 org.mybatis.spring From 2518f44fd133bf99798dc54a94ad2ad58bd0d618 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 10:15:40 +0000 Subject: [PATCH 872/933] fix(deps): update spring core to v6.2.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3352884ae4..16657a90c1 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.10 + 6.2.11 3.5.5 5.2.2 org.mybatis.spring From b6d1059cd24202b439e85d2e6a578e50a497dc35 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 19:18:41 +0000 Subject: [PATCH 873/933] fix(deps): update spring batch to v5.2.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16657a90c1..0a1915338a 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ 3.5.19 6.2.11 3.5.5 - 5.2.2 + 5.2.3 org.mybatis.spring 5.13.4 From 3fade87831c4a21c0720e8ef4593567b9a575841 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 14:45:09 +0000 Subject: [PATCH 874/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a1915338a..7d3a45752b 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.11 - 3.5.5 + 3.5.6 5.2.3 org.mybatis.spring From f87888f4f47d71d73c8944f230efa9b2d91bcd67 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 01:02:21 +0000 Subject: [PATCH 875/933] chore(deps): update dependency org.assertj:assertj-core to v3.27.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a1915338a..3fdc1087c5 100644 --- a/pom.xml +++ b/pom.xml @@ -260,7 +260,7 @@ org.assertj assertj-core - 3.27.4 + 3.27.5 test From 84fca6ef90f3adb19a14b9fc54f0bd06d2fcaf04 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 13:27:01 +0000 Subject: [PATCH 876/933] chore(deps): update dependency org.mockito:mockito-core to v5.20.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1621c5e865..8c54b73dac 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-core - 5.19.0 + 5.20.0 test From 98d5b7c84d38c01e151b41d4206b927523c19379 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 17:46:41 +0000 Subject: [PATCH 877/933] chore(deps): update dependency org.assertj:assertj-core to v3.27.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c54b73dac..aabeb6cfe1 100644 --- a/pom.xml +++ b/pom.xml @@ -260,7 +260,7 @@ org.assertj assertj-core - 3.27.5 + 3.27.6 test From 76cced8e16c93627a9524398135b27c51ff8b4e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 10:57:05 +0000 Subject: [PATCH 878/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aabeb6cfe1..f918323d72 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.3 org.mybatis.spring - 5.13.4 + 6.0.0 1749492577 From e41555bf3a0cf2067304b26aa10c2eae708550a5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 5 Oct 2025 01:39:40 +0000 Subject: [PATCH 879/933] fix(deps): update dependency org.mybatis:mybatis-parent to v51 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f918323d72..3f30da9b3c 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.mybatis mybatis-parent - 50 + 51 From fa7d259d42afcc708ebe50348f792965afc6a393 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:36:52 +0000 Subject: [PATCH 880/933] chore(deps): update github/codeql-action action to v4 --- .github/workflows/codeql.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 1855cb9df9..f620d67e18 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -35,15 +35,15 @@ jobs: java-version: 21 - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v4 with: category: "/language:${{ matrix.language }}" From 337870a67f64b8bd6d0cec45c2785b8ac8b26010 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 00:24:50 +0000 Subject: [PATCH 881/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f30da9b3c..3a7c9534c2 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.7 + 1.17.8 test From 15be4e9499baf2d5d6c51dd07687be3447962fdd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 00:24:53 +0000 Subject: [PATCH 882/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.17.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f30da9b3c..5d7dc54d84 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.7 + 1.17.8 test From 5696fa1b1b945e051937b3fa528f56a43fa903c2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 14:44:37 +0000 Subject: [PATCH 883/933] chore(deps): update dependency org.jboss.byteman:byteman-bmunit to v4.0.26 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 628f39e533..1e6d56fad3 100644 --- a/pom.xml +++ b/pom.xml @@ -191,7 +191,7 @@ org.jboss.byteman byteman-bmunit - 4.0.25 + 4.0.26 test From a3c99ee304999c1f53c74025b93b13a064ee4009 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 08:42:58 +0000 Subject: [PATCH 884/933] fix(deps): update spring core to v6.2.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 628f39e533..6434c34e73 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.11 + 6.2.12 3.5.6 5.2.3 org.mybatis.spring From 457779c933958f092074a025dd226bd02f7ddc37 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 Oct 2025 18:32:31 +0000 Subject: [PATCH 885/933] fix(deps): update spring batch to v5.2.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ee9fedd490..57e5956446 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ 3.5.19 6.2.12 3.5.6 - 5.2.3 + 5.2.4 org.mybatis.spring 6.0.0 From 794959baa0cb1d6e6c6e96e0ae77ecd492462c6d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:24:37 +0000 Subject: [PATCH 886/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 57e5956446..ea7e841798 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 6.2.12 - 3.5.6 + 3.5.7 5.2.4 org.mybatis.spring From 19d4c977e96952d3c0d936417a003efb3fe7c097 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Oct 2025 18:52:17 +0000 Subject: [PATCH 887/933] chore(deps): update dependency org.junit.jupiter:junit-jupiter-engine to v6.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea7e841798..a3dea7dcfb 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 5.2.4 org.mybatis.spring - 6.0.0 + 6.0.1 1749492577 From 911833e5be31a8b70b14259fba5f0d9feeaf2729 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 07:50:42 +0000 Subject: [PATCH 888/933] chore(deps): update dependency org.aspectj:aspectjweaver to v1.9.25 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a3dea7dcfb..7ef4c359e0 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ org.aspectj aspectjweaver - 1.9.24 + 1.9.25 compile true From b4e247c55c1fa4ca537ac1c22fc3c9c8cc8fb43f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Nov 2025 09:59:59 +0000 Subject: [PATCH 889/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.18.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ef4c359e0..ef42b74bbb 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.17.8 + 1.18.0 test From aab2dc188fe8afa92354f6f3e83d6934bb784100 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Nov 2025 10:00:02 +0000 Subject: [PATCH 890/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.18.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ef4c359e0..e76c0f9304 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.17.8 + 1.18.0 test From 70115746a75f1153478160424a1efdfec30f0b96 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 17:51:58 +0000 Subject: [PATCH 891/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.18.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6762ac241..816ad41cda 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.18.0 + 1.18.1 test From fb0e929e6016031e7017cfcda66f3009f4f9e8e7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 17:52:03 +0000 Subject: [PATCH 892/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.18.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6762ac241..534a6acb43 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.18.0 + 1.18.1 test From de32c936e16648f38c3c47cb0bc50730aef0027a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:51:00 +0000 Subject: [PATCH 893/933] fix(deps): update spring core to v7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6762ac241..54b8074f59 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 6.2.12 + 7.0.0 3.5.7 5.2.4 org.mybatis.spring From bf80433c90dc3af4e4a20299f6d45ede88fea796 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:10:09 +0000 Subject: [PATCH 894/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v3.5.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 35d31cb75e..6e315451a5 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 7.0.0 - 3.5.7 + 3.5.8 5.2.4 org.mybatis.spring From fb3f26b0da1c9488c0e8be941baa376b4a87366e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:10:17 +0000 Subject: [PATCH 895/933] chore(deps): update actions/checkout action to v6 --- .github/workflows/ci.yaml | 2 +- .github/workflows/codeql.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/site.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fa9e1d17ae..99f47e8077 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} uses: actions/setup-java@v5 with: diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index f620d67e18..93f0f17e67 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Setup Java uses: actions/setup-java@v5 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 54044db381..0ca4f8f7fc 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -9,7 +9,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Java uses: actions/setup-java@v5 with: diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index cfd7c23c72..a5828d47f2 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -13,7 +13,7 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Java uses: actions/setup-java@v5 with: diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 25c0b88ec5..d6b918b141 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -12,7 +12,7 @@ jobs: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 23bf66596a..3e3d513d1c 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -12,7 +12,7 @@ jobs: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Java uses: actions/setup-java@v5 with: From 851d25421fe4758ab4d190c215778e474cecc1a4 Mon Sep 17 00:00:00 2001 From: Mingyuan Wu Date: Fri, 21 Nov 2025 08:37:20 +0800 Subject: [PATCH 896/933] update spring batch to v6 --- pom.xml | 4 ++-- .../mybatis/spring/batch/MyBatisBatchItemWriter.java | 6 +++--- .../spring/batch/MyBatisCursorItemReader.java | 4 ++-- .../spring/batch/MyBatisPagingItemReader.java | 4 ++-- .../spring/batch/MyBatisBatchItemWriterTest.java | 4 ++-- .../spring/batch/MyBatisCursorItemReaderTest.java | 6 +++--- .../org/mybatis/spring/batch/SpringBatchTest.java | 4 ++-- .../builder/MyBatisBatchItemWriterBuilderTest.java | 4 ++-- .../builder/MyBatisCursorItemReaderBuilderTest.java | 4 ++-- .../builder/MyBatisPagingItemReaderBuilderTest.java | 4 ++-- .../mybatis/spring/sample/AbstractSampleJobTest.java | 4 ++-- .../sample/batch/UserToPersonItemProcessor.java | 4 ++-- .../spring/sample/config/SampleJobConfig.java | 12 ++++++------ .../spring/sample/config/applicationContext-job.xml | 7 +++++-- 14 files changed, 37 insertions(+), 34 deletions(-) diff --git a/pom.xml b/pom.xml index 35d31cb75e..0f60fe20e6 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 3.0.6-SNAPSHOT + 4.0.0-SNAPSHOT mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -116,7 +116,7 @@ 3.5.19 7.0.0 3.5.7 - 5.2.4 + 6.0.0 org.mybatis.spring 6.0.1 diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index 9999275ba2..0015db9bd9 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ import org.mybatis.logging.Logger; import org.mybatis.logging.LoggerFactory; import org.mybatis.spring.SqlSessionTemplate; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ItemWriter; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.convert.converter.Converter; import org.springframework.dao.EmptyResultDataAccessException; diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java index 8bc0b3330c..520463ede7 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; -import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; +import org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.beans.factory.InitializingBean; /** diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index c459c39c59..1ef247a6ba 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionTemplate; -import org.springframework.batch.item.database.AbstractPagingItemReader; +import org.springframework.batch.infrastructure.item.database.AbstractPagingItemReader; /** * {@code org.springframework.batch.item.ItemReader} for reading database records using MyBatis in a paging fashion. diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index c38083996d..d14262b3bb 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.mockito.MockitoAnnotations; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.batch.domain.Employee; -import org.springframework.batch.item.Chunk; +import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.InvalidDataAccessResourceUsageException; diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index 965fa84336..fbaf4b3c85 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamException; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemStreamException; /** * Tests for {@link MyBatisCursorItemReader}. diff --git a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java index f2eb2034d4..76ee5a1e34 100644 --- a/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java +++ b/src/test/java/org/mybatis/spring/batch/SpringBatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.apache.ibatis.session.SqlSession; import org.junit.jupiter.api.Test; import org.mybatis.spring.batch.domain.Employee; -import org.springframework.batch.item.Chunk; +import org.springframework.batch.infrastructure.item.Chunk; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index a39fc45e93..08c1a0a6b5 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mybatis.spring.SqlSessionTemplate; -import org.springframework.batch.item.Chunk; +import org.springframework.batch.infrastructure.item.Chunk; /** * Tests for {@link MyBatisBatchItemWriterBuilder}. diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index dbad275cd8..5cc91f21f1 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ExecutionContext; /** * Tests for {@link MyBatisCursorItemReaderBuilder}. diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index e1f1961f04..7806da99dc 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ExecutionContext; /** * Tests for {@link MyBatisPagingItemReaderBuilder}. diff --git a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java index b076e29469..8741445b32 100644 --- a/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java +++ b/src/test/java/org/mybatis/spring/sample/AbstractSampleJobTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.springframework.batch.core.Job; +import org.springframework.batch.core.job.Job; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; diff --git a/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java b/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java index b09e21f13d..0a00fc6628 100644 --- a/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java +++ b/src/test/java/org/mybatis/spring/sample/batch/UserToPersonItemProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import org.mybatis.spring.sample.domain.Person; import org.mybatis.spring.sample.domain.User; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; public class UserToPersonItemProcessor implements ItemProcessor { diff --git a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java index 8c6fbd8e12..ed944a54c1 100644 --- a/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java +++ b/src/test/java/org/mybatis/spring/sample/config/SampleJobConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,15 +31,15 @@ import org.mybatis.spring.sample.batch.UserToPersonItemProcessor; import org.mybatis.spring.sample.domain.Person; import org.mybatis.spring.sample.domain.User; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.Step; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemReader; +import org.springframework.batch.infrastructure.item.ItemWriter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; diff --git a/src/test/resources/org/mybatis/spring/sample/config/applicationContext-job.xml b/src/test/resources/org/mybatis/spring/sample/config/applicationContext-job.xml index 0f25fba78d..b6423d874f 100644 --- a/src/test/resources/org/mybatis/spring/sample/config/applicationContext-job.xml +++ b/src/test/resources/org/mybatis/spring/sample/config/applicationContext-job.xml @@ -1,7 +1,7 @@ - 1749492577 + 1764514347 true From 1b813f427f93185cec44f5db977d1bacd35468a2 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Sun, 30 Nov 2025 23:53:13 +0900 Subject: [PATCH 905/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 752a715864..1b9ae40e51 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 4.0.0 + 4.0.1-SNAPSHOT mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -80,7 +80,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-4.0.0 + HEAD https://github.com/mybatis/spring/ @@ -122,7 +122,7 @@ 6.0.1 - 1764514347 + 1764514393 true From 84fe1cc2808d031c87e301ac40720e47b9413ef3 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 6 Jul 2025 15:28:48 -0400 Subject: [PATCH 906/933] Cleanup mockito tests by using extend with instead of legacy open mocks --- pom.xml | 2 +- .../batch/MyBatisBatchItemWriterTest.java | 10 +-- .../batch/MyBatisCursorItemReaderTest.java | 11 +-- .../MyBatisBatchItemWriterBuilderTest.java | 28 +++---- .../MyBatisCursorItemReaderBuilderTest.java | 6 +- .../MyBatisPagingItemReaderBuilderTest.java | 75 ++++++++++--------- 6 files changed, 65 insertions(+), 67 deletions(-) diff --git a/pom.xml b/pom.xml index 1b9ae40e51..7b6e481c2a 100644 --- a/pom.xml +++ b/pom.xml @@ -252,7 +252,7 @@ org.mockito - mockito-core + mockito-junit-jupiter 5.20.0 test diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java index d14262b3bb..a65d1a17d5 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisBatchItemWriterTest.java @@ -29,12 +29,12 @@ import org.apache.ibatis.executor.BatchResult; import org.apache.ibatis.session.ExecutorType; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.batch.domain.Employee; import org.springframework.batch.infrastructure.item.Chunk; @@ -44,6 +44,7 @@ /** * @author Putthiphong Boonphong */ +@ExtendWith(MockitoExtension.class) class MyBatisBatchItemWriterTest { @Mock @@ -52,11 +53,6 @@ class MyBatisBatchItemWriterTest { @InjectMocks private MyBatisBatchItemWriter writer; - @BeforeEach - void setUp() { - MockitoAnnotations.openMocks(this); - } - @Test void testZeroBatchResultShouldThrowException() { Chunk employees = Chunk.of(new Employee(), new Employee()); diff --git a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java index fbaf4b3c85..d37198a0b8 100644 --- a/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java +++ b/src/test/java/org/mybatis/spring/batch/MyBatisCursorItemReaderTest.java @@ -26,17 +26,18 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.batch.infrastructure.item.ExecutionContext; import org.springframework.batch.infrastructure.item.ItemStreamException; /** * Tests for {@link MyBatisCursorItemReader}. */ +@ExtendWith(MockitoExtension.class) class MyBatisCursorItemReaderTest { @Mock @@ -48,16 +49,10 @@ class MyBatisCursorItemReaderTest { @Mock private Cursor cursor; - @BeforeEach - void setUp() { - MockitoAnnotations.openMocks(this); - } - @Test void testCloseOnFailing() throws Exception { Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.SIMPLE)).thenReturn(this.sqlSession); - Mockito.when(this.cursor.iterator()).thenReturn(getFoos().iterator()); Mockito.when(this.sqlSession.selectCursor("selectFoo", Collections.singletonMap("id", 1))) .thenThrow(new RuntimeException("error.")); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java index 08c1a0a6b5..3075a72983 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilderTest.java @@ -34,9 +34,10 @@ import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.batch.infrastructure.item.Chunk; @@ -47,6 +48,7 @@ * * @author Kazuki Shimizu */ +@ExtendWith(MockitoExtension.class) class MyBatisBatchItemWriterBuilderTest { @Mock @@ -60,19 +62,17 @@ class MyBatisBatchItemWriterBuilderTest { @BeforeEach void setUp() { - MockitoAnnotations.openMocks(this); - { - var configuration = new Configuration(); - var environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); - configuration.setEnvironment(environment); - Mockito.when(this.sqlSessionFactory.getConfiguration()).thenReturn(configuration); - Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.BATCH)).thenReturn(this.sqlSession); - } - { - var result = new BatchResult(null, null); - result.setUpdateCounts(new int[] { 1 }); - Mockito.when(this.sqlSession.flushStatements()).thenReturn(Collections.singletonList(result)); - } + + var configuration = new Configuration(); + var environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); + configuration.setEnvironment(environment); + Mockito.when(this.sqlSessionFactory.getConfiguration()).thenReturn(configuration); + Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.BATCH)).thenReturn(this.sqlSession); + + var result = new BatchResult(null, null); + result.setUpdateCounts(new int[] { 1 }); + Mockito.when(this.sqlSession.flushStatements()).thenReturn(Collections.singletonList(result)); + } @Test diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java index 5cc91f21f1..fddf3aec65 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilderTest.java @@ -28,9 +28,10 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.batch.infrastructure.item.ExecutionContext; /** @@ -40,6 +41,7 @@ * * @author Kazuki Shimizu */ +@ExtendWith(MockitoExtension.class) class MyBatisCursorItemReaderBuilderTest { @Mock @@ -53,8 +55,6 @@ class MyBatisCursorItemReaderBuilderTest { @BeforeEach void setUp() { - MockitoAnnotations.openMocks(this); - Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.SIMPLE)).thenReturn(this.sqlSession); Mockito.when(this.cursor.iterator()).thenReturn(getFoos().iterator()); Map parameters = new HashMap<>(); diff --git a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java index 7806da99dc..18fd13333e 100644 --- a/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java +++ b/src/test/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilderTest.java @@ -32,9 +32,12 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.batch.infrastructure.item.ExecutionContext; /** @@ -44,6 +47,8 @@ * * @author Kazuki Shimizu */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) class MyBatisPagingItemReaderBuilderTest { @Mock @@ -57,8 +62,6 @@ class MyBatisPagingItemReaderBuilderTest { @BeforeEach void setUp() { - MockitoAnnotations.openMocks(this); - var configuration = new Configuration(); var environment = new Environment("unittest", new JdbcTransactionFactory(), dataSource); configuration.setEnvironment(environment); @@ -70,19 +73,21 @@ void setUp() { parameters.put("_page", 0); parameters.put("_pagesize", 10); parameters.put("_skiprows", 0); + + // Most tests are using this, lenient as a result on class. Mockito.when(this.sqlSession.selectList("selectFoo", parameters)).thenReturn(getFoos()); } @Test void testConfiguration() throws Exception { // @formatter:off - var itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); var executionContext = new ExecutionContext(); @@ -102,14 +107,14 @@ void testConfiguration() throws Exception { @Test void testConfigurationSaveStateIsFalse() throws Exception { // @formatter:off - var itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .saveState(false) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .saveState(false) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); var executionContext = new ExecutionContext(); @@ -126,14 +131,14 @@ void testConfigurationSaveStateIsFalse() throws Exception { @Test void testConfigurationMaxItemCount() throws Exception { // @formatter:off - var itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .maxItemCount(2) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .maxItemCount(2) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); var executionContext = new ExecutionContext(); @@ -151,14 +156,14 @@ void testConfigurationMaxItemCount() throws Exception { @Test void testConfigurationPageSize() throws Exception { // @formatter:off - var itemReader = new MyBatisPagingItemReaderBuilder() - .sqlSessionFactory(this.sqlSessionFactory) - .queryId("selectFoo") - .parameterValues(Collections.singletonMap("id", 1)) - .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) - .pageSize(2) - .build(); - // @formatter:on + var itemReader = new MyBatisPagingItemReaderBuilder() + .sqlSessionFactory(this.sqlSessionFactory) + .queryId("selectFoo") + .parameterValues(Collections.singletonMap("id", 1)) + .parameterValuesSupplier(() -> Collections.singletonMap("name", "Doe")) + .pageSize(2) + .build(); + // @formatter:on itemReader.afterPropertiesSet(); Map parameters = new HashMap<>(); @@ -167,6 +172,8 @@ void testConfigurationPageSize() throws Exception { parameters.put("name", "Doe"); parameters.put("_pagesize", 2); parameters.put("_skiprows", 0); + + // The initial mock on this needed repeated here, lenient as a result on class. Mockito.when(this.sqlSession.selectList("selectFoo", parameters)).thenReturn(getFoos()); var executionContext = new ExecutionContext(); From 727550da6942b1cd98b8405b096940c87ee4754e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 12:31:31 -0500 Subject: [PATCH 907/933] [mvn] Update maven wrapper --- .mvn/jvm.config | 0 .mvn/maven.config | 1 + .mvn/wrapper/MavenWrapperDownloader.java | 9 ++++--- .mvn/wrapper/maven-wrapper.properties | 20 ++------------ mvnw | 33 +++++++++++++++--------- mvnw.cmd | 22 +++++++++------- 6 files changed, 43 insertions(+), 42 deletions(-) create mode 100644 .mvn/jvm.config diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.mvn/maven.config b/.mvn/maven.config index afdcfab795..f996a0db0b 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1,2 +1,3 @@ -Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 -Daether.connector.smartChecksums=false +--no-transfer-progress diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index 9439f285a5..b79c3b637f 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -29,7 +29,7 @@ import java.util.concurrent.ThreadLocalRandom; public final class MavenWrapperDownloader { - private static final String WRAPPER_VERSION = "3.3.2"; + private static final String WRAPPER_VERSION = "3.3.4"; private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE")); @@ -44,8 +44,11 @@ public static void main(String[] args) { try { log(" - Downloader started"); final URL wrapperUrl = URI.create(args[0]).toURL(); - final String jarPath = args[1].replace("..", ""); // Sanitize path - final Path wrapperJarPath = Path.of(jarPath).toAbsolutePath().normalize(); + final Path baseDir = Path.of(".").toAbsolutePath().normalize(); + final Path wrapperJarPath = baseDir.resolve(args[1]).normalize(); + if (!wrapperJarPath.startsWith(baseDir)) { + throw new IOException("Invalid path: outside of allowed directory"); + } downloadFileFromURL(wrapperUrl, wrapperJarPath); log("Done"); } catch (IOException e) { diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index b06697c613..ad003123f9 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,20 +1,4 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -wrapperVersion=3.3.2 distributionType=source distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar +wrapperVersion=3.3.4 diff --git a/mvnw b/mvnw index 6683888259..da7a37009b 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.3.2 +# Apache Maven Wrapper startup batch script, version 3.3.4 # # Required ENV vars: # ------------------ @@ -201,6 +201,14 @@ MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} export MAVEN_PROJECTBASEDIR log "$MAVEN_PROJECTBASEDIR" +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. @@ -212,15 +220,13 @@ else log "Couldn't find $wrapperJarPath, downloading it ..." if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" fi while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') case "$key" in wrapperUrl) - wrapperUrl="$safeValue" + wrapperUrl=$(trim "${value-}") break ;; esac @@ -235,17 +241,17 @@ else log "Found wget ... using wget" [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget ${QUIET:+"$QUIET"} "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget ${QUIET:+"$QUIET"} --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" fi elif command -v curl >/dev/null; then log "Found curl ... using curl" [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + curl ${QUIET:+"$QUIET"} -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + curl ${QUIET:+"$QUIET"} --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" fi else log "Falling back to using Java to download" @@ -276,7 +282,7 @@ fi wrapperSha256Sum="" while IFS="=" read -r key value; do case "$key" in wrapperSha256Sum) - wrapperSha256Sum=$value + wrapperSha256Sum=$(trim "${value-}") break ;; esac @@ -284,7 +290,7 @@ done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" if [ -n "$wrapperSha256Sum" ]; then wrapperSha256Result=false if command -v sha256sum >/dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c - >/dev/null 2>&1; then wrapperSha256Result=true fi elif command -v shasum >/dev/null; then @@ -321,6 +327,8 @@ fi MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" export MAVEN_CMD_LINE_ARGS +# Maven main class is here to fix maven 4.0.0-beta-5 through 4.0.0-rc-4 +MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain # shellcheck disable=SC2086 # safe args @@ -329,4 +337,5 @@ exec "$JAVACMD" \ $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.mainClass=${MAVEN_MAIN_CLASS}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index da4fe4dd93..4d22d665ea 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM Apache Maven Wrapper startup batch script, version 3.3.4 @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -117,9 +117,12 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" + +@REM Maven main class is here to fix maven 4.0.0-beta-5 through 4.0.0-rc-4 +set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B @@ -133,7 +136,7 @@ if exist %WRAPPER_JAR% ( ) ) else ( if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" ) if "%MVNW_VERBOSE%" == "true" ( echo Couldn't find %WRAPPER_JAR%, downloading it ... @@ -141,12 +144,12 @@ if exist %WRAPPER_JAR% ( ) powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ - "}" + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" if "%MVNW_VERBOSE%" == "true" ( echo Finished downloading %WRAPPER_JAR% ) @@ -182,6 +185,7 @@ set MAVEN_CMD_LINE_ARGS=%* %MAVEN_DEBUG_OPTS% ^ -classpath %WRAPPER_JAR% ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + "-Dmaven.mainClass=%MAVEN_MAIN_CLASS%" ^ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end From 1af8db7952d0a4beb4bd45ab440ca9dfbf3ed21e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 12:33:58 -0500 Subject: [PATCH 908/933] [gha] Update actions --- .github/workflows/ci.yaml | 15 ++++++++++----- .github/workflows/codeql.yaml | 30 +++++++++++++----------------- .github/workflows/coveralls.yaml | 17 ++++++++++++----- .github/workflows/site.yaml | 15 ++++++++++----- .github/workflows/sonar.yaml | 19 +++++++++++++++---- .github/workflows/sonatype.yaml | 13 +++++++++---- 6 files changed, 69 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 99f47e8077..acc46d6446 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,26 +4,31 @@ on: [workflow_dispatch, push, pull_request] permissions: read-all +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: runs-on: ${{ matrix.os }} + timeout-minutes: 30 strategy: matrix: cache: [maven] distribution: [temurin] - java: [17, 21, 24, 25-ea] + java: [21, 25, 26-ea] os: [macos-latest, ubuntu-latest, windows-latest] fail-fast: false - max-parallel: 4 + max-parallel: 6 name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} - uses: actions/setup-java@v5 + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: cache: ${{ matrix.cache }} distribution: ${{ matrix.distribution }} java-version: ${{ matrix.java }} - name: Test with Maven - run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" + run: ./mvnw test --batch-mode --no-transfer-progress --show-version -D"license.skip=true" diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 93f0f17e67..45b5818b5d 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -6,44 +6,40 @@ on: pull_request: branches: [ master ] schedule: - - cron: '37 14 * * 6' + - cron: '43 10 * * 2' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: analyze: name: Analyze - runs-on: ubuntu-latest - timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + runs-on: 'ubuntu-latest' + timeout-minutes: 30 permissions: actions: read contents: read security-events: write - strategy: - fail-fast: false - matrix: - language: [ java-kotlin ] - steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: cache: maven distribution: 'temurin' - java-version: 21 + java-version: 25 - name: Initialize CodeQL - uses: github/codeql-action/init@v4 + uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 with: - languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v4 + uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 - with: - category: "/language:${{ matrix.language }}" + uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 0ca4f8f7fc..beb604ca9e 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -4,26 +4,33 @@ on: [push, pull_request] permissions: read-all +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: coveralls: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: cache: maven distribution: temurin - java-version: 21 + java-version: 25 + - name: Run the build + run: ./mvnw test --batch-mode --no-transfer-progress --quiet --show-version -Dlicense.skip=true - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' - run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER --no-transfer-progress + run: ./mvnw generate-sources jacoco:report coveralls:report --batch-mode --no-transfer-progress -DpullRequest=${{ env.PR_NUMBER }} -DrepoToken=${{ env.GITHUB_TOKEN }} -DserviceName=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} - name: Report Coverage to Coveralls for General Push if: github.event_name == 'push' - run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github --no-transfer-progress + run: ./mvnw generate-sources jacoco:report coveralls:report --batch-mode --no-transfer-progress -DrepoToken=${{ env.GITHUB_TOKEN }} -DserviceName=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index a5828d47f2..59df4a2df7 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -8,25 +8,30 @@ on: permissions: contents: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest + timeout-minutes: 60 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: cache: maven distribution: temurin - java-version: 21 + java-version: 25 - name: Build site - run: ./mvnw site site:stage -DskipTests -Dlicense.skip=true -B -V --no-transfer-progress --settings ./.mvn/settings.xml + run: ./mvnw site site:stage --batch-mode --no-transfer-progress --settings ./.mvn/settings.xml --show-version -Dlicense.skip=true -DskipTests env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NVD_API_KEY: ${{ secrets.NVD_API_KEY }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@v4 + uses: JamesIves/github-pages-deploy-action@4a3abc783e1a24aeb44c16e869ad83caf6b4cc23 # v4 with: branch: gh-pages folder: target/staging diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index d6b918b141..72d43afe75 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -7,23 +7,34 @@ on: permissions: read-all +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + SONAR_ORGANIZATION: mybatis + SONAR_PROJECT_KEY: spring + jobs: build: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: cache: maven distribution: temurin - java-version: 21 + java-version: 25 + - name: Set SONAR_SCANNER_JAVA_OPTS + run: echo "SONAR_SCANNER_JAVA_OPTS=-Xmx512m" >> ${GITHUB_ENV} - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -V -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress -Dsonar.scanner.skipJreProvisioning=true + run: ./mvnw verify jacoco:report sonar:sonar --batch-mode --no-transfer-progress --show-version -Dlicense.skip=true -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=${{ env.SONAR_ORGANIZATION }} -Dsonar.projectKey=${{ env.SONAR_ORGANIZATION }}_${{ env.SONAR_PROJECT_KEY }} -Dsonar.scanner.skipJreProvisioning=true -Dsonar.token=${{ env.SONAR_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 3e3d513d1c..19862d2e53 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -7,20 +7,25 @@ on: permissions: read-all +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: cache: maven distribution: temurin - java-version: 21 + java-version: 25 - name: Deploy to Sonatype - run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true + run: ./mvnw deploy --batch-mode --no-transfer-progress --settings ./.mvn/settings.xml --show-version -Dlicense.skip=true -DskipTests env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} From 9de4f1f8df74d9c576353b3d926c90328aeec0ab Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:14:07 -0500 Subject: [PATCH 909/933] [javadocs] Fix invalid usage of 'p' tags --- src/main/java/org/mybatis/spring/annotation/MapperScan.java | 5 +---- .../org/mybatis/spring/mapper/ClassPathMapperScanner.java | 5 +---- .../org/mybatis/spring/mapper/MapperScannerConfigurer.java | 6 +----- .../org/mybatis/spring/support/SqlSessionDaoSupport.java | 3 +-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScan.java b/src/main/java/org/mybatis/spring/annotation/MapperScan.java index e6e244ed2d..93133ffdb2 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScan.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScan.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ * the class that declares this annotation. *

    * Configuration example: - *

    * *
      * @Configuration
    @@ -168,7 +167,6 @@
        * Whether enable lazy initialization of mapper bean.
        * 

    * Default is {@code false}. - *

    * * @return set {@code true} to enable lazy initialization * @@ -180,7 +178,6 @@ * Specifies the default scope of scanned mappers. *

    * Default is {@code ""} (equiv to singleton). - *

    * * @return the default scope */ diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 62955111e1..9877b7c9d8 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,7 +118,6 @@ public void setAnnotationClass(Class annotationClass) { * Set whether enable lazy initialization for mapper bean. *

    * Default is {@code false}. - *

    * * @param lazyInitialization * Set the @{code true} to enable @@ -133,7 +132,6 @@ public void setLazyInitialization(boolean lazyInitialization) { * Set whether print warning log if not found mappers that matches conditions. *

    * Default is {@code true}. But {@code false} when running in native image. - *

    * * @param printWarnLogIfNotFoundMappers * Set the @{code true} to print @@ -192,7 +190,6 @@ public void setMapperFactoryBeanClass(Class mapperF * Set the default scope of scanned mappers. *

    * Default is {@code null} (equiv to singleton). - *

    * * @param defaultScope * the scope diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index f220ce4dee..211e3c1fa9 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,7 +164,6 @@ public void setAddToConfig(boolean addToConfig) { * Set whether enable lazy initialization for mapper bean. *

    * Default is {@code false}. - *

    * * @param lazyInitialization * Set the @{code true} to enable @@ -235,7 +234,6 @@ public void setRawExcludeFilters(List> rawExcludeFilters) { /** * Specifies which {@code SqlSessionTemplate} to use in the case that there is more than one in the spring context. * Usually this is only needed when you have more than one datasource. - *

    * * @deprecated Use {@link #setSqlSessionTemplateBeanName(String)} instead * @@ -266,7 +264,6 @@ public void setSqlSessionTemplateBeanName(String sqlSessionTemplateName) { /** * Specifies which {@code SqlSessionFactory} to use in the case that there is more than one in the spring context. * Usually this is only needed when you have more than one datasource. - *

    * * @deprecated Use {@link #setSqlSessionFactoryBeanName(String)} instead. * @@ -357,7 +354,6 @@ public void setNameGenerator(BeanNameGenerator nameGenerator) { * Sets the default scope of scanned mappers. *

    * Default is {@code null} (equiv to singleton). - *

    * * @param defaultScope * the default scope diff --git a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java index 0eeeab17c6..ed6573932b 100644 --- a/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java +++ b/src/main/java/org/mybatis/spring/support/SqlSessionDaoSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ * be used to execute SQL methods. *

    * This class needs a SqlSessionTemplate or a SqlSessionFactory. If both are set the SqlSessionFactory will be ignored. - *

    * * @author Putthiphong Boonphong * @author Eduardo Macarron From 92014e8bdf52e744700b6a3c4c27484c09d095ff Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:15:03 -0500 Subject: [PATCH 910/933] [imports] Correct spring batch imports in javadocs and documentation as moved --- .../spring/batch/MyBatisPagingItemReader.java | 3 ++- .../builder/MyBatisCursorItemReaderBuilder.java | 10 +++++----- .../builder/MyBatisPagingItemReaderBuilder.java | 12 ++++++------ .../mybatis/spring/batch/builder/package-info.java | 6 +++--- src/site/es/markdown/batch.md | 2 +- src/site/ja/markdown/batch.md | 2 +- src/site/ko/markdown/batch.md | 2 +- src/site/markdown/batch.md | 2 +- src/site/zh_CN/markdown/batch.md | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 1ef247a6ba..36c017f9b7 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -31,7 +31,8 @@ import org.springframework.batch.infrastructure.item.database.AbstractPagingItemReader; /** - * {@code org.springframework.batch.item.ItemReader} for reading database records using MyBatis in a paging fashion. + * {@code org.springframework.batch.infrastructure.item.ItemReader} for reading database records using MyBatis in a + * paging fashion. *

    * Provided to facilitate the migration from Spring-Batch iBATIS 2 page item readers to MyBatis 3. * diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java index 11d0eec554..fba124f155 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -104,15 +104,15 @@ public MyBatisCursorItemReaderBuilder parameterValuesSupplier( } /** - * Configure if the state of the {@link org.springframework.batch.item.ItemStreamSupport} should be persisted within - * the {@link org.springframework.batch.item.ExecutionContext} for restart purposes. + * Configure if the state of the {@link org.springframework.batch.infrastructure.item.ItemStreamSupport} should be + * persisted within the {@link org.springframework.batch.infrastructure.item.ExecutionContext} for restart purposes. * * @param saveState * defaults to true * * @return The current instance of the builder. * - * @see org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader#setSaveState(boolean) + * @see org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader#setSaveState(boolean) */ public MyBatisCursorItemReaderBuilder saveState(boolean saveState) { this.saveState = saveState; @@ -127,7 +127,7 @@ public MyBatisCursorItemReaderBuilder saveState(boolean saveState) { * * @return The current instance of the builder. * - * @see org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader#setMaxItemCount(int) + * @see org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader#setMaxItemCount(int) */ public MyBatisCursorItemReaderBuilder maxItemCount(int maxItemCount) { this.maxItemCount = maxItemCount; diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java index e4504b6559..5b85a4c2ce 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public MyBatisPagingItemReaderBuilder parameterValuesSupplier( * * @return this instance for method chaining * - * @see org.springframework.batch.item.database.AbstractPagingItemReader#setPageSize(int) + * @see org.springframework.batch.infrastructure.item.database.AbstractPagingItemReader#setPageSize(int) */ public MyBatisPagingItemReaderBuilder pageSize(int pageSize) { this.pageSize = pageSize; @@ -120,15 +120,15 @@ public MyBatisPagingItemReaderBuilder pageSize(int pageSize) { } /** - * Configure if the state of the {@link org.springframework.batch.item.ItemStreamSupport} should be persisted within - * the {@link org.springframework.batch.item.ExecutionContext} for restart purposes. + * Configure if the state of the {@link org.springframework.batch.infrastructure.item.ItemStreamSupport} should be + * persisted within the {@link org.springframework.batch.infrastructure.item.ExecutionContext} for restart purposes. * * @param saveState * defaults to true * * @return The current instance of the builder. * - * @see org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader#setSaveState(boolean) + * @see org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader#setSaveState(boolean) */ public MyBatisPagingItemReaderBuilder saveState(boolean saveState) { this.saveState = saveState; @@ -143,7 +143,7 @@ public MyBatisPagingItemReaderBuilder saveState(boolean saveState) { * * @return The current instance of the builder. * - * @see org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader#setMaxItemCount(int) + * @see org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader#setMaxItemCount(int) */ public MyBatisPagingItemReaderBuilder maxItemCount(int maxItemCount) { this.maxItemCount = maxItemCount; diff --git a/src/main/java/org/mybatis/spring/batch/builder/package-info.java b/src/main/java/org/mybatis/spring/batch/builder/package-info.java index 9420c603a2..59758649c5 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/package-info.java +++ b/src/main/java/org/mybatis/spring/batch/builder/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ * limitations under the License. */ /** - * Contains classes to builder classes for {@link org.springframework.batch.item.ItemReader} and - * {@link org.springframework.batch.item.ItemWriter}. + * Contains classes to builder classes for {@link org.springframework.batch.infrastructure.item.ItemReader} and + * {@link org.springframework.batch.infrastructure.item.ItemWriter}. * * @since 2.0.0 */ diff --git a/src/site/es/markdown/batch.md b/src/site/es/markdown/batch.md index 1578477f98..76ba12b0c7 100644 --- a/src/site/es/markdown/batch.md +++ b/src/site/es/markdown/batch.md @@ -271,7 +271,7 @@ Entonces en la configuración de spring habrá un `CompositeItemWriter` que usar Fijate que el *InteractionMetadata* es una asociacióin en el ejemplo por lo que debe ser escrita antes para que la Interaction pueda recibir la clave generada. ```xml - + diff --git a/src/site/ja/markdown/batch.md b/src/site/ja/markdown/batch.md index 0c0d55257e..9c0fcd60af 100644 --- a/src/site/ja/markdown/batch.md +++ b/src/site/ja/markdown/batch.md @@ -267,7 +267,7 @@ public class Interaction { この例では *Interaction* をアップデートするためのキーを取得するため、*InteractionMetadata* を先に書き込む必要があります。 ```xml - + diff --git a/src/site/ko/markdown/batch.md b/src/site/ko/markdown/batch.md index cdcd9d0b5b..26911daef1 100644 --- a/src/site/ko/markdown/batch.md +++ b/src/site/ko/markdown/batch.md @@ -274,7 +274,7 @@ public class Interaction { 그리고 스프링 설정에는 각각의 레코드를 처리하기 위해 특별히 설정된 전용(delegates) writer를 사용하는 `CompositeItemWriter`가 있다. ```xml - + diff --git a/src/site/markdown/batch.md b/src/site/markdown/batch.md index a6ad50418c..aba658ef21 100644 --- a/src/site/markdown/batch.md +++ b/src/site/markdown/batch.md @@ -280,7 +280,7 @@ Then in the spring configuration there will be a `CompositeItemWriter` that will Note that as the *InteractionMetadata* is an association in the example it will need to be written first so that Interaction can have the updated key. ```xml - + diff --git a/src/site/zh_CN/markdown/batch.md b/src/site/zh_CN/markdown/batch.md index 891ed531cb..5d891fe154 100644 --- a/src/site/zh_CN/markdown/batch.md +++ b/src/site/zh_CN/markdown/batch.md @@ -264,7 +264,7 @@ public class Interaction { 在 Spring 配置中要配置一个 `CompositeItemWriter`,它将会将写入操作委托到特定种类的 writer 上面去。注意 *InteractionMetadata* 在例子里面是一个关联,它需要首先被写入,这样 Interaction 才能获得更新之后的键。 ```xml - + From 2df427f970250e06830bd9ca8d483a3305b818e9 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:29:43 -0500 Subject: [PATCH 911/933] [javadocs] Fill in missing javadocs All source javadocs generally needed but skipping missing constructor requirements at this time. --- src/main/java/org/mybatis/logging/Logger.java | 41 ++++++++++- .../org/mybatis/logging/LoggerFactory.java | 21 +++++- .../spring/MyBatisSystemException.java | 18 ++++- .../org/mybatis/spring/SqlSessionHolder.java | 17 ++++- .../mybatis/spring/SqlSessionTemplate.java | 17 ++++- .../spring/annotation/MapperScans.java | 8 ++- .../spring/batch/MyBatisBatchItemWriter.java | 3 + .../spring/batch/MyBatisCursorItemReader.java | 8 +++ .../spring/batch/MyBatisPagingItemReader.java | 6 ++ .../MyBatisBatchItemWriterBuilder.java | 5 +- .../MyBatisCursorItemReaderBuilder.java | 3 + .../MyBatisPagingItemReaderBuilder.java | 5 +- .../spring/mapper/ClassPathMapperScanner.java | 68 ++++++++++++++++++- .../spring/mapper/MapperFactoryBean.java | 14 +++- .../transaction/SpringManagedTransaction.java | 8 ++- 15 files changed, 231 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/mybatis/logging/Logger.java b/src/main/java/org/mybatis/logging/Logger.java index 75c98d5e2a..d1b57df919 100644 --- a/src/main/java/org/mybatis/logging/Logger.java +++ b/src/main/java/org/mybatis/logging/Logger.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,30 +26,69 @@ */ public class Logger { + /** The log. */ private final Log log; + /** + * Instantiates a new logger. + * + * @param log + * the log + */ Logger(Log log) { this.log = log; } + /** + * Error. + * + * @param s + * the s + * @param e + * the e + */ public void error(Supplier s, Throwable e) { log.error(s.get(), e); } + /** + * Error. + * + * @param s + * the s + */ public void error(Supplier s) { log.error(s.get()); } + /** + * Warn. + * + * @param s + * the s + */ public void warn(Supplier s) { log.warn(s.get()); } + /** + * Debug. + * + * @param s + * the s + */ public void debug(Supplier s) { if (log.isDebugEnabled()) { log.debug(s.get()); } } + /** + * Trace. + * + * @param s + * the s + */ public void trace(Supplier s) { if (log.isTraceEnabled()) { log.trace(s.get()); diff --git a/src/main/java/org/mybatis/logging/LoggerFactory.java b/src/main/java/org/mybatis/logging/LoggerFactory.java index 33a35a4cd0..dca5433077 100644 --- a/src/main/java/org/mybatis/logging/LoggerFactory.java +++ b/src/main/java/org/mybatis/logging/LoggerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +24,33 @@ */ public class LoggerFactory { + /** + * Instantiates a new logger factory. + */ private LoggerFactory() { // NOP } + /** + * Gets the logger. + * + * @param aClass + * the a class + * + * @return the logger + */ public static Logger getLogger(Class aClass) { return new Logger(LogFactory.getLog(aClass)); } + /** + * Gets the logger. + * + * @param logger + * the logger + * + * @return the logger + */ public static Logger getLogger(String logger) { return new Logger(LogFactory.getLog(logger)); } diff --git a/src/main/java/org/mybatis/spring/MyBatisSystemException.java b/src/main/java/org/mybatis/spring/MyBatisSystemException.java index a40d25c4a6..ee071a3f08 100644 --- a/src/main/java/org/mybatis/spring/MyBatisSystemException.java +++ b/src/main/java/org/mybatis/spring/MyBatisSystemException.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2023 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,11 +31,27 @@ public class MyBatisSystemException extends UncategorizedDataAccessException { private static final long serialVersionUID = -5284728621670758939L; + /** + * Instantiates a new my batis system exception. + * + * @param cause + * the cause + * + * @deprecated as of 3.0.4, use {@link #MyBatisSystemException(String, Throwable)} instead + */ @Deprecated(since = "3.0.4", forRemoval = true) public MyBatisSystemException(Throwable cause) { this(cause.getMessage(), cause); } + /** + * Instantiates a new my batis system exception. + * + * @param msg + * the msg + * @param cause + * the cause + */ public MyBatisSystemException(String msg, Throwable cause) { super(msg, cause); } diff --git a/src/main/java/org/mybatis/spring/SqlSessionHolder.java b/src/main/java/org/mybatis/spring/SqlSessionHolder.java index df2ffbf603..91d4b07573 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionHolder.java +++ b/src/main/java/org/mybatis/spring/SqlSessionHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,14 +59,29 @@ public SqlSessionHolder(SqlSession sqlSession, ExecutorType executorType, this.exceptionTranslator = exceptionTranslator; } + /** + * Gets the sql session. + * + * @return the sql session + */ public SqlSession getSqlSession() { return sqlSession; } + /** + * Gets the executor type. + * + * @return the executor type + */ public ExecutorType getExecutorType() { return executorType; } + /** + * Gets the persistence exception translator. + * + * @return the persistence exception translator + */ public PersistenceExceptionTranslator getPersistenceExceptionTranslator() { return exceptionTranslator; } diff --git a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java index ca1a6405b5..d1b22c0e7f 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionTemplate.java +++ b/src/main/java/org/mybatis/spring/SqlSessionTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,14 +132,29 @@ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType exec new Class[] { SqlSession.class }, new SqlSessionInterceptor()); } + /** + * Gets the sql session factory. + * + * @return the sql session factory + */ public SqlSessionFactory getSqlSessionFactory() { return this.sqlSessionFactory; } + /** + * Gets the executor type. + * + * @return the executor type + */ public ExecutorType getExecutorType() { return this.executorType; } + /** + * Gets the persistence exception translator. + * + * @return the persistence exception translator + */ public PersistenceExceptionTranslator getPersistenceExceptionTranslator() { return this.exceptionTranslator; } diff --git a/src/main/java/org/mybatis/spring/annotation/MapperScans.java b/src/main/java/org/mybatis/spring/annotation/MapperScans.java index 2eddbe3c00..989f1b2d97 100644 --- a/src/main/java/org/mybatis/spring/annotation/MapperScans.java +++ b/src/main/java/org/mybatis/spring/annotation/MapperScans.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,5 +41,11 @@ @Documented @Import(MapperScannerRegistrar.RepeatingRegistrar.class) public @interface MapperScans { + + /** + * Value. + * + * @return the mapper scan[] + */ MapperScan[] value(); } diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index 0015db9bd9..28589a167f 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -47,6 +47,9 @@ * * @author Eduardo Macarron * + * @param + * the generic type + * * @since 1.1.0 */ public class MyBatisBatchItemWriter implements ItemWriter, InitializingBean { diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java index 520463ede7..6498c60983 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisCursorItemReader.java @@ -32,7 +32,12 @@ import org.springframework.beans.factory.InitializingBean; /** + * {@code ItemReader} that uses MyBatis Cursor to read data. + * * @author Guillaume Darmont / guillaume@dropinocean.com + * + * @param + * the generic type */ public class MyBatisCursorItemReader extends AbstractItemCountingItemStreamItemReader implements InitializingBean { @@ -48,6 +53,9 @@ public class MyBatisCursorItemReader extends AbstractItemCountingItemStreamIt private Cursor cursor; private Iterator cursorIterator; + /** + * Instantiates a new my batis cursor item reader. + */ public MyBatisCursorItemReader() { setName(getShortName(MyBatisCursorItemReader.class)); } diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java index 36c017f9b7..a8baed03a6 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisPagingItemReader.java @@ -38,6 +38,9 @@ * * @author Eduardo Macarron * + * @param + * the generic type + * * @since 1.1.0 */ public class MyBatisPagingItemReader extends AbstractPagingItemReader { @@ -52,6 +55,9 @@ public class MyBatisPagingItemReader extends AbstractPagingItemReader { private Supplier> parameterValuesSupplier; + /** + * Instantiates a new my batis paging item reader. + */ public MyBatisPagingItemReader() { setName(getShortName(MyBatisPagingItemReader.class)); } diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java index 6270175fb4..a55c34da15 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisBatchItemWriterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,9 @@ * * @author Kazuki Shimizu * + * @param + * the generic type + * * @since 2.0.0 * * @see MyBatisBatchItemWriter diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java index fba124f155..93e21d4548 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisCursorItemReaderBuilder.java @@ -27,6 +27,9 @@ * * @author Kazuki Shimizu * + * @param + * the generic type + * * @since 2.0.0 * * @see MyBatisCursorItemReader diff --git a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java index 5b85a4c2ce..cf710a10a8 100644 --- a/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java +++ b/src/main/java/org/mybatis/spring/batch/builder/MyBatisPagingItemReaderBuilder.java @@ -27,9 +27,12 @@ * * @author Kazuki Shimizu * - * @since 2.0.0 + * @param + * the generic type * * @see MyBatisPagingItemReader + * + * @since 2.0.0 */ public class MyBatisPagingItemReaderBuilder { diff --git a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java index 9877b7c9d8..3ce01d9248 100644 --- a/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java +++ b/src/main/java/org/mybatis/spring/mapper/ClassPathMapperScanner.java @@ -90,6 +90,14 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner { private String defaultScope; private List excludeFilters; + /** + * Instantiates a new class path mapper scanner. + * + * @param registry + * the registry + * @param environment + * the environment + */ public ClassPathMapperScanner(BeanDefinitionRegistry registry, Environment environment) { super(registry, false, environment); setIncludeAnnotationConfig(!AotDetector.useGeneratedArtifacts()); @@ -97,6 +105,11 @@ public ClassPathMapperScanner(BeanDefinitionRegistry registry, Environment envir } /** + * Instantiates a new class path mapper scanner. + * + * @param registry + * the registry + * * @deprecated Please use the {@link #ClassPathMapperScanner(BeanDefinitionRegistry, Environment)}. */ @Deprecated(since = "3.0.4", forRemoval = true) @@ -106,10 +119,22 @@ public ClassPathMapperScanner(BeanDefinitionRegistry registry) { setPrintWarnLogIfNotFoundMappers(!NativeDetector.inNativeImage()); } + /** + * Sets the adds the to config. + * + * @param addToConfig + * the new adds the to config + */ public void setAddToConfig(boolean addToConfig) { this.addToConfig = addToConfig; } + /** + * Sets the annotation class. + * + * @param annotationClass + * the new annotation class + */ public void setAnnotationClass(Class annotationClass) { this.annotationClass = annotationClass; } @@ -142,34 +167,75 @@ public void setPrintWarnLogIfNotFoundMappers(boolean printWarnLogIfNotFoundMappe this.printWarnLogIfNotFoundMappers = printWarnLogIfNotFoundMappers; } + /** + * Sets the marker interface. + * + * @param markerInterface + * the new marker interface + */ public void setMarkerInterface(Class markerInterface) { this.markerInterface = markerInterface; } + /** + * Sets the exclude filters. + * + * @param excludeFilters + * the new exclude filters + */ public void setExcludeFilters(List excludeFilters) { this.excludeFilters = excludeFilters; } + /** + * Sets the sql session factory. + * + * @param sqlSessionFactory + * the new sql session factory + */ public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { this.sqlSessionFactory = sqlSessionFactory; } + /** + * Sets the sql session template. + * + * @param sqlSessionTemplate + * the new sql session template + */ public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { this.sqlSessionTemplate = sqlSessionTemplate; } + /** + * Sets the sql session template bean name. + * + * @param sqlSessionTemplateBeanName + * the new sql session template bean name + */ public void setSqlSessionTemplateBeanName(String sqlSessionTemplateBeanName) { this.sqlSessionTemplateBeanName = sqlSessionTemplateBeanName; } + /** + * Sets the sql session factory bean name. + * + * @param sqlSessionFactoryBeanName + * the new sql session factory bean name + */ public void setSqlSessionFactoryBeanName(String sqlSessionFactoryBeanName) { this.sqlSessionFactoryBeanName = sqlSessionFactoryBeanName; } /** + * Sets the mapper factory bean. + * + * @param mapperFactoryBean + * the new mapper factory bean + * * @deprecated Since 2.0.1, Please use the {@link #setMapperFactoryBeanClass(Class)}. */ - @Deprecated + @Deprecated(since = "2.0.1", forRemoval = true) public void setMapperFactoryBean(MapperFactoryBean mapperFactoryBean) { this.mapperFactoryBeanClass = mapperFactoryBean == null ? MapperFactoryBean.class : mapperFactoryBean.getClass(); } diff --git a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java index f95b721314..66132589f2 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,9 @@ * * @author Eduardo Macarron * + * @param + * the generic type + * * @see SqlSessionTemplate */ public class MapperFactoryBean extends SqlSessionDaoSupport implements FactoryBean { @@ -56,10 +59,19 @@ public class MapperFactoryBean extends SqlSessionDaoSupport implements Factor private boolean addToConfig = true; + /** + * Instantiates a new mapper factory bean. + */ public MapperFactoryBean() { // intentionally empty } + /** + * Instantiates a new mapper factory bean. + * + * @param mapperInterface + * the mapper interface + */ public MapperFactoryBean(Class mapperInterface) { this.mapperInterface = mapperInterface; } diff --git a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java index 1b6cd04832..4b3eefc683 100644 --- a/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java +++ b/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,12 @@ public class SpringManagedTransaction implements Transaction { private boolean autoCommit; + /** + * Instantiates a new spring managed transaction. + * + * @param dataSource + * the data source + */ public SpringManagedTransaction(DataSource dataSource) { notNull(dataSource, "No DataSource specified"); this.dataSource = dataSource; From 90a93342dbcd46846193cc48c7999d5649bf05db Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:20:01 -0500 Subject: [PATCH 912/933] [mockito] Delete old mock maker inline as that is the default now --- .../resources/mockito-extensions/org.mockito.plugins.MockMaker | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450..0000000000 --- a/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline From 3d1d533ce5f762a4233f18e1a40497a6f49cbd23 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:15:33 -0500 Subject: [PATCH 913/933] [jspecify] Use jspecify nullable instead of deprecated spring nullable --- .../java/org/mybatis/spring/mapper/MapperScannerConfigurer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java index 211e3c1fa9..6445421814 100644 --- a/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java +++ b/src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java @@ -25,6 +25,7 @@ import java.util.regex.Pattern; import org.apache.ibatis.session.SqlSessionFactory; +import org.jspecify.annotations.Nullable; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.BeanUtils; import org.springframework.beans.PropertyValues; @@ -46,7 +47,6 @@ import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.core.type.filter.RegexPatternTypeFilter; import org.springframework.core.type.filter.TypeFilter; -import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; From 42192fdca8bbad47e7d64e6172c0d91cf96745a9 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:58:20 -0500 Subject: [PATCH 914/933] [javadocs] Fix javadoc on test side did not address any warnings as a lot of them and those only affect us --- .../java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java index f0fd88e5fd..fa756e6833 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; /** - * test the function of excludeFilters in + * test the function of excludeFilters in . */ public class XmlScanFilterTest { From 274c6fcecb0e08beb02bd1badb660e8eedf1f74e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 13:58:44 -0500 Subject: [PATCH 915/933] [tests] Junit 5 stylings --- src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java | 3 ++- src/test/java/org/mybatis/spring/filter/ScanFilterTest.java | 4 ++-- .../java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java index f89e7777c9..1118c4d90d 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ // tests basic usage and implementation only // MapperFactoryBeanTest handles testing the transactional functions in SqlSessionTemplate +// Method is public as extended by other test classes outside this package public class SqlSessionTemplateTest extends AbstractMyBatisSpringTest { private static SqlSession sqlSessionTemplate; diff --git a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java index 1cb984c765..4c83d076eb 100644 --- a/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/ScanFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2024 the original author or authors. + * Copyright 2010-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ /** * test the function of excludeFilters in @MapperScan */ -public class ScanFilterTest { +class ScanFilterTest { private AnnotationConfigApplicationContext applicationContext; diff --git a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java index fa756e6833..ccecf80fd7 100644 --- a/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java +++ b/src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java @@ -26,7 +26,7 @@ /** * test the function of excludeFilters in . */ -public class XmlScanFilterTest { +class XmlScanFilterTest { private ClassPathXmlApplicationContext applicationContext; From 6faf7f0b97de5b9ab549a470bd308edda140f03e Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 14:12:20 -0500 Subject: [PATCH 916/933] [maven-release-plugin] prepare release mybatis-spring-4.0.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7b6e481c2a..2cf437e59e 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 4.0.1-SNAPSHOT + 4.0.0 mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -80,7 +80,7 @@ scm:git:ssh://git@github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - HEAD + mybatis-spring-4.0.0 https://github.com/mybatis/spring/ @@ -122,7 +122,7 @@ 6.0.1 - 1764514393 + 1764529899 true From 1cc2681d1b91d36cacc82ef25b9aba2c87370add Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Sun, 30 Nov 2025 14:12:56 -0500 Subject: [PATCH 917/933] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2cf437e59e..dec4442912 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.mybatis mybatis-spring - 4.0.0 + 4.0.1-SNAPSHOT mybatis-spring An easy-to-use Spring bridge for MyBatis sql mapping framework. @@ -122,7 +122,7 @@ 6.0.1 - 1764529899 + 1764529975 true From cd503af1afb4a36bc79d3d807c619f4aad708ada Mon Sep 17 00:00:00 2001 From: taole33 Date: Mon, 1 Dec 2025 20:22:51 +0900 Subject: [PATCH 918/933] docs: Fix SqlSession direct API usage caveats based on actual behavior(#531) This commit updates the documentation for the direct use of the raw MyBatis SqlSession API, resolving the long-standing discrepancy reported in #531. The previous documentation incorrectly stated that using SqlSession.openSession() within a Spring transaction would "throw an exception" and "not participate in any Spring transactions." The revised documentation reflects the actual behavior. --- src/site/markdown/using-api.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/site/markdown/using-api.md b/src/site/markdown/using-api.md index 0bcaa59f1e..d9df03ae7c 100644 --- a/src/site/markdown/using-api.md +++ b/src/site/markdown/using-api.md @@ -21,10 +21,9 @@ public class UserDaoImpl implements UserDao { } ``` -Use this option with care because wrong usage may produce runtime errors or worse, data integrity problems. Be aware of the following caveats with direct API usage: +Use this option **with care** because wrong usage may produce runtime errors or worse, data integrity problems. Be aware of the following caveats with direct API usage: -* It will **not** participate in any Spring transactions. -* If the `SqlSession` is using a `DataSource` that is also being used by a Spring transaction manager and there is currently a transaction in progress, this code **will** throw an exception. +* Unless **explicitly managed by Spring's `@Transactional` annotation** or configured for **auto-commit** at the database connection level, the raw `SqlSession` does **not** participate in any transaction management. Reliance on the raw `SqlSession` is highly discouraged as it bypasses Spring's automatic resource management mechanism. * MyBatis' `DefaultSqlSession` is not thread safe. If you inject it in your beans you **will** get errors. * Mappers created using `DefaultSqlSession` are not thread safe either. If you inject them it in your beans you **will** get errors. -* You must make sure that your `SqlSession`s are **always** closed in a finally block. +* You must make sure that your `SqlSession`s are **always** closed in a finally block. \ No newline at end of file From a2e590ffd7d8a121a7b56b5c053234035bfa42e0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 17:45:34 +0000 Subject: [PATCH 919/933] Update actions/checkout digest to 8e8c483 --- .github/workflows/ci.yaml | 2 +- .github/workflows/codeql.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/site.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index acc46d6446..1997304b7d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 45b5818b5d..bfe2388af0 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Java uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index beb604ca9e..d19a0eadbd 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Java uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 59df4a2df7..c9964c0cf7 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Java uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 72d43afe75..0f59990923 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 19862d2e53..fe54ddb179 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Java uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 with: From 44fce298e168ffe54886dd3ba191db283603870e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 06:57:12 +0000 Subject: [PATCH 920/933] Update actions/setup-java digest to f2beeb2 --- .github/workflows/ci.yaml | 2 +- .github/workflows/codeql.yaml | 2 +- .github/workflows/coveralls.yaml | 2 +- .github/workflows/site.yaml | 2 +- .github/workflows/sonar.yaml | 2 +- .github/workflows/sonatype.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index acc46d6446..27b49ddfb7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: steps: - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 with: cache: ${{ matrix.cache }} distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 45b5818b5d..97c394876d 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -27,7 +27,7 @@ jobs: uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 with: cache: maven distribution: 'temurin' diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index beb604ca9e..150d72298c 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 with: cache: maven distribution: temurin diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 59df4a2df7..b6d43e7de7 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 with: cache: maven distribution: temurin diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 72d43afe75..619087d348 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -26,7 +26,7 @@ jobs: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 with: cache: maven distribution: temurin diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 19862d2e53..0492a7b7ec 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Setup Java - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 with: cache: maven distribution: temurin From 2fe2a0ccd889c1490f0e8db9f8ce5d248195347f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 20:57:17 +0000 Subject: [PATCH 921/933] Update github/codeql-action digest to cf1bb45 --- .github/workflows/codeql.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 45b5818b5d..25d78557ad 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -34,12 +34,12 @@ jobs: java-version: 25 - name: Initialize CodeQL - uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 + uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4 with: queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 + uses: github/codeql-action/autobuild@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 + uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4 From 7abd5c1c6b90c5688045be5705cbe02539717609 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Dec 2025 18:41:06 +0000 Subject: [PATCH 922/933] chore(deps): update jamesives/github-pages-deploy-action digest to 4ef313c --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 570be390be..87c89908b1 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -31,7 +31,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NVD_API_KEY: ${{ secrets.NVD_API_KEY }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@4a3abc783e1a24aeb44c16e869ad83caf6b4cc23 # v4 + uses: JamesIves/github-pages-deploy-action@4ef313c6a410f0883308623d45510e4a11625465 # v4 with: branch: gh-pages folder: target/staging From db2633e135c1dad192ef12383a64249a71c077f1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 01:59:34 +0000 Subject: [PATCH 923/933] chore(deps): update jamesives/github-pages-deploy-action digest to 9d877ee --- .github/workflows/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 87c89908b1..908cd1eea2 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -31,7 +31,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NVD_API_KEY: ${{ secrets.NVD_API_KEY }} - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@4ef313c6a410f0883308623d45510e4a11625465 # v4 + uses: JamesIves/github-pages-deploy-action@9d877eea73427180ae43cf98e8914934fe157a1a # v4 with: branch: gh-pages folder: target/staging From a85fe32ff010613a940ebe743cec1143628e5bdc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 01:59:38 +0000 Subject: [PATCH 924/933] chore(deps): update dependency org.mockito:mockito-junit-jupiter to v5.21.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dec4442912..29040b9907 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,7 @@ org.mockito mockito-junit-jupiter - 5.20.0 + 5.21.0 test From 5615cf82507a505c4ed7a81333bb06c62648b02e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 19:45:34 +0000 Subject: [PATCH 925/933] fix(deps): update spring core to v7.0.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 29040b9907..b7ac03e634 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ 10.17.1.0 3.5.19 - 7.0.1 + 7.0.2 4.0.0 6.0.0 org.mybatis.spring From 3fae85eefbc9d164b78cd948cd599de226ab35bd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:14:21 +0000 Subject: [PATCH 926/933] chore(deps): update github/codeql-action digest to 1b168cd --- .github/workflows/codeql.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 6980798280..b0e912735c 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -34,12 +34,12 @@ jobs: java-version: 25 - name: Initialize CodeQL - uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4 + uses: github/codeql-action/init@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4 with: queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4 + uses: github/codeql-action/autobuild@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4 + uses: github/codeql-action/analyze@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4 From 498d84e6032b611750b4f83e0309267d2dc9e605 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 16 Dec 2025 19:58:23 +0000 Subject: [PATCH 927/933] chore(deps): update github/codeql-action digest to 5d4e8d1 --- .github/workflows/codeql.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index b0e912735c..86a1ce6d93 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -34,12 +34,12 @@ jobs: java-version: 25 - name: Initialize CodeQL - uses: github/codeql-action/init@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4 + uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4 with: queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4 + uses: github/codeql-action/autobuild@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4 + uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4 From f97b68c0754b847128f6b9a47cac09e26dbea036 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 00:06:57 +0000 Subject: [PATCH 928/933] chore(deps): update dependency maven to v3.9.12 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ad003123f9..041d19464c 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,4 +1,4 @@ distributionType=source -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar wrapperVersion=3.3.4 From a704b7a3a98ef5f4754dad4fa7580704957ee5b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 02:01:34 +0000 Subject: [PATCH 929/933] chore(deps): update dependency org.aspectj:aspectjweaver to v1.9.25.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7ac03e634..8b333965a1 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ org.aspectj aspectjweaver - 1.9.25 + 1.9.25.1 compile true From f15c3e8b441446573687966aff1532d28040bd2e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:42:53 +0000 Subject: [PATCH 930/933] fix(deps): update spring batch to v6.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b333965a1..7db7f50d7b 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ 3.5.19 7.0.2 4.0.0 - 6.0.0 + 6.0.1 org.mybatis.spring 6.0.1 From effb8293c3a4d175662c38a787c0587716a15570 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 18:39:10 +0000 Subject: [PATCH 931/933] chore(deps): update dependency net.bytebuddy:byte-buddy to v1.18.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b333965a1..d8c8df8beb 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ net.bytebuddy byte-buddy - 1.18.2 + 1.18.3 test From 2bb90216e906ad35c1208274489963178ad130de Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 18:39:13 +0000 Subject: [PATCH 932/933] chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.18.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8b333965a1..0e1fc6e3b2 100644 --- a/pom.xml +++ b/pom.xml @@ -339,7 +339,7 @@ net.bytebuddy byte-buddy-agent - 1.18.2 + 1.18.3 test From 58ab1e716483331de5d96c01961e0175486d3120 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 20 Dec 2025 01:37:12 +0000 Subject: [PATCH 933/933] chore(deps): update dependency org.springframework.boot:spring-boot-autoconfigure to v4.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b9b18903f..20be13cf4a 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 10.17.1.0 3.5.19 7.0.2 - 4.0.0 + 4.0.1 6.0.1 org.mybatis.spring