`

org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for

阅读更多
对于org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter...这个异常,是由于javaType和jdbcType的类型不匹配造成的。

<insert id="add" parameterType="Message">
        insert into t_message(id,content,createtime,t_student_id,t_class_id)
        values(#{id},#{content},#{createTime},#{student},#{class})
</insert>



我的数据库里,t_student_id和t_class_id是varchar类型,Message里面有student和class对象,所以直接按上面方案配置,就会报typehandler异常,解决方法也很简单:


<insert id="add" parameterType="Message">
        insert into t_message(id,content,createtime,t_student_id,t_class_id)
        values(#{id},#{content},#{createTime},#{student.id},#{class.id})
</insert>


用直接类似EL表达式的方式即可绑定你想给定的数据类型 !
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics