title: Doctrine 2, query inside entities
body: <p>How do I perform queries in an entity?</p>
  
  <pre><code>namespace Entities\Members;
  
  /**
   * @Entity(repositoryClass="\Entities\Member\MembersRepository")
   * @Table(name="Members")
   * @HasLifecycleCallbacks
   */
  class Members extends \Entities\AbstractEntity
  {
      /**
       * @Id @Column(name="id", type="bigint",length=15)
       * @GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /** 
       * @Column(name="userid", type="bigint", length=26, nullable=true) 
       */
      protected $userid;
  
      /** 
       * @Column(name="fname", type="string", length=255,nullable=true) 
       */
      protected $fname;
  
      /**
       *  @OneToMany(targetEntity="\Entities\Users\Wall", mappedBy="entry", cascade={"persist"}) 
       */
      protected $commententries;
  
      public function __construct()
      {
          $this-&gt;commententries = new \Doctrine\Common\Collections\ArrayCollection();
      }
  }
  </code></pre>
  
  <p>Example I would like to have a function inside this entity called: <code>filter()</code>
  and I want to be able to filter the <code>commententries</code> collection. It should return a collection with a certain condition such <code>id=1</code>. Basically it should be filtering the data received from the join query.</p>
  
  <p>So something like this:</p>
  
  <pre><code>$this-&gt;commententries-&gt;findBy(array('id' =&gt; 1));
  </code></pre>
  
  <p>But obviously this does not work.</p>