一、String数组
1.mysql 字段类型为json
2.java实体类字段类型为List<String>
@ApiModelProperty(value = "后缀")
@TableField(value = "postfix", typeHandler = JacksonTypeHandler.class)
private List<String> postfix;
TableName注解要加autoResultMap
@TableName(value = "op_dataset_view_conf",autoResultMap = true)
3.xml 字段加typehandler
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhito.sjpt.common.database.mapper.op.DatasetViewConfMapper">
<resultMap id="DatasetViewConf" type="com.zhito.sjpt.common.database.entity.op.DatasetViewConf">
<id column="id" property="id"/>
<result column="type" property="type"/>
<result column="play_next" property="playNext"/>
<result column="postfix" property="postfix" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result column="replay" property="replay"/>
</resultMap>
</mapper>
4.结果能查能插
查
插
二 、换成对象类型
和上面一样,把实体类字段的类型改成相应的对象类型即可
一样能插能查
三、对象数组类型
和上面一样,把实体类字段类型修改为
结果 能插能查