[DDC-1846] Fix EntityRepository#find() with pessimistic locking.
This commit is contained in:
parent
58a2cba6da
commit
ff2c5f85c3
@ -142,8 +142,15 @@ class EntityRepository implements ObjectRepository
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lockMode !== LockMode::NONE) {
|
switch ($lockMode) {
|
||||||
$this->_em->lock($entity, $lockMode, $lockVersion);
|
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!
|
return $entity; // Hit!
|
||||||
|
@ -738,9 +738,9 @@ class BasicEntityPersister
|
|||||||
* column or field names to values.
|
* column or field names to values.
|
||||||
* @param object $entity The entity to refresh.
|
* @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);
|
list($params, $types) = $this->expandParameters($id);
|
||||||
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user