title: Spring data hibernate serialize item properties according to method
body: <p>I have a question. 
  Lets imagine, we have an entity of Hotel. That entity contains for example <strong>id, name, Country object reference, theme foto path and list of other photo patches</strong>.</p>
  
  <p>I'm using the Spring boot JPA + jackson. So repositories are like...</p>
  
  <pre><code>@Repository
  public interface HotelRepository extends CrudRepository&lt;HotelEntity, Long&gt; {
      List&lt;HotelEntity&gt; findTop3ByCountryOrderByPriorityDesc(CountryEntity country);
  }
  </code></pre>
  
  <p>Is there any possibility to annotate entity fields with some jackson to tell Spring boot- "Hey, if you use this repository method (for example that findTop3ByCountryOrderByPriorityDesc method), take just name, id and theme photo.
  (And this approach would be used in all entities and methods). Something like</p>
  
  <pre><code>@JsonSerializeClasses({"top3Hotels", "hotels"})    
  String name;
  </code></pre>
  
  <p>And usage in repositorz</p>
  
  <pre><code>@JsonSerializeClassesUsage({top3Hotels})
  List&lt;HotelEntity&gt; findTop3ByCountryOrderByPriorityDesc(CountryEntitycountry);
  </code></pre>
  
  <p>(This method would return list of hotel entities that contains just names).</p>
  
  <p>Note: It can work in a "negative" way too. So if I annotate some field with some "class in class", this field would not be included in return object from method, that has not this "inner class" included in its annotation.</p>
  
  <p>Is this possible in Spring data with jackson?</p>
  
  <p>Or I really have to return objects and in cases i dont want some properities, I have to iterate over them and "null" it manually?</p>
  
  <p>Thank you.</p>