Today mybatis reported error
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='InfoId', mode=IN, javaType=class java.lang.Long, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
As if to say the transformation error.
The mapper.java
mapper.xml
And entities checked.
Finally found the reason
mapper.java in the reference to an int
XXXDTO getXXXInfoId(int xxxInfoId);
To the mybatis of the parameters defined mapper.xml becomes long, resulting in the above error.
<select id="getXXXInfoId" parameterType="long" resultMap="XXXResultMap">
The long into an int, the problem is solved.
<select id="getXXXInfoId" parameterType="int" resultMap="XXXResultMap">