peter.ordog
(Peter Ördög)
September 28, 2023, 12:21pm
1
Hello,
With SQL Server set as data store we get an unhandled SQLServerException in the Onboarding tutorial project when saving a new Department instance with a duplicate name.
If an entity is created with the soft delete trait then the unique index constraint works and the exception is handled with an error notification that can be localized.
Best regards,
Peter
krivopustov
(Konstantin Krivopustov)
October 5, 2023, 7:06am
4
Hi Peter,
Thank you for spotting the problem. We’ll try to fix it in the next update:
opened 06:56AM - 05 Oct 23 UTC
closed 09:43AM - 27 Dec 23 UTC
type: bug
in: data
- Start SQLServer, for example in docker: `docker run --cap-add SYS_PTRACE -e 'A… CCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=saPass_1' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge`
- Open https://github.com/jmix-framework/jmix-onboarding-2 project
- Change database type to MS SQLServer 2012+, set `sa` / `saPass_1` credentials
- Run the app, create new Department with `Finance` name
ER:
Notification "A department with the same name already exists"
AR:
Unexpected error
SQLServerException: Violation of UNIQUE KEY constraint 'IDX_DEPARTMENT_UNQ_NAME'. Cannot insert duplicate key in object 'dbo.DEPARTMENT'. The duplicate key value is (Finance).
See also [forum topic](https://forum.jmix.io/t/unhandled-sqlserverexception-with-unique-attribute/3724).
Meanwhile, you can set this property in your project to make the framework recognize the unique constraint violation exception from SQLServer:
jmix.data.unique-constraint-violation-pattern = Violation of UNIQUE KEY constraint '(.+?)'
Regards,
Konstantin