Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
SQLContainer and TableQuery concurrent commits (update) without VersionColu
I am developing a CRUD application and have the following problem when two users edit the same record concurrently and update their changes (either in a Form or directly in an editable Table). I am using mySQL (dev/test) and MS SQL (productive) and therefore use the SQLContainer add-on with either DefaultSQLGenerator or MSSQLgenerator, in combination with the TableQuery. The database table I am using does not have a version column, so I cannot use the mechanism vaadin offers as explained for the TableQuery.setVersionColumn to address conflicts for a record. I do assign some database column though for the version (some auto-generated value from MS SQL when new record is added to the table), but it´s more a dummy column since it does not track the version of a record.
I use the FilteringTable add-on, and the user can either edit a single record in a Form (FormLayout and FieldGroup) or edit the whole Table (editable mode).
The database has about about 20 fields (columns).
When two users open the same record for editing at the same time, let´s say
UserA changes Field1
UserB changes Field2
First UserA commits, then UserB commits. At the end, the changes of UserA are gone.
Though UserB did not change the value for Field1, this field is commited and updated (as it was binded to the form on read) to the database.
I don´t quite understand why this happens, since only Field2 was changed by UserB.
Having a closer look at the vaadin implementation and the generated SQL, I find that the update statements include the whole record (all fields) even though I modified only one single field.
I am trying to find a way go around that problem my remembering in the form which fields were modified, and then modifiy the SQL statements so that only fields and values where changes were made get into the SQL update statement.
This is kind of ugly, I am wondering if there is no other nicer way in terms of using the framework in such a sitation..
Unfortunately an VersionColumn is not an option at this moment.
What am I doing wrong here?
Any suggestions and help is highly appreciated,