dirigible
dirigible copied to clipboard
[EDM] Entity sequence initial value is not correct
When you have an entity which has predefined entries provided by CSVIM you cannot add new entries until the sequence generator reach value which is not already used.
For example:
and values:
If you try to create new entry you get:
2024-02-20 14:51:49.703 [ERROR] [http-nio-8080-exec-9] o.e.d.c.api.db.DatabaseFacade - Failed to execute insert statement [INSERT INTO "CODBEX_ORDERSTATUS" ("ORDERSTATUS_ID", "ORDERSTATUS_LANGUAGE", "ORDERSTATUS_NAME", "ORDERSTATUS_DEFAULT") VALUES (?, ?, ?, ?)] in data source [DefaultDB].
org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.CODBEX_ORDERSTATUS(ORDERSTATUS_ID) ( /* key:15 */ 15, 1, 'Processed', FALSE)"; SQL statement:
INSERT INTO "CODBEX_ORDERSTATUS" ("ORDERSTATUS_ID", "ORDERSTATUS_LANGUAGE", "ORDERSTATUS_NAME", "ORDERSTATUS_DEFAULT") VALUES (?, ?, ?, ?) [23505-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:520) ~[h2-2.2.224.jar!/:na]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) ~[h2-2.2.224.jar!/:na]
at org.h2.message.DbException.get(DbException.java:223) ~[h2-2.2.224.jar!/:na]
at org.h2.message.DbException.get(DbException.java:199) ~[h2-2.2.224.jar!/:na]
at org.h2.mvstore.db.MVPrimaryIndex.add(MVPrimaryIndex.java:120) ~[h2-2.2.224.jar!/:na]
at org.h2.mvstore.db.MVTable.addRow(MVTable.java:519) ~[h2-2.2.224.jar!/:na]
at org.h2.command.dml.Insert.insertRows(Insert.java:174) ~[h2-2.2.224.jar!/:na]
at org.h2.command.dml.Insert.update(Insert.java:135) ~[h2-2.2.224.jar!/:na]
at org.h2.command.CommandContainer.executeUpdateWithGeneratedKeys(CommandContainer.java:242) ~[h2-2.2.224.jar!/:na]
at org.h2.command.CommandContainer.update(CommandContainer.java:163) ~[h2-2.2.224.jar!/:na]
at org.h2.command.Command.executeUpdate(Command.java:256) ~[h2-2.2.224.jar!/:na]
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:216) ~[h2-2.2.224.jar!/:na]
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:174) ~[h2-2.2.224.jar!/:na]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[HikariCP-5.0.1.jar!/:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[HikariCP-5.0.1.jar!/:na]
at org.eclipse.dirigible.components.api.db.DatabaseFacade.insert(DatabaseFacade.java:312) ~[dirigible-components-api-database-11.0.0-SNAPSHOT.jar!/:na]
@iliyan-velichkov hmmm, that's strange. I think this was already fixed here:
- https://github.com/eclipse/dirigible/blob/master/components/api/api-database/src/main/java/org/eclipse/dirigible/components/api/db/DatabaseFacade.java#L450-L479
I guess it needs to be debugged ...