title: MongoDB Spring Data Projection Returns only the First Matched Element
body: <p>I have </p>
  
  <pre><code>@Document
  public class Employee
  {
   @Id
   Long empCode;
   String empSurname;
   String address;
  // getters setters
  }
  </code></pre>
  
  <p>Then I have an extension of the MongoRepository</p>
  
  <pre><code>public interface EmployeeRepository extends MongoRepository&lt;Employee, Long&gt;
  {
    EmployeeProject findAddressByEmpSurname(String surName);
  }
  </code></pre>
  
  <p>EmployeeProject is a Projection</p>
  
  <pre><code>public interface EmployeeProject 
  {
      public List&lt;String&gt; getAddress();
  }
  </code></pre>
  
  <p>I am calling</p>
  
  <pre><code>EmployeeProject param = employeeRepository.findAddressByEmpSurname("Smith");
  param.getAddress().size(); -&gt; Returns the first matched element only
  </code></pre>
  
  <p>I need getAddress() to return all matched values as a String and not just the first one.</p>
  
  <p>Any help would be much appreciated. Thanks.
  PS: If I run the generated query directly on the MongoDB database, I get back all documents.
  It appears that I need a <a href="http://docs.spring.io/spring/docs/4.2.5.RELEASE/spring-framework-reference/html/expressions.html" rel="nofollow">Collection Projection</a> but I can't seem to get the Syntax correct.</p>