Validation message for unique constraints on MS SQL Server

Hello,

in one application we use a MS SQL Server database. If we create a user here where the name already exists we get an exception dialog instead of a notification:

2020-02-19%2013_46_31-aKSM%20Anwendung

I have already set the following setting in app.properties, but this did not work:

cuba.uniqueConstraintViolationPattern =  Eine Zeile mit doppeltem Schlüssel .* mit eindeutigen (.+)-Index nicht eingefügt werden

Here again an extract from the log:

2020-02-19 13:36:18.825 ERROR [http-nio-8083-exec-13/aksm-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Exception:
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Eine Zeile mit doppeltem Schlüssel kann in das dbo.SEC_USER-Objekt mit dem eindeutigen IDX_SEC_USER_UNIQ_LOGIN-Index nicht eingefügt werden. Der doppelte Schlüsselwert ist (baiter, <NULL>).
Error Code: 2601
Call: INSERT INTO SEC_USER (ID, ACTIVE, CHANGE_PASSWORD_AT_LOGON, CREATE_TS, CREATED_BY, DELETE_TS, DELETED_BY, EMAIL, FIRST_NAME, IP_MASK, LANGUAGE_, LAST_NAME, LDAP_USER, LOGIN, LOGIN_LC, MIDDLE_NAME, MIGRATION_USER, NAME, PASSWORD, PASSWORD_ENCRYPTION, POSITION_, TIME_ZONE, TIME_ZONE_AUTO, TS_LDAP_SYNC, UPDATE_TS, UPDATED_BY, VERSION, WORKFORCE_ID, GROUP_ID, PERSON_ID, DTYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
        bind => [8D0DF5A6-81AA-ED68-B4B2-C94D7D5D3D7D, true, true, 2020-02-19 13:36:18.434, admin, null, null, null, Baiter, null, de, Baiter, false, Baiter, baiter, null, false, null, $2a$10$P9pbfExnOxpwR.VH5stwjuS.5C3Jo2LMd.dep0vZAKQiCIdo7/40W, bcrypt, null, null, null, null, 2020-02-19 13:36:18.434, null, 1, null, BCCD3FB7-D953-11E9-A098-00FF30EA02FE, null, ksm$ExtUser]
Query: WriteObjectQuery(de.agentes.ksm.entity.persons.ExtUser-8d0df5a6-81aa-ed68-b4b2-c94d7d5d3d7d [new,managed])

Thanks for your help. :slightly_smiling_face:

Greetings
Andreas

Hi,
You can put breakpoints to handle() and doHandle() methods of this class:
com.haulmont.cuba.gui.exception.UniqueConstraintViolationHandler

and debug why it doesn’t work as expected.
Maybe umlaut in the message prevents regular expression from matching, but it’s just my guess.