mybatis 插入数据,model的属性存在null,插入报错

在使用mybatis 进行insert时,如果字段值存在null的情况,会出现插入失败的情况,解决方案:

如果使用spring boot:

  1. @Bean
  2. ConfigurationCustomizer mybatisConfigurationCustomizer() {
  3. return new ConfigurationCustomizer() {
  4. @Override
  5. public void customize(org.apache.ibatis.session.Configuration configuration) {
  6. configuration.setJdbcTypeForNull(JdbcType.NULL);
  7. }
  8. };
  9. }

mybatis学习 -每天一记 mybatis insert null 报错的更多相关文章

  1. MyBatis学习总结(七)——Mybatis缓存(转载)

      孤傲苍狼 只为成功找方法,不为失败找借口! MyBatis学习总结(七)--Mybatis缓存 一.MyBatis缓存介绍 正如大多数持久层框架一样,MyBatis 同样提供了一级缓存和二级缓存的 ...

  2. 【转】MyBatis学习总结(七)——Mybatis缓存

    [转]MyBatis学习总结(七)——Mybatis缓存 一.MyBatis缓存介绍 正如大多数持久层框架一样,MyBatis 同样提供了一级缓存和二级缓存的支持 一级缓存: 基于PerpetualC ...

  3. 【转】MyBatis学习总结(一)——MyBatis快速入门

    [转]MyBatis学习总结(一)——MyBatis快速入门 一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC ...

  4. 转:MyBatis学习总结(Mybatis总结精华文章)

    http://www.cnblogs.com/xdp-gacl/tag/MyBatis%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/ 当前标签: MyBatis学习总结   ...

  5. oracle-function-into时为null报错

    oracle-function-into时为null报错 create or replace function P_ADD_CUSTOMER_FOR_CSS_heyt_test(i_cust_name ...

  6. mybatis查询时使用基本数据类型接收报错-attempted to return null from a method with a primitive return type (int)

    一.问题由来 自己在查看日志时发现日志中打印了一行错误信息为: 组装已经放养的宠物数据异常--->Mapper method 'applets.user.mapper.xxxMapper.xxx ...

  7. mybatis之insert语句报错Cause: java.sql.SQLException: sql injection violation, syntax error: ERROR. token : WHERE,

    报错日志:org.springframework.jdbc.UncategorizedSQLException: Error updating database. Cause: java.sql.SQ ...

  8. mybatis 批量insert,update报错 The error occurred while setting parameters

    数据脚本执行正常,但是报错,搜索关键信息 The error occurred while setting parameters ,发现了解决帖子: http://blog.csdn.net/jing ...

  9. MyBatis 学习记录5 MyBatis的二级缓存

    主题 之前学习了一下MyBatis的一级缓存,主要涉及到BaseExecutor这个类. 现在准备学习记录下MyBatis二级缓存. 配置二级缓存与初始化发生的事情 首先二级缓存默认是不开启的,需要自 ...

随机推荐

  1. IntelliJ IDEA 实用快捷键

    psvm--------------主(main)-----------------public staitc void main(String[] args) sout--------------- ...

  2. Python之PIL库的运用、GIF处理h

    一.PIL库简介 PIL(Python Image Library)库是Python语言的第三方库,它支持图像存储.显示和处理,它能够处理几乎所有图片格式,可以完成对图像的缩放.剪裁.折叠以及像图片添 ...

  3. django登录逻辑

    django-restframework中已经实现了登录逻辑,只需要安装配置就可以使用 pip install djangorestframework-jwt REST_FRAMEWORK = { ' ...

  4. uwp应用在debug模式下运行正常,编译为release版本的时候抛出异常

    原因是在代码中使用了dynamic关键字,导致release时.net native优化了代码造成元数据丢失 所以在代码中要尽量不用dynamic.

  5. CentOS7查看和关闭防火墙

    CentOS 7.0默认使用的是firewall作为防火墙 1.查看防火墙状态 firewall-cmd --state2.停止firewall systemctl stop firewalld.se ...

  6. Linux内核笔记:内存管理

    逻辑地址由16位segment selector和offset组成 根据segment selector到GDT或LDT中去查找segment descriptor 32位base,20位limit, ...

  7. openstack--10--知识点补充

    关于uuid和Fernet方式比较 提供令牌有四种方式[fernet|pkiz|pki|uuid]默认是uuid.

  8. 记录一次Struts s2-045重大安全漏洞修复过程

    [升级修复] 受影响用户可升级版本至Apache Struts 2.3.32 或 Apache Struts 2..5.10.1以消除漏洞影响. 官方公告:https://cwiki..apache. ...

  9. win2008安装并配置zabbix3.4 agent

    agent 下载地址: https://www.zabbix.com/download_agents 下载解压后有2个文件夹,一个是bin,存放32位和64位执行程序,一个是conf目录存放着配置文件 ...

  10. Vue.js中ref ($refs)用法举例总结

    原文地址:http://www.cnblogs.com/xueweijie/p/6907676.html <div id="app"> <input type=& ...