Mapper method parsing exceptions are vauge and often unhelpful

16 views
Skip to first unread message

Andrew Strickland

unread,
Feb 14, 2022, 12:07:20 AMFeb 14
to mybatis-user

Hey Everyone
I use MyBatis quite frequently for my job. In the last week I had created a Mapper that I would like to share between multiple projects by placing it in a project that each of the others had a dependency on. One of the projects had a TypeHandler registerd to handle "TypeA" while the other project did not. When MyBatis tried to parse the mapper in one project I was met with the error message "No typehandler found for property null".
Weird ...
None of the methods that used "TypeA" were being used in this project; however the MapperAnnotationBuilder class parses each mapper method when a mapper is added to a config, regardless if it gets used or not. I have added more context to these parsing exceptions by adding the mapper's fully qualified class name, method name and argument types. Still the "property null" part of the message did not make sense, and I traced it to an error message that relied on the "name" property of the @Arg annotation to be present, even though it is not required. I changed this error message to use "column" if "name" was null.
This error message now looks like the following:

Error while parsing mapper method com.example.andrew.MyMapper#methodNameHere(int):
No typehandler found for column 'exampleCol'

Would others find this method information more helpful when debugging mapper parsing exceptions? Admittedly these exceptions are probably rare for most, but mistakes are easy, and messages like the former are not very helpful at catching those mistakes.
Reply all
Reply to author
Forward
0 new messages