记录学习SSM框架遇到的问题3
异常报告
消息 Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘id’, mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #3 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2).
描述 服务器遇到一个意外的情况,阻止它完成请求。
出现问题的原因主要是出现在mapper.xml文件中,可能会有几个原因:
1、两个#写在了一起,会出现识别错误 (我的错误)
<update id="updateById" parameterType="main.java.com.dy.domain.News">
update news
<set>
<include refid="News_update"/>
</set>
where id=##{id}
</update>
2、里面出现javaEE的注释/* */
<update id="updateById" parameterType="main.java.com.dy.domain.News">
update news
<set> /* */
<include refid="News_update"/>
</set>
where id=#{id}
</update>
3、#{id}被单引号盖住了(摘自网上被人的错误 )
<update id="updateById" parameterType="main.java.com.dy.domain.News">
update news
<set>
<include refid="News_update"/>
</set>
where id='#{id}'
</update>
以上各种细节错误可能都会导致SQL语句执行时出现错误,所以以后开发过程程中还是尽量细心一点。
最后
以上就是怡然御姐最近收集整理的关于mapper.xml出现错误 Error setting non null for parameter #3 with JdbcType null .的全部内容,更多相关mapper.xml出现错误内容请搜索靠谱客的其他文章。
发表评论 取消回复