title: Unrecognized field: user_name, while querying Via Doctrine using ZF2
body: <p>here is the snippet to my code when i try to query it like this </p>
  
  <pre><code>   if ($request-&gt;isPost()) {
          $form-&gt;setData($request-&gt;getPost());
          if ($form-&gt;isValid()) {
  
              //check authentication...
              $this-&gt;getAuthService()-&gt;getAdapter()
                      -&gt;setIdentity($request-&gt;getPost('username'))
                      -&gt;setCredential($request-&gt;getPost('password'));
  
              $username = $request-&gt;getPost('username');
              $password = $request-&gt;getPost('password');
              $result = $this-&gt;getAuthService()-&gt;authenticate();
  
              $criteria = array("user_name" =&gt; $username,);
             $results= $this-&gt;getEntityManager()-&gt;getRepository('Subject\Entity\User')-&gt;findBy($criteria);
             print_r($results);
             exit;
  </code></pre>
  
  <p>i get the following error</p>
  
  <blockquote>
    <p>Unrecognized field: user_name</p>
  </blockquote>
  
  <p>These are my includes </p>
  
  <blockquote>
    <p>Use Doctrine\ORM\EntityManager,
        Album\Entity\Album;</p>
  </blockquote>
  
  <p>Edit: this is my Subject\Entity\User file </p>
  
  <pre><code> &lt;?php
  
  namespace Subject\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Zend\InputFilter\InputFilter;
  use Zend\InputFilter\Factory as InputFactory;
  use Zend\InputFilter\InputFilterAwareInterface;
  use Zend\InputFilter\InputFilterInterface;
  
  /**
   * @ORM\Entity
  
  * @ORM\Table(name="users")
  
  * @property string $username
  
  * @property string $password
  
  * @property int $id
  
   */
  class User implements InputFilterAwareInterface {
  
  protected $_username;
  protected $_password;
  
   /**
   * @ORM\OneToMany(targetEntity="Subject\Entity\Subject", mappedBy="user")
   * @var Collection
   */
  private $subjects;
  
  /** @ORM\Id() @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") @var int */
  protected $_id;
  
  public function __get($property) {
  
      return $this-&gt;$property;
  }
  
  public function __set($property, $value) {
  
      $this-&gt;$property = $value;
  }
  
  //Getters and setters
  
  /** @return Collection */
  public function getSubjects() {
      return $this-&gt;subjects;
  }
  
  /** @param Comment $comment */
  public function addSubject(Subject $subjects) {
      $this-&gt;subjects-&gt;add($subjects);
      $subjects-&gt;setUser($this);
  }
  
  
   public function __construct($subjects) {
      //Initializing collection. Doctrine recognizes Collections, not arrays!
      $this-&gt;subjects = new ArrayCollection();
  
  }
  public function getArrayCopy() {
  
      return get_object_vars($this);
  }
  
  public function populate($data = array()) {
  
      $this-&gt;_id = $data['id'];
  
      $this-&gt;_username = $data['username'];
  
      $this-&gt;_password = $data['password'];
  }
  
  public function setInputFilter(InputFilterInterface $inputFilter) {
  
      throw new \Exception("Not used");
  }
  
  public function getInputFilter() {
  
      if (!$this-&gt;inputFilter) {
          $inputFilter = new InputFilter();
          $factory = new InputFactory();
          $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name' =&gt; 'id',
                      'required' =&gt; true,
                      'filters' =&gt; array(
                          array('name' =&gt; 'Int'),
                      ),
                  )));
          $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name' =&gt; 'username',
                      'required' =&gt; true,
                      'filters' =&gt; array(
                          array('name' =&gt; 'StripTags'),
                          array('name' =&gt; 'StringTrim'),
                      ),
                      'validators' =&gt; array(
                          array(
                              'name' =&gt; 'StringLength',
                              'options' =&gt; array(
                                  'encoding' =&gt; 'UTF-8',
                                  'min' =&gt; 1,
                                  'max' =&gt; 100,
                              ),
                          ),
                      ),
                  )));
  
  
  
          $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name' =&gt; 'password',
                      'required' =&gt; true,
                      'filters' =&gt; array(
                          array('name' =&gt; 'StripTags'),
                          array('name' =&gt; 'StringTrim'),
                      ),
                      'validators' =&gt; array(
                          array(
                              'name' =&gt; 'StringLength',
                              'options' =&gt; array(
                                  'encoding' =&gt; 'UTF-8',
                                  'min' =&gt; 1,
                                  'max' =&gt; 100,
                              ),
                          ),
                      ),
                  )));
  
  
  
          $this-&gt;inputFilter = $inputFilter;
      }
  
  
  
      return $this-&gt;inputFilter;
  }
  
  //put your code here
  }
  
  ?&gt;
  </code></pre>