Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
TableQuery performs UPDATE without WHERE clause
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
I changed setVersionColumn("person_id") AND added the backquotes as parameters to the constructor of the connection pool and it works.