解决报错问题:SQLIntegrityConstraintViolationExcepti 。。。
解决报错问题:SQLIntegrityConstraintViolationException: Duplicate entry ‘4’ for key ‘PRIMARY’
SqlSession [org.apache.ibatis.ssion.defaults.DefaultSqlSession@4813a18a] was not registered for synchronization becau synchronization is not active
JDBC Connection [sql.cj.jdbc.ConnectionImpl@703e71fd] will not be managed by Spring
==> Preparing: INSERT INTO wx_main_detail ( home_id, sort_order, create_time ) values ( ?, ?, ? )
==> Parameters: 3(Integer), 1(Integer), 2019-11-27 10:51:58.805(Timestamp)五香素鸡
Closing non transactional SqlSession [org.apache.ibatis.ssion.defaults.DefaultSqlSession@4813a18a]
2019-11-27 10:51:58.865 ERROR 119624 — [ XNIO-1 task-29] c.GlobalExceptionHandler : 异常信息uri=/sys/WxMainHome/saveEditIn,method=POST,e={}
org.springframework.dao.DuplicateKeyException:梦见吃鸡
听课意见和建议
Error updating databa. Cau: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘4’ for key ‘PRIMARY’
抗肿瘤中药前三名The error may involve com.ultrapower.life.mapper.WxMainDetailMapper.inrtId-Inline
The error occurred while tting parameters
SQL: INSERT INTO wx_main_detail ( home_id, sort_order, create_time ) values ( ?, ?, ? )
Cau: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘4’ for key ‘PRIMARY’; Duplicate entry ‘4’ for key ‘PRIMARY’; nested exception is java.sql.SQLIntegrityConstraintViolationException:Duplicate entry ‘4’ for key ‘PRIMARY’秋天景色的词语
at
大班绘画图片
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslat or.java:242)
at
辅助怎么玩
org.springframework.jdbc.anslate(AbstractFallbackSQLExceptionTransla tor.java:72)
batis.anslateExceptionIfPossible(MyBatisExceptionTranslator.java:73)batis.spring.SqlSessionTemplate Proxy101.inrt(Unknown Source)
batis.spring.SqlSessionTemplate.inrt(SqlSessionTemplate.java:278)
看报错信息,“Duplicate entry ‘4’ for key ‘PRIMARY’”表⽰,主键有重复的,因此,错误的原因就是值重复了,解决此类问题就是将插⼊的值不能是数据库已经有了的主键,在我这个项⽬中主要是把表的id 设置为不是⾃动递增(去掉勾选)
SqlSessionInterceptor .invoke (SqlSessionTemplate .java :
446)atcom .sun .proxy .
在我的插⼊语句的mapper⽂件⾥插⼊需要的id即可:
后⾯我的项⽬就跑起来了朋友定义