Commit 78328ec6 authored by Benjamin Eberlei's avatar Benjamin Eberlei

DDC-178 - Removed Doctrine\ORM\LockMode in favour of Doctrine\DBAL\LockMode

parent e9583964
......@@ -22,6 +22,7 @@ namespace Doctrine\ORM;
use Closure, Exception,
Doctrine\Common\EventManager,
Doctrine\DBAL\Connection,
Doctrine\DBAL\LockMode,
Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\ClassMetadataFactory,
Doctrine\ORM\Proxy\ProxyFactory;
......
......@@ -19,6 +19,8 @@
namespace Doctrine\ORM;
use Doctrine\DBAL\LockMode;
/**
* An EntityRepository serves as a repository for entities with generic as well as
* business specific methods for retrieving entities.
......
......@@ -790,9 +790,9 @@ class BasicEntityPersister
: '';
$lockSql = '';
if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_READ) {
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
$lockSql = ' ' . $this->_platform->getReadLockSql();
} else if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE) {
} else if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$lockSql = ' ' . $this->_platform->getWriteLockSql();
}
......@@ -1028,9 +1028,9 @@ class BasicEntityPersister
{
$conditionSql = $this->_getSelectConditionSQL($criteria);
if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_READ) {
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
$lockSql = $this->_platform->getReadLockSql();
} else if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE) {
} else if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$lockSql = $this->_platform->getWriteLockSql();
}
......
......@@ -19,7 +19,8 @@
namespace Doctrine\ORM;
use Doctrine\ORM\Query\Parser,
use Doctrine\DBAL\LockMode,
Doctrine\ORM\Query\Parser,
Doctrine\ORM\Query\QueryException;
/**
......@@ -495,7 +496,7 @@ final class Query extends AbstractQuery
/**
* Set the lock mode for this Query.
*
* @see Doctrine\ORM\LockMode
* @see Doctrine\DBAL\LockMode
* @param int $lockMode
* @return Query
*/
......
......@@ -367,11 +367,11 @@ class SqlWalker implements TreeWalker
);
if (($lockMode = $this->_query->getHint(Query::HINT_LOCK_MODE)) !== false) {
if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_READ) {
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
$sql .= " " . $this->_platform->getReadLockSQL();
} else if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE) {
} else if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$sql .= " " . $this->_platform->getWriteLockSQL();
} else if ($lockMode == \Doctrine\ORM\LockMode::OPTIMISTIC) {
} else if ($lockMode == \Doctrine\DBAL\LockMode::OPTIMISTIC) {
$versionedClassFound = false;
foreach ($this->_selectedClasses AS $class) {
if ($class->isVersioned) {
......
......@@ -1646,7 +1646,7 @@ class UnitOfWork implements PropertyChangedListener
$entityName = get_class($entity);
$class = $this->_em->getClassMetadata($entityName);
if ($lockMode == LockMode::OPTIMISTIC) {
if ($lockMode == \Doctrine\DBAL\LockMode::OPTIMISTIC) {
if (!$class->isVersioned) {
throw OptimisticLockException::notVersioned($entityName);
}
......@@ -1657,7 +1657,7 @@ class UnitOfWork implements PropertyChangedListener
throw OptimisticLockException::lockFailedVersionMissmatch($entity, $lockVersion, $entityVersion);
}
}
} else if ($lockMode == LockMode::PESSIMISTIC_READ || $lockMode == LockMode::PESSIMISTIC_WRITE) {
} else if (in_array($lockMode, array(\Doctrine\DBAL\LockMode::PESSIMISTIC_READ, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE))) {
if (!$this->_em->getConnection()->isTransactionActive()) {
throw TransactionRequiredException::transactionRequired();
......
......@@ -103,7 +103,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->setExpectedException('Doctrine\ORM\TransactionRequiredException');
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->find(1, \Doctrine\ORM\LockMode::PESSIMISTIC_READ);
->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ);
}
/**
......@@ -115,7 +115,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->setExpectedException('Doctrine\ORM\TransactionRequiredException');
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->find(1, \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE);
->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE);
}
/**
......@@ -127,7 +127,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->setExpectedException('Doctrine\ORM\OptimisticLockException');
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->find(1, \Doctrine\ORM\LockMode::OPTIMISTIC);
->find(1, \Doctrine\DBAL\LockMode::OPTIMISTIC);
}
/**
......@@ -148,7 +148,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $userId);
$this->setExpectedException('Doctrine\ORM\OptimisticLockException');
$this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $userId, \Doctrine\ORM\LockMode::OPTIMISTIC);
$this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $userId, \Doctrine\DBAL\LockMode::OPTIMISTIC);
}
}
......@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\Tests\Models\CMS\CmsArticle,
Doctrine\Tests\Models\CMS\CmsUser,
Doctrine\ORM\LockMode,
Doctrine\DBAL\LockMode,
Doctrine\ORM\EntityManager;
require_once __DIR__ . '/../../../TestInit.php';
......
......@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\Tests\Models\CMS\CmsArticle,
Doctrine\Tests\Models\CMS\CmsUser,
Doctrine\ORM\LockMode,
Doctrine\DBAL\LockMode,
Doctrine\ORM\EntityManager;
require_once __DIR__ . '/../../../TestInit.php';
......
......@@ -603,7 +603,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'",
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ".
"FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE",
array(Query::HINT_LOCK_MODE => \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE)
array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE)
);
}
......@@ -619,7 +619,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'",
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ".
"FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE",
array(Query::HINT_LOCK_MODE => \Doctrine\ORM\LockMode::PESSIMISTIC_READ)
array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ)
);
}
......@@ -646,7 +646,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'",
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ".
"FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE",
array(Query::HINT_LOCK_MODE => \Doctrine\ORM\LockMode::PESSIMISTIC_READ)
array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ)
);
}
......@@ -662,7 +662,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'",
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ".
"FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE",
array(Query::HINT_LOCK_MODE => \Doctrine\ORM\LockMode::PESSIMISTIC_READ)
array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ)
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment