解决报错问题:SQLIntegrityConstraintViolationException: Duplicate entry ‘4’ for key ‘PRIMARY’
SqlSession [[email protected]] was not registered for synchronization because synchronization is not active
JDBC Connection [[email protected]] 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 [[email protected]]
2019-11-27 10:51:58.865 ERROR 119624 — [ XNIO-1 task-29] c.u.l.c.e.GlobalExceptionHandler : 异常信息uri=/sys/WxMainHome/saveEditIn,method=POST,e={}
org.springframework.dao.DuplicateKeyException:
Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘4’ for key ‘PRIMARY’
The error may involve com.ultrapower.life.mapper.WxMainDetailMapper.insertId-Inline
The error occurred while setting parameters
SQL: INSERT INTO wx_main_detail ( home_id, sort_order, create_time ) values ( ?, ?, ? )
Cause: 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(SQLErrorCodeSQLExceptionTranslator.java:242)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplateProxy101.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)