the timeline looks like this:
User(browser) ---------------------------> update TARGET 2----------------->
Thread ------> update TARGET 1 ---------> long_operation -----> update TARGET 3
I kick off a thread to execute an long_operation, and update the TARGET object before and after the operation.
The problem is, during the long_operation, the user could update the TARGET in UI. Therefore, when I try to update TARGET after long_operation, I get a optimistic lock exception.
I use version number to do optimistic locking, and update 2 is in a transaction.
I tried doing update 1 and 3 in different transaction -> doesn't work. I also tried update the version number before doing update_3 -> doesn't work.
Not sure what is the right thing to do here....