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; ...@@ -22,6 +22,7 @@ namespace Doctrine\ORM;
use Closure, Exception, use Closure, Exception,
Doctrine\Common\EventManager, Doctrine\Common\EventManager,
Doctrine\DBAL\Connection, Doctrine\DBAL\Connection,
Doctrine\DBAL\LockMode,
Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\ClassMetadataFactory, Doctrine\ORM\Mapping\ClassMetadataFactory,
Doctrine\ORM\Proxy\ProxyFactory; Doctrine\ORM\Proxy\ProxyFactory;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
namespace Doctrine\ORM; namespace Doctrine\ORM;
use Doctrine\DBAL\LockMode;
/** /**
* An EntityRepository serves as a repository for entities with generic as well as * An EntityRepository serves as a repository for entities with generic as well as
* business specific methods for retrieving entities. * business specific methods for retrieving entities.
......
...@@ -790,9 +790,9 @@ class BasicEntityPersister ...@@ -790,9 +790,9 @@ class BasicEntityPersister
: ''; : '';
$lockSql = ''; $lockSql = '';
if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_READ) { if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
$lockSql = ' ' . $this->_platform->getReadLockSql(); $lockSql = ' ' . $this->_platform->getReadLockSql();
} else if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE) { } else if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$lockSql = ' ' . $this->_platform->getWriteLockSql(); $lockSql = ' ' . $this->_platform->getWriteLockSql();
} }
...@@ -1028,9 +1028,9 @@ class BasicEntityPersister ...@@ -1028,9 +1028,9 @@ class BasicEntityPersister
{ {
$conditionSql = $this->_getSelectConditionSQL($criteria); $conditionSql = $this->_getSelectConditionSQL($criteria);
if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_READ) { if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
$lockSql = $this->_platform->getReadLockSql(); $lockSql = $this->_platform->getReadLockSql();
} else if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE) { } else if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$lockSql = $this->_platform->getWriteLockSql(); $lockSql = $this->_platform->getWriteLockSql();
} }
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
namespace Doctrine\ORM; namespace Doctrine\ORM;
use Doctrine\ORM\Query\Parser, use Doctrine\DBAL\LockMode,
Doctrine\ORM\Query\Parser,
Doctrine\ORM\Query\QueryException; Doctrine\ORM\Query\QueryException;
/** /**
...@@ -495,7 +496,7 @@ final class Query extends AbstractQuery ...@@ -495,7 +496,7 @@ final class Query extends AbstractQuery
/** /**
* Set the lock mode for this Query. * Set the lock mode for this Query.
* *
* @see Doctrine\ORM\LockMode * @see Doctrine\DBAL\LockMode
* @param int $lockMode * @param int $lockMode
* @return Query * @return Query
*/ */
......
...@@ -367,11 +367,11 @@ class SqlWalker implements TreeWalker ...@@ -367,11 +367,11 @@ class SqlWalker implements TreeWalker
); );
if (($lockMode = $this->_query->getHint(Query::HINT_LOCK_MODE)) !== false) { 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(); $sql .= " " . $this->_platform->getReadLockSQL();
} else if ($lockMode == \Doctrine\ORM\LockMode::PESSIMISTIC_WRITE) { } else if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$sql .= " " . $this->_platform->getWriteLockSQL(); $sql .= " " . $this->_platform->getWriteLockSQL();
} else if ($lockMode == \Doctrine\ORM\LockMode::OPTIMISTIC) { } else if ($lockMode == \Doctrine\DBAL\LockMode::OPTIMISTIC) {
$versionedClassFound = false; $versionedClassFound = false;
foreach ($this->_selectedClasses AS $class) { foreach ($this->_selectedClasses AS $class) {
if ($class->isVersioned) { if ($class->isVersioned) {
......
...@@ -1646,7 +1646,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1646,7 +1646,7 @@ class UnitOfWork implements PropertyChangedListener
$entityName = get_class($entity); $entityName = get_class($entity);
$class = $this->_em->getClassMetadata($entityName); $class = $this->_em->getClassMetadata($entityName);
if ($lockMode == LockMode::OPTIMISTIC) { if ($lockMode == \Doctrine\DBAL\LockMode::OPTIMISTIC) {
if (!$class->isVersioned) { if (!$class->isVersioned) {
throw OptimisticLockException::notVersioned($entityName); throw OptimisticLockException::notVersioned($entityName);
} }
...@@ -1657,7 +1657,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1657,7 +1657,7 @@ class UnitOfWork implements PropertyChangedListener
throw OptimisticLockException::lockFailedVersionMissmatch($entity, $lockVersion, $entityVersion); 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()) { if (!$this->_em->getConnection()->isTransactionActive()) {
throw TransactionRequiredException::transactionRequired(); throw TransactionRequiredException::transactionRequired();
......
...@@ -103,7 +103,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -103,7 +103,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); $this->setExpectedException('Doctrine\ORM\TransactionRequiredException');
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $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 ...@@ -115,7 +115,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); $this->setExpectedException('Doctrine\ORM\TransactionRequiredException');
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $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 ...@@ -127,7 +127,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->setExpectedException('Doctrine\ORM\OptimisticLockException'); $this->setExpectedException('Doctrine\ORM\OptimisticLockException');
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $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 ...@@ -148,7 +148,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $userId); $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $userId);
$this->setExpectedException('Doctrine\ORM\OptimisticLockException'); $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; ...@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\Tests\Models\CMS\CmsArticle, use Doctrine\Tests\Models\CMS\CmsArticle,
Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsUser,
Doctrine\ORM\LockMode, Doctrine\DBAL\LockMode,
Doctrine\ORM\EntityManager; Doctrine\ORM\EntityManager;
require_once __DIR__ . '/../../../TestInit.php'; require_once __DIR__ . '/../../../TestInit.php';
......
...@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking; ...@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\Tests\Models\CMS\CmsArticle, use Doctrine\Tests\Models\CMS\CmsArticle,
Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsUser,
Doctrine\ORM\LockMode, Doctrine\DBAL\LockMode,
Doctrine\ORM\EntityManager; Doctrine\ORM\EntityManager;
require_once __DIR__ . '/../../../TestInit.php'; require_once __DIR__ . '/../../../TestInit.php';
......
...@@ -603,7 +603,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ...@@ -603,7 +603,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "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 ". "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", "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 ...@@ -619,7 +619,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "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 ". "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", "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 ...@@ -646,7 +646,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "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 ". "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", "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 ...@@ -662,7 +662,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "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 ". "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", "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