title: Select data from another table from JPA repository
body: <p>I have this query in JPA repository:</p>
  
  <pre><code>@Repository
  public interface PaymentTransactionsDailyFactsRepository extends JpaRepository&lt;PaymentTransactionsDailyFacts, Integer&gt; {
  
      @Query(value = "SELECT " + 
              " COUNT(*) count, " + 
              " SUM(amount) volume, " + 
              " DATE(created_at) date, " + 
              " YEAR(created_at) year, " + 
              " MONTH(created_at) month, " + 
              " WEEK(created_at) week, " + 
              " DAY(created_at) day, " + 
              " type transaction_type, " + 
              " contract_id, merchant_id, terminal_id, " + 
              " status, card_brand, currency " + 
              " FROM payment_transactions " + 
              " WHERE status NOT IN ('pending_async','pending','pending_review','in_progress','new') AND created_at BETWEEN :start_date AND :end_date " + 
              " GROUP by date, contract_id, merchant_id, terminal_id, transaction_type, status, card_brand, currency", nativeQuery = true)
      List&lt;PaymentTransactionsDailyFacts&gt; generateDailyFacts(@Param("start_date") LocalDate start_date, @Param("end_date") LocalDate end_date);
  }
  </code></pre>
  
  <p>But when I execute it in Spring Scheduler I get error:</p>
  
  <pre><code>SQL Error: 1054, SQLState: 42S22
  Caused by: java.sql.SQLSyntaxErrorException: No such column: id
  </code></pre>
  
  <p>When I execute this query in MariaDB it's working fine:</p>
  
  <pre><code>SELECT  COUNT(*) count,  SUM(amount) volume,  DATE(created_at) date,  YEAR(created_at) year,  MONTH(created_at) month,  WEEK(created_at) week,  DAY(created_at) day,  type transaction_type,  contract_id, merchant_id, terminal_id,  status, card_brand, currency  FROM payment_transactions  WHERE status NOT IN ('pending_async','pending','pending_review','in_progress','new') AND created_at BETWEEN '2011-04-11 00:00:01' AND '2029-04-11 00:00:00'  GROUP by date, contract_id, merchant_id, terminal_id, transaction_type, status, card_brand, currency
  </code></pre>
  
  <p>As you can see I'm running this native query for table <code>payment_transactions</code> but I'm expecting a result for table <code>payment_transactions_daily_facts</code>. Is there a way to implement this query properly? </p>