What version of the MyBatis are you using?
MyBatis 3.0.2
Please describe the problem. Unit tests are best!
JdbcType is required for nullable parameters, as JDBC specification dictates. I
know it is a very old topic, but I think MyBatis can improve this (see
additional information bellow).
What is the expected output? What do you see instead?
Expected: No error. MyBatis would use configuration+reflection to determine
jdbcType for null parameters without explicit jdbctype.
Actual: "JDBC requires that the JdbcType must be specified for all nullable
parameters"
Please provide any additional information below.
I have a lot of nullable parameters in my mappers, and basically of types
Boolean, Integer, String and Date. I have to put jdbcType NUMERIC, NUMERIC,
NVARCHAR and TIMESTAMP every time. I propose this: When the parameter comes
from a class property (not from a Map), the property java type can be used to
map to a jdbcType. By default Boolean (and descendants) would be mapped to
NUMERIC, Integer to NUMERIC, String to NVARCHAR and Date to TIMESTAMP, for
example. You could change the default behaviour by configuration. Or may be
this behaviour could be disabled by default (for backward compatibility) and
enabled explicitly. The configuration could be a new element
<defaultNullableParametersJdbcTypes enable="true"> with subelements for each
java type in the XML/object configuration, or may be by special parameters in
<parameters> or settings in <settings>. The mapping could be extended to any
java type.
I have seen some threads about the problem and a supposed solution here:
http://www.mail-archive.com/user-java@ibatis.apache.org/msg16078.html
but this is contradictory with the MyBatis documentation, that explicitly cites
the problem with no global solution.
Original issue reported on code.google.com by boccaro...@gmail.com on 12 Nov 2010 at 8:06
Original issue reported on code.google.com by
boccaro...@gmail.com
on 12 Nov 2010 at 8:06