Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimistic locking & concurrency

Tags:

java

mysql

My application working in a multi-users environment for medical records. One of the important parts of the application is writing the medical records, doctors should always review the current written data then adding or correcting any information's as needed.

I were aware about the situation when 2 doctors (A,B) viewing the data at same time, one of them will make changes and hit save (A).

the other doctor (B) still editing the old data & he don't know about the changes applied by doctor (A).

When doctor (B) hit save, the application will compare the Version column in the database, application then return an error message ("Data has been changed by another user !!!").

My Question in this case: What choices should be available within my solution.

I'm seeking an professional solution or idea from your experiences.

My application using: Java Swing for end user client & MySQL database.

like image 674
user3822563 Avatar asked Mar 03 '26 23:03

user3822563


1 Answers

Doctor B should absolutely be notified in some way that the record has been modified since he opened it. The rest is up to you/the requirements of the program. Does it matter if Doctor A's changes are overwritten? Would it be better to have Doctor B view the changes made by Doctor A, and then decide if the changes (made by Doctor B) should still be saved? Should the changes be merged? It all depends on what you decide to design, as well as any requirements that may be imposed on the system you are creating. Without more detail on the system you are designing or its requirements, it would be impossible to provide a specific answer.

like image 100
holtc Avatar answered Mar 05 '26 13:03

holtc