Skip to content

Commit b5a8c62

Browse files
committed
Merge branch 'master' into feat/2618-auto-determine-type-when-missing
2 parents 541fc61 + 7939f2a commit b5a8c62

File tree

9 files changed

+46
-25
lines changed

9 files changed

+46
-25
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
<dependency>
208208
<groupId>org.assertj</groupId>
209209
<artifactId>assertj-core</artifactId>
210-
<version>3.27.1</version>
210+
<version>3.27.2</version>
211211
<scope>test</scope>
212212
</dependency>
213213
<dependency>

src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -235,7 +235,7 @@ private Configuration getConfiguration() {
235235
+ FACTORY_METHOD + "] is not static.");
236236
}
237237

238-
if (!factoryMethod.isAccessible()) {
238+
if (!factoryMethod.canAccess(null)) {
239239
configurationObject = AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
240240
try {
241241
factoryMethod.setAccessible(true);

src/main/java/org/apache/ibatis/scripting/xmltags/OgnlMemberAccess.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -48,7 +48,7 @@ public Object setup(OgnlContext context, Object target, Member member, String pr
4848
Object result = null;
4949
if (isAccessible(context, target, member, propertyName)) {
5050
AccessibleObject accessible = (AccessibleObject) member;
51-
if (!accessible.isAccessible()) {
51+
if (!accessible.canAccess(target)) {
5252
result = Boolean.FALSE;
5353
accessible.setAccessible(true);
5454
}

src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomObjectFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -48,13 +48,13 @@ private <T> T instantiateClass(Class<T> type, List<Class<?>> constructorArgTypes
4848
Constructor<T> constructor;
4949
if (constructorArgTypes == null || constructorArgs == null) {
5050
constructor = type.getDeclaredConstructor();
51-
if (!constructor.isAccessible()) {
51+
if (!constructor.canAccess(null)) {
5252
constructor.setAccessible(true);
5353
}
5454
return constructor.newInstance();
5555
}
5656
constructor = type.getDeclaredConstructor(constructorArgTypes.toArray(new Class[constructorArgTypes.size()]));
57-
if (!constructor.isAccessible()) {
57+
if (!constructor.canAccess(null)) {
5858
constructor.setAccessible(true);
5959
}
6060
return constructor.newInstance(constructorArgs.toArray(new Object[constructorArgs.size()]));

src/test/java/org/apache/ibatis/testcontainers/MysqlContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -36,7 +36,7 @@ public final class MysqlContainer {
3636

3737
private static MySQLContainer<?> initContainer() {
3838
@SuppressWarnings("resource")
39-
MySQLContainer<?> container = new MySQLContainer<>().withDatabaseName(DB_NAME).withUsername(USERNAME)
39+
MySQLContainer<?> container = new MySQLContainer<>("mysql").withDatabaseName(DB_NAME).withUsername(USERNAME)
4040
.withPassword(PASSWORD).withUrlParam("useSSL", "false");
4141
container.start();
4242
return container;

src/test/java/org/apache/ibatis/testcontainers/PgContainer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -31,8 +31,8 @@ public final class PgContainer {
3131

3232
private static PostgreSQLContainer<?> initContainer() {
3333
@SuppressWarnings("resource")
34-
PostgreSQLContainer<?> container = new PostgreSQLContainer<>().withDatabaseName(DB_NAME).withUsername(USERNAME)
35-
.withPassword(PASSWORD);
34+
PostgreSQLContainer<?> container = new PostgreSQLContainer<>("postgres").withDatabaseName(DB_NAME)
35+
.withUsername(USERNAME).withPassword(PASSWORD);
3636
container.start();
3737
return container;
3838
}

src/test/java/org/apache/ibatis/type/DateOnlyTypeHandlerTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 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.
@@ -17,6 +17,7 @@
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;
1919
import static org.junit.jupiter.api.Assertions.assertNull;
20+
import static org.junit.jupiter.api.Assertions.assertSame;
2021
import static org.mockito.Mockito.never;
2122
import static org.mockito.Mockito.verify;
2223
import static org.mockito.Mockito.when;
@@ -42,7 +43,9 @@ public void shouldSetParameter() throws Exception {
4243
@Test
4344
public void shouldGetResultFromResultSetByName() throws Exception {
4445
when(rs.getDate("column")).thenReturn(SQL_DATE);
45-
assertEquals(DATE, TYPE_HANDLER.getResult(rs, "column"));
46+
Date actual = TYPE_HANDLER.getResult(rs, "column");
47+
assertEquals(DATE, actual);
48+
assertSame(DATE.getClass(), actual.getClass());
4649
verify(rs, never()).wasNull();
4750
}
4851

@@ -58,7 +61,9 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5861
@Test
5962
public void shouldGetResultFromResultSetByPosition() throws Exception {
6063
when(rs.getDate(1)).thenReturn(SQL_DATE);
61-
assertEquals(DATE, TYPE_HANDLER.getResult(rs, 1));
64+
Date actual = TYPE_HANDLER.getResult(rs, 1);
65+
assertEquals(DATE, actual);
66+
assertSame(DATE.getClass(), actual.getClass());
6267
verify(rs, never()).wasNull();
6368
}
6469

@@ -74,7 +79,9 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7479
@Test
7580
public void shouldGetResultFromCallableStatement() throws Exception {
7681
when(cs.getDate(1)).thenReturn(SQL_DATE);
77-
assertEquals(DATE, TYPE_HANDLER.getResult(cs, 1));
82+
Date actual = TYPE_HANDLER.getResult(cs, 1);
83+
assertEquals(DATE, actual);
84+
assertSame(DATE.getClass(), actual.getClass());
7885
verify(cs, never()).wasNull();
7986
}
8087

src/test/java/org/apache/ibatis/type/DateTypeHandlerTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -17,6 +17,7 @@
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;
1919
import static org.junit.jupiter.api.Assertions.assertNull;
20+
import static org.junit.jupiter.api.Assertions.assertSame;
2021
import static org.mockito.Mockito.never;
2122
import static org.mockito.Mockito.verify;
2223
import static org.mockito.Mockito.when;
@@ -43,7 +44,9 @@ public void shouldSetParameter() throws Exception {
4344
@Test
4445
public void shouldGetResultFromResultSetByName() throws Exception {
4546
when(rs.getTimestamp("column")).thenReturn(TIMESTAMP);
46-
assertEquals(DATE, TYPE_HANDLER.getResult(rs, "column"));
47+
Date actual = TYPE_HANDLER.getResult(rs, "column");
48+
assertEquals(DATE, actual);
49+
assertSame(DATE.getClass(), actual.getClass());
4750
verify(rs, never()).wasNull();
4851
}
4952

@@ -59,7 +62,9 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5962
@Test
6063
public void shouldGetResultFromResultSetByPosition() throws Exception {
6164
when(rs.getTimestamp(1)).thenReturn(TIMESTAMP);
62-
assertEquals(DATE, TYPE_HANDLER.getResult(rs, 1));
65+
Date actual = TYPE_HANDLER.getResult(rs, 1);
66+
assertEquals(DATE, actual);
67+
assertSame(DATE.getClass(), actual.getClass());
6368
verify(rs, never()).wasNull();
6469
}
6570

@@ -75,7 +80,9 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7580
@Test
7681
public void shouldGetResultFromCallableStatement() throws Exception {
7782
when(cs.getTimestamp(1)).thenReturn(TIMESTAMP);
78-
assertEquals(DATE, TYPE_HANDLER.getResult(cs, 1));
83+
Date actual = TYPE_HANDLER.getResult(cs, 1);
84+
assertEquals(DATE, actual);
85+
assertSame(DATE.getClass(), actual.getClass());
7986
verify(cs, never()).wasNull();
8087
}
8188

src/test/java/org/apache/ibatis/type/TimeOnlyTypeHandlerTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2024 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.
@@ -17,6 +17,7 @@
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;
1919
import static org.junit.jupiter.api.Assertions.assertNull;
20+
import static org.junit.jupiter.api.Assertions.assertSame;
2021
import static org.mockito.Mockito.never;
2122
import static org.mockito.Mockito.verify;
2223
import static org.mockito.Mockito.when;
@@ -43,7 +44,9 @@ public void shouldSetParameter() throws Exception {
4344
@Test
4445
public void shouldGetResultFromResultSetByName() throws Exception {
4546
when(rs.getTime("column")).thenReturn(SQL_TIME);
46-
assertEquals(DATE, TYPE_HANDLER.getResult(rs, "column"));
47+
Date actual = TYPE_HANDLER.getResult(rs, "column");
48+
assertEquals(DATE, actual);
49+
assertSame(DATE.getClass(), actual.getClass());
4750
verify(rs, never()).wasNull();
4851
}
4952

@@ -59,7 +62,9 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5962
@Test
6063
public void shouldGetResultFromResultSetByPosition() throws Exception {
6164
when(rs.getTime(1)).thenReturn(SQL_TIME);
62-
assertEquals(DATE, TYPE_HANDLER.getResult(rs, 1));
65+
Date actual = TYPE_HANDLER.getResult(rs, 1);
66+
assertEquals(DATE, actual);
67+
assertSame(DATE.getClass(), actual.getClass());
6368
verify(rs, never()).wasNull();
6469
}
6570

@@ -75,7 +80,9 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7580
@Test
7681
public void shouldGetResultFromCallableStatement() throws Exception {
7782
when(cs.getTime(1)).thenReturn(SQL_TIME);
78-
assertEquals(DATE, TYPE_HANDLER.getResult(cs, 1));
83+
Date actual = TYPE_HANDLER.getResult(cs, 1);
84+
assertEquals(DATE, actual);
85+
assertSame(DATE.getClass(), actual.getClass());
7986
verify(cs, never()).wasNull();
8087
}
8188

0 commit comments

Comments
 (0)