title: What's the difference between Spring Data's MongoTemplate and MongoRepository?
body: <p>I need to write an application with which I can do complex queries using spring-data and mongodb. I have been starting by using the MongoRepository but struggled with complex queries to find examples or to actually understand the Syntax. </p>
  
  <p>I'm talking about queries like this:</p>
  
  <pre><code>@Repository
  public interface UserRepositoryInterface extends MongoRepository&lt;User, String&gt; {
      List&lt;User&gt; findByEmailOrLastName(String email, String lastName);
  }
  </code></pre>
  
  <p>or the use of JSON based queries which I tried by trial and error because I don't get the syntax right. Even after reading the mongodb documentation (non-working example due to wrong syntax).</p>
  
  <pre><code>@Repository
  public interface UserRepositoryInterface extends MongoRepository&lt;User, String&gt; {
      @Query("'$or':[{'firstName':{'$regex':?0,'$options':'i'}},{'lastName':{'$regex':?0,'$options':'i'}}]")
      List&lt;User&gt; findByEmailOrFirstnameOrLastnameLike(String searchText);
  } 
  </code></pre>
  
  <p>After reading through all the documentation it seems that <code>mongoTemplate</code> is far better documented then <code>MongoRepository</code>. I'm referring to following documentation:</p>
  
  <p><a href="http://static.springsource.org/spring-data/data-mongodb/docs/current/reference/html/" rel="noreferrer">http://static.springsource.org/spring-data/data-mongodb/docs/current/reference/html/</a> </p>
  
  <p>Can you tell me what is more convenient and powerful to use? <code>mongoTemplate</code> or <code>MongoRepository</code>? Are both same mature or does one of them lack more features then the other?</p>