Column 'view_count' cannot be null

来源:11-5 电子书快照收集脚本编写-2

weixin_慕娘4446816

2021-11-29

Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘view_count’ cannot be null

The error may exist in file [D:\zhishi\target\classes\mapper\EbookSnapshotMapperCust.xml]

The error may involve defaultParameterMap

The error occurred while setting parameters

Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘view_count’ cannot be null

在Docservice中 doc.setViewCount(0);
doc.setVoteCount(0);依旧报错 。 求解决

写回答

2回答

rarukuchaser

2023-11-17

不用那么麻烦的,sql改写成:

update doc set view_count = ifnull(view_count, 0) + 1 where id = #{id}

就好

0
0

甲蛙

2021-11-29

ebook表也有view_count字段,创建ebook时也setViewCount(0)试试

0
0

Spring Boot+Vue3前后端分离,实战wiki知识库系统

一课掌握前后端最火框架,更有职场竞争力

2524 学习 · 1671 问题

查看课程