diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 96f0fbd0ed6..e4bac034a94 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -260,7 +260,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h throw new CacheException("Second-level cache query supports only select statements."); } - if (isset($hints[Query::HINT_FORCE_PARTIAL_LOAD]) && $hints[Query::HINT_FORCE_PARTIAL_LOAD]) { + if (isset($hints[Query\SqlWalker::HINT_PARTIAL]) && $hints[Query\SqlWalker::HINT_PARTIAL]) { throw new CacheException("Second level cache does not support partial entities."); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index d06d070610f..836de7261a3 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -46,6 +46,11 @@ class SqlWalker implements TreeWalker */ const HINT_DISTINCT = 'doctrine.distinct'; + /** + * @var string + */ + const HINT_PARTIAL = 'doctrine.partial'; + /** * @var ResultSetMapping */ @@ -1366,6 +1371,8 @@ public function walkSelectExpression($selectExpression) default: // IdentificationVariable or PartialObjectExpression if ($expr instanceof AST\PartialObjectExpression) { + $this->query->setHint(self::HINT_PARTIAL, true); + $dqlAlias = $expr->identificationVariable; $partialFieldSet = $expr->partialFieldSet; } else { diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 0a32886dd0f..df7e95b7e4b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -1095,7 +1095,6 @@ public function testCacheablePartialQueryException() $this->loadFixturesCountries(); $this->_em->createQuery("SELECT PARTIAL c.{id} FROM Doctrine\Tests\Models\Cache\Country c") - ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) ->setCacheable(true) ->getResult(); }