{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/27057d65bbe60f4a9ccecb6cd74dc523?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"27057d65bbe60f4a9ccecb6cd74dc523","url":"https://api.github.com/users/IjinPL","login":"IjinPL","id":581121},"assignee":null,"labels":[],"updated_at":"2011-11-17T14:50:12Z","comments":3,"closed_at":null,"url":"https://api.github.com/repos/stof/StofDoctrineExtensionsBundle/issues/85","body":"Hi.\r\nTo get all the leaves from the tree i implemented simple function extending NestedTreeRepository.php\r\n\r\n```php\r\n<?php\r\n...\r\nuse Doctrine\\ORM\\EntityRepository;\r\n...\r\npublic function getLeaves()\r\n    {\r\n\t\t$em = $this->getEntityManager();\r\n\t\t\r\n\t\t$leaves = $em->createQuery('SELECT p \r\n\t\t\t\t\t\t\t\t\tFROM CatalogerCatalogBundle:Category p \r\n\t\t\t\t\t\t\t\t\tWHERE p.id NOT IN(\r\n\t\t\t\t\t\t\t\t\t\t\tSELECT DISTINCT l.parent_id \r\n\t\t\t\t\t\t\t\t\t\t\tFROM CatalogerCatalogBundle:Category l \r\n\t\t\t\t\t\t\t\t\t\t\tWHERE l.parent_id IS NOT NULL\r\n\t\t\t\t\t\t\t\t\t)'\r\n\t\t\t\t\t\t\t\t);\t\t\r\n\t    \r\n\t\t\treturn $leaves->getResult();\r\n    }\r\n```\r\n\r\nTo retrive parent_id I added extra field  to my Category.php class, which is not accessible by default:\r\n\r\n```php\r\n<?php\r\n    /**\r\n    * @ORM\\Column(name=\"parent_id\", type=\"integer\", nullable=true)\r\n    */\r\n    private $parent_id;  \r\n\r\n\r\n    /**\r\n     * Set parent_id\r\n     *\r\n     * @param integer $parentId\r\n     */\r\n    public function setParentId($parentId)\r\n    {\r\n        $this->parent_id = $parentId;\r\n    }\r\n\r\n    /**\r\n     * Get parent_id\r\n     *\r\n     * @return integer \r\n     */\r\n    public function getParentId()\r\n    {\r\n        return $this->parent_id;\r\n    }\r\n```\r\n\r\nEverything works great in dev environtment, but if i'm trying to get nodes in production env. i got error 500 issue. \r\nI'm not realy sure if it's StofDoctrineExtensionsBundle error or Doctrine error, because if I remove subquery from selset everything works fine in both environments.\r\nPlease chceck this and if u find any solution share it with me.   ","html_url":"https://github.com/stof/StofDoctrineExtensionsBundle/issues/85","title":"Getting leaves in Nested Tree - problem","number":85,"id":2264504,"created_at":"2011-11-17T01:52:49Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/7894bbdf1c05b18a1444ad8c76c9d583?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"7894bbdf1c05b18a1444ad8c76c9d583","url":"https://api.github.com/users/stof","login":"stof","id":439401},"updated_at":"2011-11-17T14:50:12Z","url":"https://api.github.com/repos/stof/StofDoctrineExtensionsBundle/issues/comments/2776742","body":"Did you cleared it using ``--no-debug`` ? When running the command in debug mode, the cache is warmed up in debug mode and as the debug mode will generate the proxies for each request anyway, it does not run the cache warmer.\r\n\r\nthe doc of the extensions sets the relation to the parent in the example: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/tree.md (and this is even needed by the Tree extension). And the query is already implemented in a more efficient way (without using a subquery) in the NestedTreeRepository: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/lib/Gedmo/Tree/Entity/Repository/NestedTreeRepository.php#L381","id":2776742,"created_at":"2011-11-17T14:50:12Z"}}