We are using the version-based strategy but I think it should behave the same.
Quote:
Does User 1 can able to update the record based on where condition 'B1' after User 2 updated the data ?
No, User 1 will get a StaleStateException that indicates that another transaction has already modified the record.
Quote:
If answer is 'No' what is the difference between Pessimistic and Optimistic Locking?
When using pessimistic locking strategy the first user that is going to modify a record locks it when it is fetched from the database. In your case this would happen in step 1 and User 2 will not be able to get the same record in the second step. This will either result in User 2 having to wait for User 1 to release the lock or an exception is thrown.
Optimistic locking doesn't lock the record until the actual update is happening. This strategy is usually easier to use and performs better since locks are held for a shorter time.
Quote:
What is the possible solution?
What is the problem?