首页 > 数据库技术 > 详细

mybatis: No enum constant org.apache.ibatis.type.JdbcType."VARCHAR"

时间:2020-09-06 21:31:16      阅读:95      评论:0      收藏:0      [点我收藏+]

mybatis 插入的时候一句sql报错如下。

 

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType."VARCHAR"

 

insert into sys_user(
             <if test="userId != null and userId != ‘‘ ">user_id,</if>
           

             create_time
         )values(
             <if test="userId != null and userId != ‘‘">#{userId,jdbcType="VARCHAR"},</if>
             
             sysdate
         )

原因在于

#{userId,jdbcType="VARCHAR"}, 

即mybatis所定义的类型常量枚举不存在,mybatis 解析为了"VARCHAR" 带双引号的字符串,改为

insert into sys_user(
             <if test="userId != null and userId != ‘‘ ">user_id,</if>
         

             create_time
         )values(
             <if test="userId != null and userId != ‘‘">#{userId,jdbcType=VARCHAR},</if>
         
             sysdate
         )

把双引号去掉或者直接不写jdbcType 即可。

mybatis: No enum constant org.apache.ibatis.type.JdbcType."VARCHAR"

原文:https://www.cnblogs.com/shuiliuhualuo/p/13623435.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!