ITeye博客

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

cline · 2012-05-15 16:38 · mybatis · 编程语言 · MyBatis · typeHandler · executorexception · Markdown

对于[color=red]org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter...[/color]这个异常,是由于javaType和jdbcType的类型不匹配造成的。 [code="xml"] insert into t_message(id,content,createtime,t_student_id,t_class_id) values(#{id},#{content},#{createTime},#{student},#{class}) [/code] [color=green] 我的数据库里,t_student_id和t_class_id是varchar类型,Message里面有student和class对象,所以直接按上面方案配置,就会报typehandler异常,解决方法也很简单: [/color] [code="xml"] insert into t_message(id,content,createtime,t_student_id,t_class_id) values(#{id},#{content},#{createTime},#{student.id},#{class.id}) [/code] [color=red]用直接类似EL表达式的方式即可绑定你想给定的数据类型 ![/color]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。