public function useWithPessimisticVersionLock($id, $lockVersion, $callback)
{
return $this->useWithPessimisticWriteLock($id, function (VersionLockable $entity, EntityManager $em, $self) use($lockVersion, $callback) {
if ($entity->getVersion() !== $lockVersion) {
// FIXME: This isn't the appropriate exception type.
throw OptimisticLockException::lockFailedVersionMissmatch($entity, $lockVersion, $entity->getVersion());
}
$entity->incrementVersion();
return $callback($entity, $em, $self);
});
}