title: Spring data dynamic @Query based on params possible?
body: <p>I recently switched from JEE to Spring Boot and I'm loving it so far. 
  But I have run into a little issue. I have this method that fetches lazy references that used to look something like this:</p>
  
  <pre><code>public Foo getParentWithChildren(long id, boolean isFetchChild, boolean isFetchPets) {
      StringBuilder sql = new StringBuilder();
      sql.append("select DISTINCT(p) from Parent p");
      if(isFetchChild) {
          sql.append(" left join p.child c");
      } if(isFetchPets) {
          sql.append(" left join p.pets pts");
      } 
  
      sql.append(" where p.id=:id");
  
      TypedQuery&lt;Foo&gt; query = em.createQuery(sql.toString(), Foo.class);
      query.setParameter("id", id);
      return query.getSingleResult();
  }
  </code></pre>
  
  <p>Now with spring data and their awesome interfaces I would like to do something simlar using the @Query annotation on the interface instead of having to write a custom implementation. But is it possible to do something similar using only the interface.  </p>
  
  <p>The example below will obviously not work but I hope you understand what I am trying to acchieve</p>
  
  <pre><code>@Query("select distinct(p) from Parent p " + 
          (fetchChild ? " left join p.child c" : "") + 
          (fetchPets ? " left join p.pets pts" : "") +
          " where p.id=:id")
  Foo getParentWithChildren(@Param("id") long id, @Param("fetchChild") boolean isFetchChild, @Param("fetchPets") boolean isFetchPets);
  </code></pre>
  
  <p>I something similar possible?</p>