Hi,
The constraint name is not found in the doHandle method. The group count of the matcher is 2. So the code block skips the logic where the constraint name is set. Perhaps MySQL is throwing content that the matcher is not expecting?
Here is matcher.toString():
java.util.regex.Matcher[pattern=Duplicate entry '(.+)' for key '(.+)' region=0,2862 lastmatch=Duplicate entry 'Moes' for key 'IDX_DEMO_COMPANY_UNIQ_COMPANY_NAME']
Here is the throwable.toString()
com.haulmont.cuba.core.global.RemoteException:
---
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.cuba20): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'Moes' for key 'IDX_DEMO_COMPANY_UNIQ_COMPANY_NAME'
Error Code: 1062
Call: INSERT INTO DEMO_COMPANY (ID, IS_COMPETITOR, CREATE_TS, CREATED_BY, DESCRIPTION, EXTERNAL_ID, COMPANY_NAME, UPDATE_TS, UPDATED_BY, VERSION, EXTERNAL_SYSTEM_ID, PARENT_COMPANY_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [ad3d3e11d4ce837fc4b4f7150ab12b23, false, 2018-03-02 16:49:04.539, admin, null, null, Moes, 2018-03-02 16:49:04.539, null, 1, dbc8860b6c2a4f7aa4a440e10a855b3a, null]
Query: InsertObjectQuery(com.rhinoj.demo.entity.Company-ad3d3e11-d4ce-837f-c4b4-f7150ab12b23 [new,managed])
---
javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.cuba20): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'Moes' for key 'IDX_DEMO_COMPANY_UNIQ_COMPANY_NAME'
Error Code: 1062
Call: INSERT INTO DEMO_COMPANY (ID, IS_COMPETITOR, CREATE_TS, CREATED_BY, DESCRIPTION, EXTERNAL_ID, COMPANY_NAME, UPDATE_TS, UPDATED_BY, VERSION, EXTERNAL_SYSTEM_ID, PARENT_COMPANY_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [ad3d3e11d4ce837fc4b4f7150ab12b23, false, 2018-03-02 16:49:04.539, admin, null, null, Moes, 2018-03-02 16:49:04.539, null, 1, dbc8860b6c2a4f7aa4a440e10a855b3a, null]
Query: InsertObjectQuery(com.rhinoj.demo.entity.Company-ad3d3e11-d4ce-837f-c4b4-f7150ab12b23 [new,managed])
---
org.eclipse.persistence.exceptions.DatabaseException:
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'Moes' for key 'IDX_DEMO_COMPANY_UNIQ_COMPANY_NAME'
Error Code: 1062
Call: INSERT INTO DEMO_COMPANY (ID, IS_COMPETITOR, CREATE_TS, CREATED_BY, DESCRIPTION, EXTERNAL_ID, COMPANY_NAME, UPDATE_TS, UPDATED_BY, VERSION, EXTERNAL_SYSTEM_ID, PARENT_COMPANY_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [ad3d3e11d4ce837fc4b4f7150ab12b23, false, 2018-03-02 16:49:04.539, admin, null, null, Moes, 2018-03-02 16:49:04.539, null, 1, dbc8860b6c2a4f7aa4a440e10a855b3a, null]
Query: InsertObjectQuery(com.rhinoj.demo.entity.Company-ad3d3e11-d4ce-837f-c4b4-f7150ab12b23 [detached])
---
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'Moes' for key 'IDX_DEMO_COMPANY_UNIQ_COMPANY_NAME'