The OptimisticLockException indicates that the second client has a stale version of the entity, i.e. it won't be updating the latest version.
As far as I know, using the EntityManager.lock method will force the version to be incremented, whether or not you actually changed the entity.
So, i guess, when using only version without lock there won't be increment of version attribute? Is it possible? I thought that version is always incremented after update.
@Version will enable JPA Optmistic locking for the entity. EM.lock allows the application to specify the lock mode to be used on the versioned object.
This is no JPA "waiting" or caching of updates to an entity until another Tx is finished with it; that responsibility is on the part of the application. JPA locking provides you with a mechinism to ensure your data integrity is kept.