Skip to content

Use imports instead of fully qualified #3351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.apache.ibatis.builder;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -452,7 +453,7 @@ private Class<?> resolveParameterJavaType(Class<?> resultType, String property,
JdbcType jdbcType) {
if (javaType == null) {
if (JdbcType.CURSOR.equals(jdbcType)) {
javaType = java.sql.ResultSet.class;
javaType = ResultSet.class;
} else if (Map.class.isAssignableFrom(resultType)) {
javaType = Object.class;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.apache.ibatis.builder;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -99,7 +100,7 @@ private ParameterMapping buildParameterMapping(String content) {
} else if (typeHandlerRegistry.hasTypeHandler(parameterType)) {
propertyType = parameterType;
} else if (JdbcType.CURSOR.name().equals(propertiesMap.get("jdbcType"))) {
propertyType = java.sql.ResultSet.class;
propertyType = ResultSet.class;
} else if (property == null || Map.class.isAssignableFrom(parameterType)) {
propertyType = Object.class;
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -159,8 +161,8 @@ public TypeHandlerRegistry(Configuration configuration) {
register(JdbcType.TIME, new TimeOnlyTypeHandler());

register(java.sql.Date.class, new SqlDateTypeHandler());
register(java.sql.Time.class, new SqlTimeTypeHandler());
register(java.sql.Timestamp.class, new SqlTimestampTypeHandler());
register(Time.class, new SqlTimeTypeHandler());
register(Timestamp.class, new SqlTimestampTypeHandler());

register(String.class, JdbcType.SQLXML, new SqlxmlTypeHandler());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.sql.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -53,8 +54,8 @@ class DataClass {
@Test
void issue2609() throws Exception {
Map<String, Object> context = new HashMap<>();
context.put("d1", java.sql.Date.valueOf("2022-01-01"));
context.put("d2", java.sql.Date.valueOf("2022-01-02"));
context.put("d1", Date.valueOf("2022-01-01"));
context.put("d2", Date.valueOf("2022-01-02"));
assertEquals(-1, OgnlCache.getValue("d1.compareTo(d2)", context));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.property.PropertyTokenizer;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;

public class CustomObjectWrapper implements org.apache.ibatis.reflection.wrapper.ObjectWrapper {
public class CustomObjectWrapper implements ObjectWrapper {

private final CustomCollection collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;

public class CustomObjectWrapperFactory implements org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory {
public class CustomObjectWrapperFactory implements ObjectWrapperFactory {

@Override
public boolean hasWrapperFor(Object object) {
Expand All @@ -27,7 +28,7 @@ public boolean hasWrapperFor(Object object) {

@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
return new org.apache.ibatis.submitted.custom_collection_handling.CustomObjectWrapper((CustomCollection) object);
return new CustomObjectWrapper((CustomCollection) object);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.apache.ibatis.submitted.language;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -77,7 +78,7 @@ private ParameterMapping buildParameterMapping(String content) {
if (typeHandlerRegistry.hasTypeHandler(parameterType)) {
propertyType = parameterType;
} else if (JdbcType.CURSOR.name().equals(jdbcType)) {
propertyType = java.sql.ResultSet.class;
propertyType = ResultSet.class;
} else if (property != null) {
MetaClass metaClass = MetaClass.forClass(parameterType, configuration.getReflectorFactory());
if (metaClass.hasGetter(property)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DateTypeHandlerTest extends BaseTypeHandlerTest {
@Test
public void shouldSetParameter() throws Exception {
TYPE_HANDLER.setParameter(ps, 1, DATE, null);
verify(ps).setTimestamp(1, new java.sql.Timestamp(DATE.getTime()));
verify(ps).setTimestamp(1, new Timestamp(DATE.getTime()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.sql.Time;
import java.util.Date;

import org.junit.jupiter.api.Test;

class SqlTimeTypeHandlerTest extends BaseTypeHandlerTest {

private static final TypeHandler<java.sql.Time> TYPE_HANDLER = new SqlTimeTypeHandler();
private static final java.sql.Time SQL_TIME = new java.sql.Time(new Date().getTime());
private static final TypeHandler<Time> TYPE_HANDLER = new SqlTimeTypeHandler();
private static final Time SQL_TIME = new Time(new Date().getTime());

@Override
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class SqlTimetampTypeHandlerTest extends BaseTypeHandlerTest {

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

@Override
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.sql.Time;
import java.util.Date;

import org.junit.jupiter.api.Test;
Expand All @@ -29,7 +30,7 @@ class TimeOnlyTypeHandlerTest extends BaseTypeHandlerTest {

private static final TypeHandler<Date> TYPE_HANDLER = new TimeOnlyTypeHandler();
private static final Date DATE = new Date();
private static final java.sql.Time SQL_TIME = new java.sql.Time(DATE.getTime());
private static final Time SQL_TIME = new Time(DATE.getTime());

@Override
@Test
Expand Down
Loading