java.sql.SQLDataException Unsupported conversion from DATETIME to java.lang.Integer

2022-03-15 01:33:37  阅读 5371 次 评论 1 条

初学SpringBoot,留个笔记

报错信息:

org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'create_time' from result set.  Cause: java.sql.SQLDataException: Unsupported conversion from DATETIME to java.lang.Integer

; Unsupported conversion from DATETIME to java.lang.Integer; nested exception is java.sql.SQLDataException: Unsupported conversion from DATETIME to java.lang.Integer


事故起因:

使用Mybatis-plus在 mapper中手写SQL引起。

bean类中有Date类型属性,MySQL中也有对应字段,使用QueryWrapper操作正常,但@Select 手写报错


解决方法:

bean类加上注解@NoArgsConstructor


深层原因以我目前修为不是很明白,猜测此不同类型,工具无法直接使用构造方法创建对象,得用setter,难道setter那里就能转换类型了?

本文地址:http://bloguan.com/?id=582
版权声明:本文为原创文章,版权归 博观网 所有,欢迎分享本文,转载请保留出处!

发表评论


表情

评论列表

  1. 访客
    访客  @回复

    应该是你用@Builder()注解了