慕姐5116453
2021-01-05 10:36
@Test public void insert(){ User user = new User(); user.setName("tom"); user.setManagerId(1088248166370832385L); user.setCreateTime(new Date()); int insert = userMapper.insert(user); System.out.println("insert = " + insert); }
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/exam/demo/mapper/UserMapper.java (best guess)
### The error may involve com.exam.demo.mapper.UserMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO user ( name, manager_id, create_time ) 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
同学,你主键策略设置的是什么?包括mp和数据库的,我怀疑你mp设置的为自增,但数据库没设置。
MyBatis-Plus入门
56140 学习 · 381 问题
相似问题