title: Spring JPA Projection findAll
body: <p>Is it possible to use "findAll" for a JPARepository returning a Collection/List of Projections?
  Example:</p>
  
  <pre><code>@Entity
  public class Login {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
      @GenericGenerator(name = "native", strategy = "native")
      private Integer id;
  
      private String name;
  
      private String pass;
  
      (...)
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public interface LoginProjection {
      public String getName();
  }
  
  @Repository
  public interface LoginRepository extends JpaRepository&lt;Login, Long&gt; {
      Login findByName(String name);
  
      @Query(value = "SELECT name FROM login", nativeQuery = true)
      List&lt;LoginProjection&gt; findAllLoginProjection();
  }
  </code></pre>
  
  <p>Using @Query it works! But it is not possible to use </p>
  
  <pre><code> List&lt;LoginProjection&gt; findAll();
  </code></pre>
  
  <p>Because LoginProjection it does not extends T (Login).</p>
  
  <p>I was thinking if it is possible to give a "alias" for findAll like findAllXYZ that does the same thing as findAll.
  Using filters it works too, but I do not want to use them:</p>
  
  <pre><code> List&lt;LoginProjection&gt; findAllByName(String name);
  </code></pre>
  
  <p>My main goal would be something like this:</p>
  
  <pre><code>@Repository
  public interface LoginRepository extends JpaRepository&lt;Login, Long&gt; {
      Login findByName(String name);
  
      List&lt;Login&gt; findAll();
  
      List&lt;LoginProjection&gt; findAllLoginProjection();
  }
  </code></pre>
  
  <p>Which is pretty easy and with "zero @Query"</p>