mybatis的自定义类型转化器如何使用

   

  

  <?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.****.dao.StudentVOMapper">
  <resultMap id="BaseResultMap" type="com.****.bean.Student">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="age" jdbcType="INTEGER" property="age" />
    <result column="config" jdbcType="VARCHAR" property="config" typeHandler="com.****.typehandler.AbstractClassJsonTypeHandler"/>
  </resultMap>
<insert id="insert" parameterType="com.*****.bean.Student" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  insert into student(name, age,config)
  values (#{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER},
   ,#{config,jdbcType=VARCHAR,typeHandler=com.****.typehandler.AbstractClassJsonTypeHandler}

    )
</insert>
</mapper>

 

posted on 2022-03-10 11:47  朱古力88  阅读(79)  评论(0编辑  收藏  举报