nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping


今天mybatis报了个错误

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

 

好像是说转型错误。

把mapper.java

mapper.xml

和实体查了一下。

最后找到原因

mapper.java里入参为int型

XXXDTO getXXXInfoId(int xxxInfoId);

到mybatis的mapper.xml入参定义成了long,导致了上面的错误。

<select id="getXXXInfoId" parameterType="long" resultMap="XXXResultMap">

把long改成int型,问题解决。

<select id="getXXXInfoId" parameterType="int" resultMap="XXXResultMap">

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM