Skip to content

Commit 0e07986

Browse files
committed
Merge branch 'master' into gh/566-oracle-nested-cursor
2 parents 1df5aaf + 1b2346c commit 0e07986

21 files changed

+94
-37
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/release.properties
1111
/target
1212
.github/keys/
13+
.profiler/
1314

1415
# These are needed if running in IDE without properties set
1516
/ibderby

Diff for: .mvn/extensions.xml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1818
-->
1919
<extensions>
20+
<!-- Usage as -Dprofile -->
2021
<extension>
2122
<groupId>fr.jcgay.maven</groupId>
2223
<artifactId>maven-profiler</artifactId>

Diff for: CONTRIBUTING.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ Please use [the mailing list](https://groups.google.com/group/mybatis-user) inst
1212
- It is a good idea to discuss your changes on [the mailing list](https://groups.google.com/group/mybatis-user) to get feedback from the community.
1313
- If you have a patch with unit tests, send a pull request. Please see the [Contributing code](CONTRIBUTING.md#contributing-code) section.
1414

15-
1615
## Improving documentation
1716

1817
- Documentations are placed under [src/site](https://github.com/mybatis/mybatis-3/tree/master/src/site) directory in [the xdoc format](https://maven.apache.org/doxia/references/xdoc-format.html), so it is basically the same as creating a patch to contribute documentation changes. Please see the [Contributing code](CONTRIBUTING.md#contributing-code) section.
1918

2019
## Contributing code
2120

21+
### Formatting
22+
23+
Mybatis-core is now being auto formatted. Given nature of some code logic with mybatis, it is more appropriate to force a formatting structure manually for snippets such as sql statements. To do so, add following blocks around code.
24+
25+
- ```// @formatter:off``` to start the block of unformatted code
26+
- ```// @formatter:on``` to end the block of unformatted code
27+
28+
If comment sections need same behaviour such as javadocs, note that the entire block must be around entire comment as direct usage does not properly indicate that formatter treats it all as one comment block regardless.
29+
2230
### Copyright and License
2331

2432
- You are the author of your contributions and will always be.

Diff for: README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ MyBatis SQL Mapper Framework for Java
33

44
[![build](https://github.com/mybatis/mybatis-3/actions/workflows/ci.yaml/badge.svg)](https://github.com/mybatis/mybatis-3/actions?query=workflow%3A%22Java+CI%22)
55
[![Coverage Status](https://coveralls.io/repos/mybatis/mybatis-3/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/mybatis-3?branch=master)
6+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mybatis_mybatis-3&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=mybatis_mybatis-3)
67
[![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis)
78
[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis/)
89
[![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
@@ -25,12 +26,7 @@ Essentials
2526
Contributions
2627
-------------
2728

28-
Mybatis-core is now being auto formatted. Given nature of some code logic with mybatis, it is more appropriate to force a formatting structure manually for snippets such as sql statements. To do so, add following blocks around code.
29-
30-
- ```// @formatter:off``` to start the block of unformatted code
31-
- ```// @formatter:on``` to end the block of unformatted code
32-
33-
If comment sections need same behaviour such as javadocs, note that the entire block must be around entire comment as direct usage does not properly indicate that formatter treats it all as one comment block regardless.
29+
See [here](CONTRIBUTING.md)
3430

3531
Tests
3632
-----

Diff for: hooks/pre-commit.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2009-2025 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
set -eo pipefail
18+
19+
function format_and_sort() {
20+
# Run the validate and import check commands, suppressing all output and errors
21+
if ! mvn formatter:validate impsort:check > /dev/null 2>&1; then
22+
# If validation failed, fix it by ensuring code is formatted correctly
23+
# and that imports are sorted as some IDEs automatically change it on save
24+
mvn formatter:format impsort:sort
25+
26+
# Fail the commit, so the author can re-select what to commit
27+
echo "Formatting and/or import sorting were required. Please check and make another commit."
28+
exit 1
29+
fi
30+
31+
# If no error occurred, print a success message
32+
echo "All files are properly formatted and imports are sorted."
33+
}
34+
35+
format_and_sort

Diff for: pom.xml

+23-4
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@
7272

7373
<clirr.comparisonVersion>3.4.6</clirr.comparisonVersion>
7474

75-
<byte-buddy.version>1.15.11</byte-buddy.version>
75+
<byte-buddy.version>1.16.1</byte-buddy.version>
7676
<derby.version>10.17.1.0</derby.version>
7777
<log4j.version>2.24.3</log4j.version>
7878
<mockito.version>5.15.2</mockito.version>
7979
<mssql-jdbc.version>12.8.1.jre11</mssql-jdbc.version>
8080
<testcontainers.version>1.20.4</testcontainers.version>
81+
<git-build-hook.version>3.5.0</git-build-hook.version>
8182

8283
<!-- Add slow test groups here and annotate classes similar to @Tag('groupName'). -->
8384
<!-- Excluded groups are ran on github ci, to force here, pass -d"excludedGroups=" -->
@@ -195,13 +196,13 @@
195196
<dependency>
196197
<groupId>org.postgresql</groupId>
197198
<artifactId>postgresql</artifactId>
198-
<version>42.7.4</version>
199+
<version>42.7.5</version>
199200
<scope>test</scope>
200201
</dependency>
201202
<dependency>
202203
<groupId>com.mysql</groupId>
203204
<artifactId>mysql-connector-j</artifactId>
204-
<version>9.1.0</version>
205+
<version>9.2.0</version>
205206
<scope>test</scope>
206207
</dependency>
207208
<dependency>
@@ -213,7 +214,7 @@
213214
<dependency>
214215
<groupId>org.assertj</groupId>
215216
<artifactId>assertj-core</artifactId>
216-
<version>3.27.2</version>
217+
<version>3.27.3</version>
217218
<scope>test</scope>
218219
</dependency>
219220
<dependency>
@@ -431,6 +432,24 @@
431432
</rules>
432433
</configuration>
433434
</plugin>
435+
436+
<plugin>
437+
<groupId>com.rudikershaw.gitbuildhook</groupId>
438+
<artifactId>git-build-hook-maven-plugin</artifactId>
439+
<version>${git-build-hook.version}</version>
440+
<configuration>
441+
<installHooks>
442+
<pre-commit>hooks/pre-commit.sh</pre-commit>
443+
</installHooks>
444+
</configuration>
445+
<executions>
446+
<execution>
447+
<goals>
448+
<goal>install</goal>
449+
</goals>
450+
</execution>
451+
</executions>
452+
</plugin>
434453
</plugins>
435454
</build>
436455

Diff for: src/test/java/org/apache/ibatis/binding/BindingTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void shouldCacheMapperMethod() throws Exception {
623623
void shouldGetBlogsWithAuthorsAndPosts() {
624624
try (SqlSession session = sqlSessionFactory.openSession()) {
625625
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
626-
List<Blog> blogs = mapper.selectBlogsWithAutorAndPosts();
626+
List<Blog> blogs = mapper.selectBlogsWithAuthorAndPosts();
627627
assertEquals(2, blogs.size());
628628
assertTrue(blogs.get(0) instanceof Proxy);
629629
assertEquals(101, blogs.get(0).getAuthor().getId());
@@ -640,7 +640,7 @@ void shouldGetBlogsWithAuthorsAndPosts() {
640640
void shouldGetBlogsWithAuthorsAndPostsEagerly() {
641641
try (SqlSession session = sqlSessionFactory.openSession()) {
642642
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
643-
List<Blog> blogs = mapper.selectBlogsWithAutorAndPostsEagerly();
643+
List<Blog> blogs = mapper.selectBlogsWithAuthorAndPostsEagerly();
644644
assertEquals(2, blogs.size());
645645
assertFalse(blogs.get(0) instanceof Factory);
646646
assertEquals(101, blogs.get(0).getAuthor().getId());

Diff for: src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Blog selectBlogWithAParamNamedValue(@Param("column") String column, @Param("id")
251251
@Result(property = "posts", column = "id", many = @Many(select = "selectPostsById"))
252252
})
253253
// @formatter:on
254-
List<Blog> selectBlogsWithAutorAndPosts();
254+
List<Blog> selectBlogsWithAuthorAndPosts();
255255

256256
// @formatter:off
257257
@Select({
@@ -263,6 +263,6 @@ Blog selectBlogWithAParamNamedValue(@Param("column") String column, @Param("id")
263263
@Result(property = "posts", column = "id", many = @Many(select = "selectPostsById", fetchType = FetchType.EAGER))
264264
})
265265
// @formatter:on
266-
List<Blog> selectBlogsWithAutorAndPostsEagerly();
266+
List<Blog> selectBlogsWithAuthorAndPostsEagerly();
267267

268268
}

Diff for: src/test/java/org/apache/ibatis/executor/loader/CglibProxyTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void shouldLetCallALoadedProperty() {
7171
}
7272

7373
@Test
74-
void shouldSerizalizeADeserlizaliedProxy() throws Exception {
74+
void shouldSerializeADeserializedProxy() throws Exception {
7575
Object proxy = ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<>(),
7676
new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
7777
Author author2 = (Author) deserialize(serialize((Serializable) proxy));

Diff for: src/test/java/org/apache/ibatis/executor/loader/JavassistProxyTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void shouldLetCallALoadedProperty() {
6969
}
7070

7171
@Test
72-
void shouldSerizalizeADeserlizaliedProxy() throws Exception {
72+
void shouldSerializeADeserializedProxy() throws Exception {
7373
Object proxy = ((JavassistProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<>(),
7474
new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
7575
Author author2 = (Author) deserialize(serialize((Serializable) proxy));

Diff for: src/test/java/org/apache/ibatis/executor/loader/SerializableProxyTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties
110110
}
111111

112112
@Test
113-
void shouldSerizaliceAFullLoadedObjectToOriginalClass() throws Exception {
113+
void shouldSerializeAFullLoadedObjectToOriginalClass() throws Exception {
114114
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(),
115115
new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
116116
Object proxy2 = deserialize(serialize((Serializable) proxy));

Diff for: src/test/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandlerTest2.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,9 +93,6 @@ void shouldNotCallNextOnClosedResultSet_SimpleResult() throws Exception {
9393
when(rsmd.getColumnLabel(1)).thenReturn("id");
9494
when(rsmd.getColumnType(1)).thenReturn(Types.INTEGER);
9595
when(rsmd.getColumnClassName(1)).thenReturn(Integer.class.getCanonicalName());
96-
when(stmt.getConnection()).thenReturn(conn);
97-
when(conn.getMetaData()).thenReturn(dbmd);
98-
when(dbmd.supportsMultipleResultSets()).thenReturn(false); // for simplicity.
9996

10097
final List<Object> results = resultSetHandler.handleResultSets(stmt);
10198
assertEquals(0, results.size());

Diff for: src/test/java/org/apache/ibatis/io/ExternalResourcesTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void getConfiguredTemplate() {
9191
templateName = ExternalResources.getConfiguredTemplate(tempFile.getAbsolutePath(), "new_command.template");
9292
assertEquals("templates/col_new_template_migration.sql", templateName);
9393
} catch (Exception e) {
94-
fail("Test failed with execption: " + e.getMessage());
94+
fail("Test failed with exception: " + e.getMessage());
9595
}
9696
}
9797

Diff for: src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void shouldReturnWarningIfEndOfLineTerminatorNotFound() throws Exception {
113113
}
114114

115115
@Test
116-
void commentAferStatementDelimiterShouldNotCauseRunnerFail() throws Exception {
116+
void commentAfterStatementDelimiterShouldNotCauseRunnerFail() throws Exception {
117117
DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
118118
String resource = "org/apache/ibatis/jdbc/ScriptCommentAfterEOLTerminator.sql";
119119
try (Connection conn = ds.getConnection(); Reader reader = Resources.getResourceAsReader(resource)) {

Diff for: src/test/java/org/apache/ibatis/mapping/ResultMappingTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void shouldThrowErrorWhenBothResultMapAndNestedSelectAreSet() {
4141

4242
// Issue 4: column is mandatory on nested queries
4343
@Test
44-
void shouldFailWithAMissingColumnInNetstedSelect() {
44+
void shouldFailWithAMissingColumnInNestedSelect() {
4545
assertThrows(IllegalStateException.class,
4646
() -> new ResultMapping.Builder(configuration, "prop").nestedQueryId("nested query ID").build());
4747
}

Diff for: src/test/java/org/apache/ibatis/submitted/automapping/AutomappingTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void shouldGetAUser() {
5555
}
5656

5757
@Test
58-
void shouldGetAUserWhithPhoneNumber() {
58+
void shouldGetAUserWithPhoneNumber() {
5959
sqlSessionFactory.getConfiguration().setAutoMappingBehavior(AutoMappingBehavior.NONE);
6060
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
6161
Mapper mapper = sqlSession.getMapper(Mapper.class);

Diff for: src/test/java/org/apache/ibatis/submitted/force_flush_on_select/ForceFlushOnSelectTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void updateShouldFlushLocalCache() {
118118
}
119119

120120
@Test
121-
void selectShouldFlushLocalCacheIfFlushLocalCacheAtferEachStatementIsTrue() throws SQLException {
121+
void selectShouldFlushLocalCacheIfFlushLocalCacheAfterEachStatementIsTrue() throws SQLException {
122122
sqlSessionFactory.getConfiguration().setLocalCacheScope(LocalCacheScope.STATEMENT);
123123
try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE)) {
124124
PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);

Diff for: src/test/java/org/apache/ibatis/submitted/keygen/Jdbc3KeyGeneratorTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void shouldAssignKeysToNamedList() {
197197
}
198198

199199
@Test
200-
void shouldAssingKeysToCollection() {
200+
void shouldAssignKeysToCollection() {
201201
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
202202
try {
203203
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -215,7 +215,7 @@ void shouldAssingKeysToCollection() {
215215
}
216216

217217
@Test
218-
void shouldAssingKeysToNamedCollection() {
218+
void shouldAssignKeysToNamedCollection() {
219219
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
220220
try {
221221
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -233,7 +233,7 @@ void shouldAssingKeysToNamedCollection() {
233233
}
234234

235235
@Test
236-
void shouldAssingKeysToArray() {
236+
void shouldAssignKeysToArray() {
237237
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
238238
try {
239239
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -251,7 +251,7 @@ void shouldAssingKeysToArray() {
251251
}
252252

253253
@Test
254-
void shouldAssingKeysToNamedArray() {
254+
void shouldAssignKeysToNamedArray() {
255255
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
256256
try {
257257
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -597,7 +597,7 @@ void shouldAssignKeyToAParamWithTrickyName() {
597597
}
598598

599599
@Test
600-
void shouldAssingKeysToAMap() {
600+
void shouldAssignKeysToAMap() {
601601
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
602602
try {
603603
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);

Diff for: src/test/java/org/apache/ibatis/submitted/lazy_properties/LazyPropertiesTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ void verifyCustomLazyLoadTriggerMethods() {
155155

156156
@Test
157157
void shouldInvokingSetterInvalidateLazyLoading_Javassist() {
158-
shoulInvokingSetterInvalidateLazyLoading(new JavassistProxyFactory());
158+
shouldInvokingSetterInvalidateLazyLoading(new JavassistProxyFactory());
159159
}
160160

161161
@Tag("RequireIllegalAccess")
162162
@Test
163163
void shouldInvokingSetterInvalidateLazyLoading_Cglib() {
164-
shoulInvokingSetterInvalidateLazyLoading(new CglibProxyFactory());
164+
shouldInvokingSetterInvalidateLazyLoading(new CglibProxyFactory());
165165
}
166166

167-
private void shoulInvokingSetterInvalidateLazyLoading(ProxyFactory proxyFactory) {
167+
private void shouldInvokingSetterInvalidateLazyLoading(ProxyFactory proxyFactory) {
168168
Configuration config = sqlSessionFactory.getConfiguration();
169169
config.setProxyFactory(proxyFactory);
170170
config.setAggressiveLazyLoading(false);

Diff for: src/test/java/org/apache/ibatis/submitted/result_handler/ResulthandlerTest.java renamed to src/test/java/org/apache/ibatis/submitted/result_handler/ResultHandlerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.junit.jupiter.api.BeforeAll;
2727
import org.junit.jupiter.api.Test;
2828

29-
class ResulthandlerTest {
29+
class ResultHandlerTest {
3030

3131
private static SqlSessionFactory sqlSessionFactory;
3232

Diff for: src/test/java/org/apache/ibatis/type/SqlTimetampTypeHandlerTest.java renamed to src/test/java/org/apache/ibatis/type/SqlTimestampTypeHandlerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import org.junit.jupiter.api.Test;
2727

28-
class SqlTimetampTypeHandlerTest extends BaseTypeHandlerTest {
28+
class SqlTimestampTypeHandlerTest extends BaseTypeHandlerTest {
2929

3030
private static final TypeHandler<Timestamp> TYPE_HANDLER = new SqlTimestampTypeHandler();
3131
private static final Timestamp SQL_TIME = new Timestamp(new Date().getTime());

0 commit comments

Comments
 (0)