1
0
mirror of synced 2025-01-18 22:41:43 +03:00

[2.0] Fix for optimistic locking.

This commit is contained in:
romanb 2009-11-25 21:48:04 +00:00
parent ba4d1bb393
commit fdd9b05158
4 changed files with 7 additions and 8 deletions

View File

@ -588,7 +588,6 @@ class EntityManager
*
* @param mixed $conn An array with the connection parameters or an existing
* Connection instance.
* @param string $name The name of the EntityManager.
* @param Configuration $config The Configuration instance to use.
* @param EventManager $eventManager The EventManager instance to use.
* @return EntityManager The created EntityManager.

View File

@ -49,16 +49,16 @@ class Assigned extends AbstractIdGenerator
foreach ($idFields as $idField) {
$value = $class->getReflectionProperty($idField)->getValue($entity);
if (isset($value)) {
$identifier[] = $value;
$identifier[$idField] = $value;
} else {
throw ORMException::entityMissingAssignedId($entity);
}
}
} else {
$value = $class->getReflectionProperty($class->getSingleIdentifierFieldName())
->getValue($entity);
$idField = $class->identifier[0];
$value = $class->reflFields[$idField]->getValue($entity);
if (isset($value)) {
$identifier[] = $value;
$identifier[$idField] = $value;
} else {
throw ORMException::entityMissingAssignedId($entity);
}

View File

@ -183,7 +183,7 @@ class StandardEntityPersister
//FIXME: Order with composite keys might not be correct
$sql = "SELECT " . $versionFieldColumnName . " FROM " . $class->getQuotedTableName($this->_platform) .
" WHERE " . implode(' = ? AND ', $identifier) . " = ?";
$value = $this->_conn->fetchColumn($sql, array_values($id));
$value = $this->_conn->fetchColumn($sql, array_values((array)$id));
$this->_class->setFieldValue($entity, $versionField, $value);
}

View File

@ -42,13 +42,13 @@ class AssignedIdTest extends \Doctrine\Tests\OrmTestCase
$entity = new AssignedSingleIdEntity;
$entity->myId = 1;
$id = $this->_assignedGen->generate($this->_em, $entity);
$this->assertEquals(array(1), $id);
$this->assertEquals(array('myId' => 1), $id);
$entity = new AssignedCompositeIdEntity;
$entity->myId2 = 2;
$entity->myId1 = 4;
$id = $this->_assignedGen->generate($this->_em, $entity);
$this->assertEquals(array(4, 2), $id);
$this->assertEquals(array('myId1' => 4, 'myId2' => 2), $id);
}
}