causeby:org.apache.ibatis.exceptions.PersitenceException: Cause: java.sql.SQLIntegerityConstraintViolationException:Colum ‘type’ cannot be null

异常界面显示:
cause by : org.apache.ibatis.exceptions.PersitenceException:
cause by : org.apache.ibatis.exceptions.PersitenceException:相关代码截图:

cause by : org.apache.ibatis.exceptions.PersitenceException:
异常排查时使用的截图:
cause by : org.apache.ibatis.exceptions.PersitenceException:
异常解决截图(正确):
cause by : org.apache.ibatis.exceptions.PersitenceException:错误代码截图(对照查看):
cause by : org.apache.ibatis.exceptions.PersitenceException:

异常分析:
添加相关正确信息之后,点击发布提示“添加失败”,说明添加的功能出了问题,查看F12中的Form Data 中的数据,发现表单数据能够正常的接收,接下来,我在后台控制台打印Room对象中的数据,发现显示里面的值全是null,那么问题有两种,第一种就是并没有从前台接收到数据,可以在控制台中测试、打印接收的数据,发现可以接收到数据,那么就是在实体类中的问题,由于Room实体类中没有相应的有参构造器,我是通过Alt+Enter创建的(错误代码图片),所以第一个参数就是Object o,而不是Integer rid,因此出现了问题。修改后,代码成功运行!

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-10-23
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-04-01
猜你喜欢
  • 2021-08-30
  • 2022-12-23
  • 2021-11-06
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案