You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@SELECT("select a,b from table limit 1")
Map<String, Object> selectOne();
Steps to reproduce
Expected result
selectOne will return a map contain result select
Actual result
Error:
NullPointException when handling resultSet, root cause is Class.forName(null)
in FastResultSetHandler.java (DefaultResultSetHandler named in later verison)
the getTypeHandler method will throw NPE when classNames.get() return null.However, mybatis will handler the situation when can not load class(from classNames.get()).So it is ok when classNames.get() return null or can not load the class, we can ignore null.And we I ignore null,mybatis work well and return the result what I expected.
(I can not upload the image, so I paste the code)
In mybatis 3.1.1 which will throw NPE
finalClassjavaType = resolveClass((String)classNames.get(index)); //classNames.get() will return null in kylin-jdbc 1.5.1if(javaType != null && jdbcType != null) {`
handler = typeHandlerRegistry.getTypeHandler(javaType, jdbcType);
} elseif(javaType != null) {
handler = typeHandlerRegistry.getTypeHandler(javaType);
} elseif(jdbcType != null) { //notice:mybatis will get type handler by jdbcType if javaType is nullhandler = typeHandlerRegistry.getTypeHandler(jdbcType);
}
so if catch the NPE,maybe it will ok,and result is what I expected, following is code
Have you verified that the proposed change actually fixed your problem?
I just took a quick look at the driver code, but it is doubtful that MyBatis can return the column value if the column label was null.
yeah,I am sure it fixed my problem.I changed the mybatis source code and mvn install in local repo.Then I debug my program, it worked well.
The jdbcType of column is not null while javaType is.
MyBatis version
3.1.1
Database vendor and version
Kylin jdbc 1.5.1
Test case or example project
Steps to reproduce
Expected result
selectOne will return a map contain result select
Actual result
Error:
NullPointException when handling resultSet, root cause is Class.forName(null)
in FastResultSetHandler.java (DefaultResultSetHandler named in later verison)
the getTypeHandler method will throw NPE when classNames.get() return null.However, mybatis will handler the situation when can not load class(from classNames.get()).So it is ok when classNames.get() return null or can not load the class, we can ignore null.And we I ignore null,mybatis work well and return the result what I expected.
(I can not upload the image, so I paste the code)
In mybatis 3.1.1 which will throw NPE
so if catch the NPE,maybe it will ok,and result is what I expected, following is code
The text was updated successfully, but these errors were encountered: