首页 > 技术文章 > MyBatis 配置/注解 SQL CRUD 经典解决方案(2019.08.15持续更新)

ylhssn 2019-08-15 08:59 原文

本文旨在记录使用各位大神的经典解决方案。

2019.08.14 更新

  1. Mybatis saveOrUpdate SelectKey非主键的使用

  2. MyBatis实现SaveOrUpdate

  3. mybatis实现insertOrUpdate功能

  4. MyBatis实现SaveOrUpdate终极万能版

  5. InsertOrUpdate的一些注意项 (数据库隔离级别、事务影响)

  6. Mybatis SqlSessionTemplate 源码解析

2019.08.15 更新

 【 MySQL 5.7.X + Mybatis】 json字段的数据读取、存储

 1.注解版

1)字段注解仅需指定 JdbcType.VARCHAR 即可,无需配置typeHandler
eg:
 @column(name="follow_history", attrName="followHistory", label="维保信息" ,jdbcType = JdbcType.VARCHAR) 

2)指定json字段为Object类型
eg:
private Object followHistory;

3)json字段在保存时需JSON.toJSONString()
eg:
if(bean.getFollowHistory()!=null){
bean.setFollowHistory(JSON.toJSONString(bean.getFollowHistory()));
}

4)json字段直接bean.getXXX()即可获取,请依据业务配合JSON格式化类库使用

  2.配置版

     待补充

推荐阅读