title: How do I apply a projection to a Spring Data REST query method resource?
body: <p>I'm using Spring Data REST 2.1.4.RELEASE.</p>
  
  <p>I created</p>
  
  <ul>
  <li>an entity <code>Booking</code>, </li>
  <li>its REST repository (extending <code>CrudRepository</code>) named <code>BookingRepository</code></li>
  <li>and a <strong>projection</strong> <code>BookingDetails</code> (annotated with <code>@Projection(name="details", types = Booking.class)</code>) for returning some of its linked entities exploded, such as <code>Resource</code>, <code>Activity</code>, <code>Applicant</code> etc.</li>
  </ul>
  
  <p>The client gets all bookings with <code>.../rest/bookings</code> and the JSON response includes links for the linked entities. If it adds <code>?projection=details</code> then the linked entities are exploded and returned. And this is great.</p>
  
  <p>Now I add this <strong>custom method</strong> to the repository:</p>
  
  <pre><code>List&lt;Booking&gt; findByApplicant(@Param("applicant") Person applicant);
  </code></pre>
  
  <p>When the client invokes it with <code>.../rest/bookings/search/findByApplicant?applicant=5</code>, there seem to be no way to request the <code>details</code> projection. Following attempts are ignored:</p>
  
  <ul>
  <li>adding <code>&amp;projection=details</code> to the query string</li>
  <li><p>making the method always return <code>BookingDetails</code>:</p>
  
  <pre><code>List&lt;BookingDetails&gt; findByApplicant(@Param("applicant") Person applicant);
  </code></pre></li>
  </ul>
  
  <p>Summarizing, <strong>custom search methods (<code>findBy*</code>) never return a projection</strong>. Unless you annotate the repository with <code>@RepositoryRestResource(excerptProjection = BookingDetails.class)</code>, but this leads to some problems, first of all the client has to always use the same projection. How can we allow the user to use projections also with <code>findBy*</code> methods?</p>