Hey guys.
I’m currently busy with a project that connects to a database table with a primary key that is non-autoincrementing. Don’t ask why, but it must stay this way. When I commit the changes I’ve made to the sql container I get the following message:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '10' for key 'PRIMARY'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at com.vaadin.data.util.sqlcontainer.query.TableQuery.executeUpdate(TableQuery.java:428)
at com.vaadin.data.util.sqlcontainer.query.TableQuery.storeRow(TableQuery.java:201)
at com.vaadin.data.util.sqlcontainer.SQLContainer.commit(SQLContainer.java:900)
No changes are made to the primary key itself, I’ve tested the same changes on a table with an auto-incrementing primary key and it works. Is there a way to commit a sqlcontainer’s changes to a database table with a non-autoincrementing primary key? Sorry but I’m not allowed to show my code.
Sincerely
Johan