1.pom文件引進(jìn)maven
? ? <groupId>com.baomidou
? ? <artifactId>mybatis-plus-annotation
? ? <version>3.2.0
? ? <groupId>com.baomidou
? ? <artifactId>mybatis-plus-extension
? ? <version>3.2.0
</dependency>
2.實(shí)體加注解:實(shí)體前與JSONObject字段前
@TableName(autoResultMap = true)
public class W? {
? ? @TableField(typeHandler = FastjsonTypeHandler.class)
? ? JSONObject ratingJson;
}
3.xml文件中加配置
<resultMap id="BaseResultMap(下面select引用的resultMap)" type="實(shí)體W路徑" >?
?<result column="ratingJson(JSONObject字段名)"?
property="ratingJson(JSONObject字段名)"?
jdbcType="OTHER" javaType="com.alibaba.fastjson.JSONObject"??
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler" />
</resultMap>
<select id="getW" resultType="實(shí)體W路徑" resultMap="BaseResultMap">? ? ? ? ? ? ? ??
SELECT? r.rating_json_ ratingJson? FROM? ? `waybill_rating_` r?
</select>