I'm having a problem in my project that is java web with JSF and Mysql which is the following:
- I have a table in mysql called consecutive that is consulted by users to consult a record that is corresponding to your company and this same record is updated once consumed the consecutive adding a one.
Ex: the user of the company 1 consulted the record of the consecutive table that was in 6 and immediately I am in 7 so that another user of the same company comes and consults that consecutive one.
- The problem is when two users of the same company consult consecutive tables almost or at the same time, at the time they consult it, it returns the same number to the two users, but it is updated by adding two.
Ex: User 1 and user 2 (who are from the same company) consult the table at the same time and the registration of your company is at 6, but when the query both at the same time it returns that 6 a the two users instead of returning 6 to one and 7 to the other and remaining in 8 the record.
Any solution to this problem? I've been watching queues, but I do not know how to implement them.