php - Symfony2 and Doctrine findOneById() without loading the associated entities? -


is possible entity without loading associated entities using findonebyid()? in cases such checking entity exists or not, don't need load of associated entities, example,

$entity = $em->getrepository('estatebundle:myentity')->findonebyid($id); if (!$entity) {     throw $this->createnotfoundexception('unable find entity.'); } 

otherwise, think lead performance issue. in cakephp, possible using option recursive. i'm looking such kind of option in symfony , doctrine. think common question, can't find documentation this.

edit: removed getreference possibility, no solution question.

second possibility change entity fetch="extra_lazy" doctrine lazy

in general: assoiciated entity selected lazy default, means gets loaded, when first accessing it. maybe problem not relevant in first place? sure use development mode of symfony. there have option see, database queries executed.

edit: can use getrepository("bundle:entity")->find($id) check existence. querying write method like:

$q = $this->createquerybuilder('o,u,i')         ->select('o')         ->from("bundle:entity","o")         ->leftjoin("o.prop","u")         ->leftjoin("o.prop2","i")         ->where('o.id = :id')         ->setparameter('id', $id)         ->getquery(); 

this fetches other entities well.

hope helps


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -