Skip to content

Commit d79f125

Browse files
committed
Merge branch 'master' into pr/3108
2 parents 5c23022 + 6a2676a commit d79f125

23 files changed

+1038
-125
lines changed

pom.xml

+9-9
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@
135135
<properties>
136136
<clirr.comparisonVersion>3.4.6</clirr.comparisonVersion>
137137

138-
<byte-buddy.version>1.15.3</byte-buddy.version>
138+
<byte-buddy.version>1.15.10</byte-buddy.version>
139139
<derby.version>10.17.1.0</derby.version>
140140
<log4j.version>2.24.1</log4j.version>
141-
<mockito.version>5.14.1</mockito.version>
141+
<mockito.version>5.14.2</mockito.version>
142142
<mssql-jdbc.version>12.8.1.jre11</mssql-jdbc.version>
143-
<testcontainers.version>1.20.2</testcontainers.version>
143+
<testcontainers.version>1.20.3</testcontainers.version>
144144

145145
<!-- Add slow test groups here and annotate classes similar to @Tag('groupName'). -->
146146
<!-- Excluded groups are ran on github ci, to force here, pass -d"excludedGroups=" -->
@@ -190,19 +190,19 @@
190190
<dependency>
191191
<groupId>org.junit.jupiter</groupId>
192192
<artifactId>junit-jupiter-engine</artifactId>
193-
<version>5.11.2</version>
193+
<version>5.11.3</version>
194194
<scope>test</scope>
195195
</dependency>
196196
<dependency>
197197
<groupId>org.junit.jupiter</groupId>
198198
<artifactId>junit-jupiter-params</artifactId>
199-
<version>5.11.2</version>
199+
<version>5.11.3</version>
200200
<scope>test</scope>
201201
</dependency>
202202
<dependency>
203203
<groupId>org.hsqldb</groupId>
204204
<artifactId>hsqldb</artifactId>
205-
<version>2.7.3</version>
205+
<version>2.7.4</version>
206206
<scope>test</scope>
207207
</dependency>
208208
<dependency>
@@ -250,7 +250,7 @@
250250
<dependency>
251251
<groupId>org.apache.velocity</groupId>
252252
<artifactId>velocity-engine-core</artifactId>
253-
<version>2.4</version>
253+
<version>2.4.1</version>
254254
<scope>test</scope>
255255
</dependency>
256256
<!-- postgresql driver is required to run the refcursor tests -->
@@ -263,7 +263,7 @@
263263
<dependency>
264264
<groupId>com.mysql</groupId>
265265
<artifactId>mysql-connector-j</artifactId>
266-
<version>9.0.0</version>
266+
<version>9.1.0</version>
267267
<scope>test</scope>
268268
</dependency>
269269
<dependency>
@@ -346,7 +346,7 @@
346346
<dependency>
347347
<groupId>ch.qos.logback</groupId>
348348
<artifactId>logback-classic</artifactId>
349-
<version>1.5.8</version>
349+
<version>1.5.12</version>
350350
<scope>test</scope>
351351
</dependency>
352352
<dependency>

src/main/java/org/apache/ibatis/mapping/VendorDatabaseIdProvider.java

