I am relatively new to Hibernate. I have a API which is inherently support concurrency.
- Check user exists - If no, do something - Save/update user
As post API call I persist the user to the DB with a 'Save or Update' call.
The problem is - 'If two threads try to work on the same user simultaneously, both thread will find out the user does not exist. Do the logic and try to save the user to the DB. At the end 1st thread will do some update and the 2nd thread will overwrite the updates of the first'.
Can I solve this by using 'vesion' or 'timestamp' ?