-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Resolve type handler based on java.lang.reflect.Type
instead of Class
and respect runtime JDBC type
#3379
Merged
harawata
merged 30 commits into
mybatis:master
from
harawata:type-based-handler-resolution
Mar 15, 2025
Merged
Resolve type handler based on java.lang.reflect.Type
instead of Class
and respect runtime JDBC type
#3379
harawata
merged 30 commits into
mybatis:master
from
harawata:type-based-handler-resolution
Mar 15, 2025
+3,625
−761
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # src/main/java/org/apache/ibatis/builder/BaseBuilder.java # src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java # src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java # src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java # src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java # src/main/java/org/apache/ibatis/builder/xml/XMLStatementBuilder.java # src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java # src/main/java/org/apache/ibatis/mapping/ParameterMapping.java # src/main/java/org/apache/ibatis/mapping/ResultMapping.java # src/main/java/org/apache/ibatis/reflection/MetaClass.java # src/main/java/org/apache/ibatis/reflection/Reflector.java # src/main/java/org/apache/ibatis/reflection/ReflectorFactory.java # src/main/java/org/apache/ibatis/scripting/defaults/DefaultParameterHandler.java # src/main/java/org/apache/ibatis/scripting/xmltags/XMLLanguageDriver.java # src/main/java/org/apache/ibatis/session/AutoMappingUnknownColumnBehavior.java # src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java # src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java # src/test/java/org/apache/ibatis/reflection/ReflectorTest.java # src/test/java/org/apache/ibatis/reflection/TypeParameterResolverTest.java # src/test/java/org/apache/ibatis/submitted/language/VelocitySqlSourceBuilder.java
This was referenced Jan 3, 2025
# Conflicts: # src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java # src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java # src/main/java/org/apache/ibatis/scripting/defaults/DefaultParameterHandler.java # src/main/java/org/apache/ibatis/scripting/defaults/RawSqlSource.java # src/main/java/org/apache/ibatis/scripting/xmltags/DynamicSqlSource.java
… account Fail-fast is nice, but it practically prevents MyBatis from using runtime JDBC type information to resolve type handler. Related to mybatis#9 mybatis#19
java.lang.reflect.Type
instead of Class
java.lang.reflect.Type
instead of Class
and respect runtime JDBC type
Loading status checks…
…ndler - Deprecated UnknownTypeHandler. Type handler resolution is delayed if not explicitly specified. - Use registered type handler when retrieving OUT parameters. This could affect - Changed the column order in `src/test/resources/org/apache/ibatis/submitted/nestedresulthandler_gh1551/ProductMapper.xml` as UnknownTypeHandler handled duplicate columns differently.
For "composite keys", the behavior changes depending on the existence of `parameterType` When `parameterType` is not specified, parameter values are stored in a `Map` and custom type handler is not used. When `parameterType="User"` is specified, `User` instance is created and properties are set using type handlers. Related to mybatisgh-114 For "simple key", `parameterType` is ignored and custom type handler is not used at all. I can think of some corner cases caused by these behaviors, but will deal with them when/if they come up.
Loading status checks…
…esolution
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.
This was referenced Mar 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
no backward compatibility
Includes change no backward compatibility for previous version
🔩 typehandler
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Foo<Bar>
).java.lang.reflect.Type
instead ofjava.lang.Class
as a sole argument of its constructor. TypeHandler lost information of actualTypeArguments when class is ParameterizedType #2187Class
orType
as a constructor argument) are processed correctly when it is specified in a parameter reference (i.e.#{param,typeHandler=x}
) or in a result map (i.e.<result ... typeHandler="x">
). BaseBuilder#resolveTypeHandler does not account javaType for caching handlers #995ParameterMetaData
orResultSetMetaData
.