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