Java, Mysql, 原创

关于MyBatis报错的奇葩问题,是String却提示Integer等等

先上报错信息:

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


org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'amap_city_code' from result set.  Cause: java.sql.SQLDataException: Value '310000000000' is outside of valid range for type java.lang.Integer

你是不是也遇到这个问题,各种调试又无法调通,完全没有头绪。

这个问题前面遇到过解决了, 后面又遇到却又忘了怎么解决, 来看看你的DO吧

@Data
@Entity
@Builder
@EqualsAndHashCode(callSuper = true)
@Table(name = "res_merge_building_statistics")
public class ResMergeBuildingStatisticsDO extends BaseSisuDO {
    @Description(value = "项目id")
    @Column(name = "building_id")
    private Long buildingId;
}

问题就出在了 @Builder, 把@Builder 去掉就无此问题了, 但是我们还就是想用@Builder 怎么处理呢,加2个构造注解:

@AllArgsConstructor
@NoArgsConstructor

于是DO 变为

@Data
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "res_merge_building_statistics")
public class ResMergeBuildingStatisticsDO extends BaseSisuDO {
    @Description(value = "项目id")
    @Column(name = "building_id")
    private Long buildingId;
}

好了,问题解决。

(38)

Author Since: Jul 05, 2018

Related Post