Skip to content
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

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

harawata
Copy link
Member

@harawata harawata commented Jan 3, 2025

A lot of related issues: #995 #1445 #2187 #3155

It's not ready for a proper review yet, but developers are welcome to test the functionality.
If you found a problematic use case, please share a test case.

# 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
@coveralls
Copy link

coveralls commented Jan 3, 2025

Coverage Status

coverage: 87.238% (+0.02%) from 87.217%
when pulling a38d06c on harawata:type-based-handler-resolution
into e202727 on mybatis:master.

# 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
@harawata harawata added the no backward compatibility Includes change no backward compatibility for previous version label Jan 29, 2025
@harawata harawata changed the title Resolve type handler based on java.lang.reflect.Type instead of Class Resolve type handler based on java.lang.reflect.Type instead of Class and respect runtime JDBC type Jan 29, 2025
…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.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants