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 * @param mixed $conn An array with the connection parameters or an existing
* Connection instance. * Connection instance.
* @param string $name The name of the EntityManager.
* @param Configuration $config The Configuration instance to use. * @param Configuration $config The Configuration instance to use.
* @param EventManager $eventManager The EventManager instance to use. * @param EventManager $eventManager The EventManager instance to use.
* @return EntityManager The created EntityManager. * @return EntityManager The created EntityManager.

View File

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

View File

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

View File

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