diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 1dfb93349..2947b19ee 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -28,6 +28,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use ReflectionClass; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\ClassLoader; +use Doctrine\ORM\Cache\CacheException; /** * A ClassMetadata instance holds all the object-relational mapping metadata @@ -1486,6 +1487,10 @@ class ClassMetadataInfo implements ClassMetadata if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) { $this->isIdentifierComposite = true; } + + if ($this->cache && !isset($mapping['cache'])) { + throw CacheException::nonCacheableEntityAssociation($this->name, $mapping['fieldName']); + } } // Mandatory attributes for both sides