I found a question explaining the problem as I have - Symfony2 + Doctrine2 is not caching results of joined entities, but the answer doesn't help, because I'm using Sf 2.3 and Doctrine 2.3.6. Also, instead of APC I use MemCache for query and result caching.
config.yml
doctrine:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
query_cache_driver:
type: memcache
host: "%result_memcache_host%"
port: "%result_memcache_port%"
instance_class: Memcache
result_cache_driver:
type: memcache
host: "%result_memcache_host%"
port: "%result_memcache_port%"
instance_class: Memcache
In controller:
$rs = $this->getEM()
->getRepository('MainBundle:Channels')
->findByIdFullData($id)
->useResultCache(true, 900, 'channel' . $id)
->getOneOrNullResult();
In repository:
public function findByIdFullData($id)
{
$rs = $this
->createQueryBuilder('c')
->select('c', 'al')
->leftJoin('c.audioLanguage', 'al')
->where('c.id = :id')
->andWhere('c.active = 1')
->setParameter('id', $id);
return $rs->getQuery();
}
audioLanguage
is a ManyToMany relation between channels and languages and every time i get a query to DB while trying to access it in twig or by calling getAudioLanguage()
What could be wrong?
Thanks