Say that we are using Hibernate as a JPA implementation and as you all know it has a cache mechanism called first-level-cache.
Is OptimisticLockException is thrown from this cache layer or does it really hits the DB and sees that the version of that row has changed also in DB and then the exception is thrown?