DataIntegrityViolationException
- Cause: java.sql.SQLException: Field ‘id’ doesn’t have a default value
org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a default value
### The error may exist in com/xxx/learning/mapper/LearningRecordMapper.java (best guess)
### The error may involve com.xxxi.learning.mapper.LearningRecordMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO learning_record ( lesson_id, section_id, user_id, moment ) VALUES ( ?, ?, ?, ? )
### Cause: java.sql.SQLException: Field 'id' doesn't have a default value
; Field 'id' doesn't have a default value; nested exception is java.sql.SQLException: Field 'id' doesn't have a default value
原因是Model类中设置为自增,数据库中并没有设置
改成了IdType.ASSIGN_ID,使用雪花算法自动生成,成功解决。