+5-5
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-2024 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.
@@ -55,11 +55,11 @@ public void setProperties(Properties p) {
5555

5656
private String getDatabaseName(DataSource dataSource) throws SQLException {
5757
String productName = getDatabaseProductName(dataSource);
58-
if (this.properties != null) {
59-
return properties.entrySet().stream().filter(entry -> productName.contains((String) entry.getKey()))
60-
.map(entry -> (String) entry.getValue()).findFirst().orElse(null);
58+
if (properties == null || properties.isEmpty()) {
59+
return productName;
6160
}
62-
return productName;
61+
return properties.entrySet().stream().filter(entry -> productName.contains((String) entry.getKey()))
62+
.map(entry -> (String) entry.getValue()).findFirst().orElse(null);
6363
}
6464

6565
private String getDatabaseProductName(DataSource dataSource) throws SQLException {

src/site/es/markdown/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: Clinton Begin, Eduardo Macarron
77

88
### ¿Qué es MyBatis?
99

10-
MyBatis es un framework de persistencia que soporta SQL, procedimientos almacenados y mapeos avanzados. MyBatis elimina casi todo el código JDBC, el establecimiento manual de parámetros y la obtención de resultados. MyBatis puede configurarse con XML o anotaciones y permite mapear typos de datos primitivos, objetos de tipo Map y POJOs (Plain Old Java Objects) a registros de base de datos.
10+
MyBatis es un framework de persistencia que soporta SQL, procedimientos almacenados y mapeos avanzados. MyBatis elimina casi todo el código JDBC, el establecimiento manual de parámetros y la obtención de resultados. MyBatis puede configurarse con XML o anotaciones y permite mapear tipos de datos primitivos, objetos de tipo Map y POJOs (Plain Old Java Objects) a registros de base de datos.
1111

1212
### Colabora para mejorar esta documentación...
1313

src/site/ko/xdoc/java-api.xml

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2009-2023 the original author or authors.
4+
Copyright 2009-2024 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
<title>마이바티스 3 | 자바 API</title>
2424
<author email="[email protected]">Clinton Begin</author>
2525
<author email="[email protected]">이동국(한국어 번역)</author>
26+
<author email="[email protected]">박동민(한국어 번역)</author>
2627
</properties>
2728

2829
<body>
@@ -269,7 +270,7 @@ int insert(String statement)
269270
int update(String statement)
270271
int delete(String statement)]]></source>
271272

272-
<p>A Cursor offers the same results as a List, except it fetches data lazily using an Iterator.</p>
273+
<p>Cursor는 List와 동일한 결과를 보여주지만, 데이터를 반복문을 통해 지연로딩을 한다.</p>
273274
<source><![CDATA[try (Cursor<MyEntity> entities = session.selectCursor(statement, param)) {
274275
for (MyEntity entity:entities) {
275276
// process one entity
@@ -304,11 +305,11 @@ public interface ResultHandler<T> {
304305

305306
<p>ResultContext파라미터는 결과 객체에 접근할 수 있도록 해준다.</p>
306307

307-
<p>Using a ResultHandler has two limitations that you should be aware of:</p>
308+
<p>ResultHandler를 사용할 때 유의해야 할 제약사항이 2개 있다:</p>
308309

309310
<ul>
310-
<li>Data got from an method called with a ResultHandler will not be cached.</li>
311-
<li>When using advanced resultmaps MyBatis will probably require several rows to build an object. If a ResultHandler is used you may be given an object whose associations or collections are not yet filled.</li>
311+
<li>ResultHandler를 사용하여 호출된 메소드의 데이터는 캐싱 되지 않는다.</li>
312+
<li>고급 resualtMap을 사용할 경우, 마이바티스는 객체를 완성하기 위해 여러 줄의 코드를 필요로 할 수 있다. ResultHandler를 사용할 때 받는 객체는 associations나 collections가 완전히 채워지지 않은 상태일 수도 있다.</li>
312313
</ul>
313314

314315
<h5>배치 수정시 flush메소드</h5>
@@ -750,36 +751,37 @@ class UserSqlBuilder {
750751
}
751752
}]]></source>
752753

753-
<p>This example shows usage that share an sql provider class to all mapper methods using global configuration(Available since 3.5.6):</p>
754+
<p>이 예제는 모든 매퍼 메소드에 SQL 프로바이더 클래스를 전역 설정으로 공유하는 방법을 보여준다. (3.5.6 버전부터 사용 가능):</p>
754755
<source><![CDATA[
755756
Configuration configuration = new Configuration();
756-
configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class); // Specify an sql provider class for sharing on all mapper methods
757+
configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class); // 모든 mapper 메소드에 공유할 시, SQL 프로바이더 클래스를 지정한다.
757758
// ...]]></source>
758759
<source><![CDATA[
759-
// Can omit the type/value attribute on sql provider annotation
760-
// If omit it, the MyBatis apply the class that specified on defaultSqlProviderType.
760+
// sql provider 애노테이션에서 type/value 속성을 생략할 수 있다.
761+
// 생략시, 마이바티스는 defaultSqlProviderType으로 지정된 클래스를 적용한다.
761762
public interface UserMapper {
762763
763-
@SelectProvider // Same with @SelectProvider(TemplateFilePathProvider.class)
764+
@SelectProvider // @SelectProvider(TemplateFilePathProvider.class) 와 동일하다.
764765
User findUser(int id);
765766
766-
@InsertProvider // Same with @InsertProvider(TemplateFilePathProvider.class)
767+
@InsertProvider // @InsertProvider(TemplateFilePathProvider.class) 와 동일하다.
767768
void createUser(User user);
768769
769-
@UpdateProvider // Same with @UpdateProvider(TemplateFilePathProvider.class)
770+
@UpdateProvider // @UpdateProvider(TemplateFilePathProvider.class) 와 동일하다.
770771
void updateUser(User user);
771772
772-
@DeleteProvider // Same with @DeleteProvider(TemplateFilePathProvider.class)
773+
@DeleteProvider // @DeleteProvider(TemplateFilePathProvider.class) 와 동일하다.
773774
void deleteUser(int id);
774775
}]]></source>
775776

776-
<p>This example shows usage the default implementation of <code>ProviderMethodResolver</code>(available since MyBatis 3.5.1 or later):</p>
777+
<p>이 예제는 <code>ProviderMethodResolver</code>의 기본 구현 사용법을 보여준다.(MyBatis 3.5.1 버전 이상부터 사용가능):</p>
777778
<source><![CDATA[@SelectProvider(UserSqlProvider.class)
778779
List<User> getUsersByName(String name);
779780
780-
// Implements the ProviderMethodResolver on your provider class
781+
// provider 클래스에서 ProviderMethodResolver 를 구현한다.
781782
class UserSqlProvider implements ProviderMethodResolver {
782783
// In default implementation, it will resolve a method that method name is matched with mapper method
784+
// 기본 구현에서, 메소드 이름이 mapper 메소드와 일치하는 경우 해당 메소드를 찾는다.
783785
public static String getUsersByName(final String name) {
784786
return new SQL(){{
785787
SELECT("*");
@@ -792,11 +794,11 @@ class UserSqlProvider implements ProviderMethodResolver {
792794
}
793795
}]]></source>
794796

795-
<p>This example shows usage the <code>databaseId</code> attribute on the statement annotation(Available since 3.5.5):</p>
797+
<p>이 예제는 statement 애노테이션에서 <code>databaseId</code> 속성이 어떻게 활용되는지를 보여준다(3.5.5 버전부터 사용 가능):</p>
796798
<source><![CDATA[
797-
@Select(value = "SELECT SYS_GUID() FROM dual", databaseId = "oracle") // Use this statement if DatabaseIdProvider provide "oracle"
798-
@Select(value = "SELECT uuid_generate_v4()", databaseId = "postgres") // Use this statement if DatabaseIdProvider provide "postgres"
799-
@Select("SELECT RANDOM_UUID()") // Use this statement if the DatabaseIdProvider not configured or not matches databaseId
799+
@Select(value = "SELECT SYS_GUID() FROM dual", databaseId = "oracle") // DatabaseIdProvider가 "oracle"을 제공하면 이 구문을 사용한다.
800+
@Select(value = "SELECT uuid_generate_v4()", databaseId = "postgres") // DatabaseIdProvider가 "postgres"를 제공하면 이 구문을 사용한다.
801+
@Select("SELECT RANDOM_UUID()") // DatabaseIdProvider가 설정되지 않았거나 일치하는 databaseId가 없는 경우 이 구문을 사용한다.
800802
String generateId();
801803
]]></source>
802804

src/test/java/org/apache/ibatis/mapping/VendorDatabaseIdProviderTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ void shouldProductNameBeReturnedIfPropertiesIsNull() throws Exception {
5050
assertEquals(PRODUCT_NAME, provider.getDatabaseId(mockDataSource()));
5151
}
5252

53+
@Test
54+
void shouldProductNameBeReturnedIfPropertiesIsEmpty() throws Exception {
55+
VendorDatabaseIdProvider provider = new VendorDatabaseIdProvider();
56+
provider.setProperties(new Properties());
57+
assertEquals(PRODUCT_NAME, provider.getDatabaseId(mockDataSource()));
58+
}
59+
5360
@Test
5461
void shouldProductNameBeTranslated() throws Exception {
5562
VendorDatabaseIdProvider provider = new VendorDatabaseIdProvider();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2009-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.ibatis.reflection.property;
17+
18+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
19+
import static org.junit.jupiter.api.Assertions.*;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
/**
24+
* @author <a href="[email protected]">mawen12</a>
25+
*
26+
* @see PropertyTokenizer
27+
*/
28+
class PropertyTokenizerTest {
29+
30+
@Test
31+
void shouldParsePropertySuccessfully() {
32+
String fullname = "id";
33+
PropertyTokenizer tokenizer = new PropertyTokenizer(fullname);
34+
35+
assertEquals("id", tokenizer.getIndexedName());
36+
assertEquals("id", tokenizer.getName());
37+
38+
assertNull(tokenizer.getChildren());
39+
assertNull(tokenizer.getIndex());
40+
assertFalse(tokenizer.hasNext());
41+
assertNull(tokenizer.getIndex());
42+
43+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(tokenizer::remove)
44+
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
45+
}
46+
47+
@Test
48+
void shouldParsePropertyWhichContainsDelimSuccessfully() {
49+
String fullname = "person.id";
50+
PropertyTokenizer tokenizer = new PropertyTokenizer(fullname);
51+
52+
assertEquals("person", tokenizer.getIndexedName());
53+
assertEquals("person", tokenizer.getName());
54+
assertTrue(tokenizer.hasNext());
55+
assertEquals("id", tokenizer.getChildren());
56+
57+
assertNull(tokenizer.getIndex());
58+
59+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(tokenizer::remove)
60+
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
61+
}
62+
63+
@Test
64+
void shouldParsePropertyWhichContainsIndexSuccessfully() {
65+
String fullname = "array[0]";
66+
PropertyTokenizer tokenizer = new PropertyTokenizer(fullname);
67+
68+
assertEquals("array[0]", tokenizer.getIndexedName());
69+
assertEquals("array", tokenizer.getName());
70+
assertEquals("0", tokenizer.getIndex());
71+
72+
assertFalse(tokenizer.hasNext());
73+
assertNull(tokenizer.getChildren());
74+
75+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(tokenizer::remove)
76+
.withMessage("Remove is not supported, as it has no meaning in the context of properties.");
77+
}
78+
}

0 commit comments

Comments
 (0)