How do you deal with that: two users modifying the same data?


this is more general question, not the specific one for Vaadin. It is interesting to know how do you deal with this situation:

Two users (A and B ) are using the same application on different computers at the same time. Both of them are editing the same object (double clicked the item in the table and got the new window with that object details). User A deletes it and commits container while user B has it opened yet. Then user B edits some data and press button “Save”. I tried that and got the error message because that situation isn’t caught in my source code.

For every user I initialize user session and DB connection.

try {
	FacadeFactory.registerFacade("mysql", true);
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {

I am using SQL Container. How do you deal with that?

Thank you for any information.

This is not Vaadin specific, but you can google for the two strategies:

Optimistic Locking vs. Pessimistic Locking

Hope that helps you.

Thank you.
I have read about those strategies. Are there specific tools (functions or so on) for implementing optimistic locking in Vaadin (for SQL Container)?

You must set a version column to TableQuery, have a look at the book of vaadin 6,
chapter 10.2.2. Creating the TableQuery Query Delegate

Yes, I did that. Created a new column in the table in DB and set it as a versionColumn. That practice should be for the further steps? I see, that after my changes the value of that column is changed also…