title: How to access repository methods for an entity in symfony2?
body: <p>I am stuck with a problem please help me with it. Here is the scenarario:</p>
  
  <p>I have an entity "User" and corresponding repository "UserRepository", inside  my entity there are only getter and setter methods. All custom queries I have written to UserRepository. Now inside my UserController I am trying to access repository methods which I am not able to do so.
  e.g. 
  User entity:</p>
  
  <pre><code>class User
  {
      ...
  
      public function getId()
      {
          return $this-&gt;id;
      }
  
      public function setId($id)
      {
          return $this-&gt;id=$id;
      }
      public function setProperty($property)
      {
          $this-&gt;property = $property;
      }
  
  
      public function getProperty()
      {
          return $this-&gt;property;
      }
  
      ....
  
      }
    ?&gt;
  </code></pre>
  
  <p>UserRepository:</p>
  
  <pre><code>class UserRepository extends EntityRepository
  {
  
  
      public function findUsersListingById($id)
      {
          $queryBuilder = $this-&gt;getEntityManager()-&gt;createQueryBuilder();
  
         $query = $em-&gt;createQuery(
                      "SELECT U
                      FROM  UserEntityPathGoesHere
                      WHERE U.id IN (".implode(",", $id).")"
                  );
  
          $users = $query-&gt;getResult();
  
          return $users;
      }
  
      public function sayHelloWorld(){
  
          echo ' Hello World';
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>UserController</p>
  
  <pre><code>class UserController
  {
   ...
  
  
  $users=$this-&gt;getDoctrine()
          -&gt;getRepository('MyUserEntityPath')
          -&gt;findUsersListingById($ids);
  
      //now I have multiple users I want to iterate through each user for associating additional data with each user
  
       foreach($users as $user)
       {
          $temp = array();
  
          //I am able to access getId method which is  defined in User entity
          $temp['id'] = $user-&gt;getId();
  
          //however I am not able to  access method from UserRepository, I tried something like below which gives me error  call to undefined function sayHelloWorld
          $temp['status'] = $user-&gt;sayHelloWorld();
  
         ....
  
       }
  
  
  }
  </code></pre>
  
  <p>....</p>
  
  <p>How can I access repository methods for an entity? Is it possible ? If not then what are the alternatives for the solution?</p>