Does JPQL update query increment @Version field to support optimistic locking? I suppose no, but then, it means JPQL update would always pass, i.e. it would update entity no matter whether there is an active transaction trying to update the given entity. In this situation, the active transaction would pass since the @Version field wasn't changed, leading to the lost update. Am I right?
How would you avoid lost updates in this situation? Should I use pessimistic locking?