Skip to content

Commit

Permalink
Merge branch 'hotfix/#1113-composite-pk-improved-support'
Browse files Browse the repository at this point in the history
Close #1113
  • Loading branch information
Ocramius committed Feb 16, 2015
2 parents 081ad0e + 2a99d5a commit f908974
Show file tree
Hide file tree
Showing 18 changed files with 660 additions and 152 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key,

/* @var $entityEntries \Doctrine\ORM\Cache\EntityCacheEntry[] */
foreach ($entityEntries as $index => $entityEntry) {
$list[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->data, self::$hints);
$list[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->resolveAssociationEntries($this->em), self::$hints);
}

array_walk($list, function($entity, $index) use ($collection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Doctrine\ORM\Cache\TimestampCacheKey;
use Doctrine\ORM\Cache\QueryCacheKey;
use Doctrine\ORM\Cache\Persister\CachedPersister;
use Doctrine\ORM\Cache\CacheException;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -233,6 +234,14 @@ public function storeEntityCache($entity, EntityCacheKey $key)
$class = $this->metadataFactory->getMetadataFor($className);
}

if ($class->containsForeignIdentifier) {
foreach ($class->associationMappings as $name => $assoc) {
if (!empty($assoc['id']) && !isset($assoc['cache'])) {
throw CacheException::nonCacheableEntityAssociation($class->name, $name);
}
}
}

$entry = $this->hydrator->buildCacheEntry($class, $key, $entity);
$cached = $this->region->put($key, $entry);

Expand Down
8 changes: 8 additions & 0 deletions lib/Doctrine/ORM/ORMException.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,12 @@ public static function overwriteInternalDQLFunctionNotAllowed($functionName)
{
return new self("It is not allowed to overwrite internal function '$functionName' in the DQL parser through user-defined functions.");
}

/**
* @return ORMException
*/
public static function cantUseInOperatorOnCompositeKeys()
{
return new self("Can't use IN operator on entities that have composite keys.");
}
}
Loading

0 comments on commit f908974

Please sign in to comment.