Let's say I would like to merge a detached entity. when I do
T mergedEntity = entityManager.merge(detachedEntity);
the entityManager will load an entity (with same identifier with the detachedEntity) from database and copy all the data from the detachedEntity to the new loaded entity. When later my transaction ends, this entity will be saved to the database.
However, in a concurrent scenario, the entity in the database can be updated by other transactions between the entity is firstly loaded in my transaction and then flushed at the end of my transaction. In this case, I would like to know whether an OptimisticLockException will be thrown? If so, why the merge API doesn't specify the OptimisticLockException in Java doc? http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#merge(T)
thanks