title: Dynamic Query in Spring Data
body: <p>I build a native query dynamically on a class especific, and I need to pass this query to JpaRepository to execute it. The result is all the same. I don't know if this is possible, but is it only solution for my problem.</p>
  
  <p>An example:</p>
  
  <pre><code>@Component
  public class DataCmd {
      public List&lt;IncomingDataDTO&gt; getAllIncomingData(String dynamicQuery){
          entity = this.getIncomingDataRepository().findAllByQuery(dynamicQuery);
      }
  }
  
  
  @Repository
  public interface IncomingDataRepository extends JpaRepository&lt;IncomingData, IncomingDataPK&gt; {
      @Query(dynamicQuery)
      public List&lt;IncomingData&gt; findAllByQuery();
  }
  </code></pre>