I'm currently developping an appointment system using Java (spring boot) and I'm facing an issue,
When two (2) users ask for the same timing almost simultaneously my verification does not work
Explanation:
New request recieved
// Fetch all the previous request from the database and checks if there is any kind of conflicts
Verification();
// If no conflict found
saveAppointment();
Example:
User1 ask for appointment at 11:03:50 Date: 12/12/2020 Starting: 10:00 Ending: 12:00
User1 ask for appointment at 11:03:51 Date: 12/12/2020 Starting: 10:00 Ending: 12:00
Problem: The system saves both without finding any issue because both happen at the same time and the system is not able to fetch any previous appointment.
Is there a way to make the system wait when there is a request going on and only take another one when the first is done ?