Hello,
I am using TableQuery and a form.
The content of the DB table is properly displayed in the UI table and when I select a row, the content of the item is properly displayed in a form.
When I commit the form, the SQLContainer is updated correctly, I am able to retrieve the new values from the container item. But when I commit the container, I get a com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException as if it was trying to insert a new record instead of updating one. But in the stack trace, the TableQuery.executeUpdate is performed.
I have only one primary key of type integer, and I do not modify it in the form.
I use MySQL and here is how I created the Table Query :
SQLContainer container = null;
try
{
TableQuery tq = new TableQuery(nomTable, connectionPool);
tq.setVersionColumn("VERSION");
System.out.println("colonne de version = " + tq.getVersionColumn());
List<String> cles = tq.getPrimaryKeyColumns();
Iterator <String> it = cles.iterator();
while (it.hasNext()) {
System.out.println("clé primaire = " + it.next());
}
container = new SQLContainer(tq);
System.out.println("container créé pour la table " + nomTable);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I also displayed the names of the primary keys, and the result is correct.
I tried to replace “VERSION” by my primary key field “person_id” but with the same result.
If I use tcpdump to capture the SQL request, the WHERE clause of the UPDATE is missing.
I copy/paste de generated SQL request into the phpmyadmin SQL editor and run it : I get the same error. But if I mannually append the where clause, the request performs successfully.
Has anyone already faced this behavior ?
Thanks