I am developing a CRUD type web application. It is a project management system having projects, milestones, tasks, employees etc. Each employee has his/her own account to login and view the system. The problems come here:
If one user deletes a task while the second has it opened at the same time, the second user will get a null pointer exception if he tries edit and save, because the object doesn't exist.
The same problem in a bit different situation. One user has a task window opened. The second user deletes one employee. The first user tries to assign a task to deleted employee (because it is already in the list in a combobox) and gets null pointer exception.
If someone deletes the object and the other user tries to open it at the same time (will be a null pointer exception when trying to get an item)
I am trying to leave technical details of the project because it is up to that. But if it helps, I'm using Vaadin framework based on Java. The database is MySQL.
I thought two possible solutions but not sure about them:
Catch null pointer exception and print a general warning to the screen ("Some objects are missing...). But it wouldn't be clear for the users that exactly has happened.
Check every commit of the object and if it was deleted catch the exception and give more detailed explanation. But it won't help in the 3rd situation.
I am really looking for any guiding points, advice, or tips you can provide on how to properly deal with these situations. Thank you in advance!