Skip to content

Commit bcb00f8

Browse files
committed
Revised default type handler registration
If a handler is registered against null JDBC type, it is the default handler for the Java type. Users can override the default handler (e.g. `register(boolean.class, null, new YNBooleanTypeHandler())` or register a custom handler for a specific Java-JDBC type combination (e.g. `register(boolean.class, JdbcType.CHAR, new YNBooleanTypeHandler())`). Type handlers in the `jdbcTypeHandlerMap` are used when Java type is unknown or as a last resort when no matching handler is found for the target Java type.
1 parent 9e56276 commit bcb00f8

20 files changed

+118
-110
lines changed

src/main/java/org/apache/ibatis/type/BigDecimalTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -25,6 +25,7 @@
2525
* @author Clinton Begin
2626
*/
2727
public class BigDecimalTypeHandler extends BaseTypeHandler<BigDecimal> {
28+
public static final BigDecimalTypeHandler INSTANCE = new BigDecimalTypeHandler();
2829

2930
@Override
3031
public void setNonNullParameter(PreparedStatement ps, int i, BigDecimal parameter, JdbcType jdbcType)

src/main/java/org/apache/ibatis/type/BlobTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -26,6 +26,7 @@
2626
* @author Clinton Begin
2727
*/
2828
public class BlobTypeHandler extends BaseTypeHandler<byte[]> {
29+
public static final BlobTypeHandler INSTANCE = new BlobTypeHandler();
2930

3031
@Override
3132
public void setNonNullParameter(PreparedStatement ps, int i, byte[] parameter, JdbcType jdbcType)

src/main/java/org/apache/ibatis/type/BooleanTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -24,6 +24,7 @@
2424
* @author Clinton Begin
2525
*/
2626
public class BooleanTypeHandler extends BaseTypeHandler<Boolean> {
27+
public static final BooleanTypeHandler INSTANCE = new BooleanTypeHandler();
2728

2829
@Override
2930
public void setNonNullParameter(PreparedStatement ps, int i, Boolean parameter, JdbcType jdbcType)

src/main/java/org/apache/ibatis/type/ByteArrayTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -24,6 +24,7 @@
2424
* @author Clinton Begin
2525
*/
2626
public class ByteArrayTypeHandler extends BaseTypeHandler<byte[]> {
27+
public static final ByteArrayTypeHandler INSTANCE = new ByteArrayTypeHandler();
2728

2829
@Override
2930
public void setNonNullParameter(PreparedStatement ps, int i, byte[] parameter, JdbcType jdbcType)

src/main/java/org/apache/ibatis/type/ByteTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -24,6 +24,7 @@
2424
* @author Clinton Begin
2525
*/
2626
public class ByteTypeHandler extends BaseTypeHandler<Byte> {
27+
public static final ByteTypeHandler INSTANCE = new ByteTypeHandler();
2728

2829
@Override
2930
public void setNonNullParameter(PreparedStatement ps, int i, Byte parameter, JdbcType jdbcType) throws SQLException {

src/main/java/org/apache/ibatis/type/ClobTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -26,6 +26,7 @@
2626
* @author Clinton Begin
2727
*/
2828
public class ClobTypeHandler extends BaseTypeHandler<String> {
29+
public static final ClobTypeHandler INSTANCE = new ClobTypeHandler();
2930

3031
@Override
3132
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType)

src/main/java/org/apache/ibatis/type/DateOnlyTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -25,6 +25,7 @@
2525
* @author Clinton Begin
2626
*/
2727
public class DateOnlyTypeHandler extends BaseTypeHandler<Date> {
28+
public static final DateOnlyTypeHandler INSTANCE = new DateOnlyTypeHandler();
2829

2930
@Override
3031
public void setNonNullParameter(PreparedStatement ps, int i, Date parameter, JdbcType jdbcType) throws SQLException {

src/main/java/org/apache/ibatis/type/DateTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -26,6 +26,7 @@
2626
* @author Clinton Begin
2727
*/
2828
public class DateTypeHandler extends BaseTypeHandler<Date> {
29+
public static final DateTypeHandler INSTANCE = new DateTypeHandler();
2930

3031
@Override
3132
public void setNonNullParameter(PreparedStatement ps, int i, Date parameter, JdbcType jdbcType) throws SQLException {

src/main/java/org/apache/ibatis/type/DoubleTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -24,6 +24,7 @@
2424
* @author Clinton Begin
2525
*/
2626
public class DoubleTypeHandler extends BaseTypeHandler<Double> {
27+
public static final DoubleTypeHandler INSTANCE = new DoubleTypeHandler();
2728

2829
@Override
2930
public void setNonNullParameter(PreparedStatement ps, int i, Double parameter, JdbcType jdbcType)

src/main/java/org/apache/ibatis/type/FloatTypeHandler.java

Lines changed: 2 additions & 1 deletion
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.
@@ -24,6 +24,7 @@
2424
* @author Clinton Begin
2525
*/
2626
public class FloatTypeHandler extends BaseTypeHandler<Float> {
27+
public static final FloatTypeHandler INSTANCE = new FloatTypeHandler();
2728

2829
@Override
2930
public void setNonNullParameter(PreparedStatement ps, int i, Float parameter, JdbcType jdbcType) throws SQLException {

0 commit comments

Comments
 (0)