Finaly i reproduce it, but with workaround with random button with code
RowLevelRoleEntity rowLevelRoleEntity = dataManager.create(RowLevelRoleEntity.class);
rowLevelRoleEntity.setId(UUID.fromString("f9df270b-6321-4092-a872-0587557a7d71"));
rowLevelRoleEntity.setCode("asd");
rowLevelRoleEntity.setName("asd");
dataManager.save(rowLevelRoleEntity);
Using jmix 1.5/1.5.5/1.6.2 and Postgres. Idk how do you reproduce it with cleaning id from Json, but for my case - no matter what empty id or duplicate - Json export and import just duplicates or ignoring(updating) existing row level role or create new with random uuid.
Anyway, the error “org.eclipse.persistence.exceptions.DatabaseException” seems like generic error and intercepted in jmix core before ours. I tested
@Order(JmixOrder.HIGHEST_PRECEDENCE)
@Component("uiex1_ZeroBalanceExceptionHandler")
public class EHP extends AbstractUiExceptionHandler {
public EHP() {
super("org.eclipse.persistence.exceptions.DatabaseException");
}
@Override
protected void doHandle(String className, String message,
@Nullable Throwable throwable, UiContext context) {
context.getNotifications().create(Notifications.NotificationType.ERROR)
.withCaption("Error asdsadsa")
.withDescription(message)
.show();
}
}
But somehow this doesnt work, i guess i need more research time.
About message handle. This is pretty funny case. E.g. you can try intercept unique user id with message
databaseUniqueConstraintViolation.USER__Pkey=asda but this also wont work, but after attempt to rename it to something like this “IDX_USER__ON_ID” → All work.
So to make you exception localized for unique values you need to write second part of key from SCREAMING_SNAKE_CASE.
solution
So, instead of SEC_ROW_LEVEL_ROLE_pkey use SEC_ROW_LEVEL_ROLE_PKEY
PS
If you need help with custom excpetion handling via custom class - mention me in this thread