Postgresql报错及解决方案:Bad value for type int / DataIntegrityVoilationException

2022-07-26,,,

1 报错信息

  • Spring报错
    org.springframework.dao,DataIntegrityVoilationException:Error attempting to get column 'xx' from result set
  • 数据库报错
    org.postgresql.util.PSQLException:Bad value for type int

2 错误原因

实体类属性定义为Integer,但数据库该字段类型为varchar

3 触发机制

本人所遇到的情况为:如果该数据库该字段为null时,进行查询操作会触发该报错.如果数据库该字段刚好有数字字符,则不会触发

4 解决方案

将该字段属性改为String即可解决问题

本文地址:https://blog.csdn.net/java0506/article/details/110676067

《Postgresql报错及解决方案:Bad value for type int / DataIntegrityVoilationException.doc》

下载本文的Word格式文档,以方便收藏与打印。