在Mybatis-Plus中指定TypeHandler后不生效的问题与解决办法

实体类中字段的定义


    /**
     * 抄送人id数组
     */
    @TableField(typeHandler = IntegerListTypeHandler.class)
    private List<Integer> copyTo;

IpTypeHandler 是一个将 32 位无符号数转换为字符串(或者反过来)的处理器。

经过如此指定之后,在插入时,表现正常,查询时则查出来一个无符号数。

两种解决办法:

  1. 实体类上打上注解:@TableName(value = "数据库表名", autoResultMap = true)

  1. 如果mapper中是以resultMap接收


    <resultMap type="EnquiryAudit" id="EnquiryAuditResult">
        <result property="auditId" column="audit_id"/>
        <result property="enquiryId" column="enquiry_id"/>
        <result property="flowNodeId" column="flow_node_id"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="auditInfo" column="audit_info"/>
        <result property="auditDate" column="audit_date"/>
        <result property="rejectCause" column="reject_cause"/>
        <result property="superiorId" column="superior_id"/>
        <result property="isDeleted" column="is_deleted"/>
        <result property="flowNodeName" column="flow_node_name"/>
        <result property="flowNodeRole" column="flow_node_role"/>
        <result property="copyTo" column="copy_to" typeHandler="com.yuepu.common.handler.IntegerListTypeHandler"/>
    </resultMap>

参考文章链接:

https://blog.csdn.net/qq_35098526/article/details/117912886

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值