1
0
mirror of synced 2025-01-29 19:41:45 +03:00

[DDC-1846] Fix EntityRepository#find() with pessimistic locking.

This commit is contained in:
Benjamin Eberlei 2012-07-07 16:48:59 +02:00
parent 58a2cba6da
commit ff2c5f85c3
2 changed files with 11 additions and 4 deletions

View File

@ -142,8 +142,15 @@ class EntityRepository implements ObjectRepository
return null;
}
if ($lockMode !== LockMode::NONE) {
$this->_em->lock($entity, $lockMode, $lockVersion);
switch ($lockMode) {
case LockMode::OPTIMISTIC:
$this->_em->lock($entity, $lockMode, $lockVersion);
break;
case LockMode::PESSIMISTIC_READ:
case LockMode::PESSIMISTIC_WRITE:
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
$persister->refresh($sortedId, $entity, $lockMode);
break;
}
return $entity; // Hit!

View File

@ -738,9 +738,9 @@ class BasicEntityPersister
* column or field names to values.
* @param object $entity The entity to refresh.
*/
public function refresh(array $id, $entity)
public function refresh(array $id, $entity, $lockMode = 0)
{
$sql = $this->_getSelectEntitiesSQL($id);
$sql = $this->_getSelectEntitiesSQL($id, null, $lockMode);
list($params, $types) = $this->expandParameters($id);
$stmt = $this->_conn->executeQuery($sql, $params, $types);