BZ-1175417 - Engine configured with pessimistic locking throws javax.persistence.OptimisticLockException

(cherry picked from commit e1768e62baeb3bfa8a356afb9cbce467718b013d)