Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
MySQL Update Syntax
Hi everyone, I am having an issue implementing the update function of the Addressbook example using a MySQL database and I am hoping somebody might point me to
what I am hoping is an obvious error on my part :D (Forgive me if this is a silly question, I am very new to vaadin).
I have successfully managed to integrate MySQL into the example, the SQLcontainers are reading into the table without an issue. My problem comes when I try to do an update. It looks to me like the SQL that is generated by the SQLGenerator is putting double quotes are around each of the column names. Unfortunately MySQL doesnt seem to like that notation on an update for some reason so it throws a wobbly. The select seems fine with double quotes though (I am not sure if this si a something I can fix in MySQL actually but hopefully somebody will know).
as an example, this will work
UPDATE `personaddress` SET `firstname`= 'Bob' Where `id` = 1
however, this is what appears to be generated and it wont work.
UPDATE "personaddress" SET "firstname"= 'Bob' Where "id" = 1
I would be very gratefull for any advice. Hopefully the solution is simple enough.
If you have admin writes on the MySQL Instance, you then you can configure MySQL to use ANSI Quotes which should work.
If not - I've not used SQLContainer myself, however, I've just looked at the source, and it looks like you can customize the SQLGenerator to use the backtick via QueryBuilder#setStringDecorator
QueryBuilder.setStringDecorator(new StringDecorator("`", "`"));
I'd prefer the first approparch, myself.
Thanks! I gave option 1 a try and it worked a treat!.