问题描述:
Caused by: java.sql.BatchUpdateException: ORA-00001: 违反唯一约束条件 (WFWYXYS_a0123456)
Caused by: org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
解决思路:
--1.查询违反约束的序列及所在的表
SELECT A.CONSTRAINT_NAME, A.CONSTRAINT_TYPE, B.COLUMN_NAME, B.TABLE_NAME
FROM USER_CONSTRAINTS A
INNER JOIN USER_CONS_COLUMNS B
ON A.TABLE_NAME = B.TABLE_NAME
WHERE A.CONSTRAINT_NAME = 'WFWYXYS_a0123456';
--2.执行1可以查询到该约束所在的表TABLEA,然后找到该表的自增序列seq_tablea,分析next number的值是不是在表中已经存在(id),肯定已经存在了。。。
--3.重新维护该next number的值即可