title: Spring Data Mongo DB Repository FindBy not working
body: <p>I'm trying to add a custom query to a MongoRepository instance, but it's not working. Section 10.3 in <a href="http://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.repositories" rel="nofollow">here</a> describes what I'm trying to do. I've tried 4 different ways of doing it, but nothing seems to work...</p>
  
  <p>My Code</p>
  
  <pre><code>public interface MyRepository extends MongoRepository&lt;StudentEO,CustomId&gt;{
  
      //1st attempt. 
      //StudentEO findByFirstName(String firstName);
  
      //2nd attempt. 
      //@Query("{ 'firstName' : ?0 }")
      //StudentEO findByFirstName(String firstName);
  
      //3rd attempt.
      //List&lt;StudentEO&gt; findByFirstName(String firstName);
  
      //4th attempt
      @Query("{ 'firstName' : ?0 }")
      List&lt;StudentEO&gt; findByFirstName(String firstName);
  }
  
  @Document(collection = "data_point_metadata")
  public class StudentEO {
  
      @Id
      private CustomId id;
      private String firstName;
      private String lastName;
      private StudentType studentType;
  
      ...
  
      getters and setters...
  }
  
  @Component
  public class StringToStudentTypeConverter implements Converter&lt;String, StudentType&gt; {
  
      @Override 
      public StudentType convert(String source) { 
          if(source == null){
              return null;
          }
  
          try{
              return StudentType.valueOf(source.trim().toUpperCase());
          }catch(Exception e){
              LOGGER.error("invalid dataType value - "+e.getMessage());
          }
          return null;
      }
  }
  </code></pre>
  
  <p>In the logs I see:</p>
  
  <pre><code>c.f.f.s.w.m.u.StringToDataTypeConverter - invalid studentType value - No enum constant ...StudentType.John
  o.s.data.mongodb.core.MongoTemplate - find using query: { "firstName" :  null } fields: null ... 
  </code></pre>
  
  <p>and I don't get anything back. When I debug it, my service layers is definitely passing a valid firstName. Not null.</p>
  
  <p>I'm also using a default findAll() repository method, and it works fine. </p>
  
  <pre><code>PageRequest pageRequest = new PageRequest(pageNumber, pageSize != 0 ? pageSize : defaultPageSize);
  Page&lt;StudentEO&gt; studentsPage = myRepository.findAll(pageRequest);
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>I'm using the following version of spring apis:</p>
  
  <ul>
  <li>spring-core 4.1.7.RELEASE</li>
  <li>spring-data-commons 1.9.3.RELEASE</li>
  <li>spring-data-mongodb 1.6.3.RELEASE</li>
  </ul>