У меня есть этот запрос в репозитории JPA:
@Repository
public interface PaymentTransactionsDailyFactsRepository extends JpaRepository<PaymentTransactionsDailyFacts, Integer> {
@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<PaymentTransactionsDailyFacts> generateDailyFacts(@Param("start_date") LocalDate start_date, @Param("end_date") LocalDate end_date);
}
Но когда я выполняю его в Spring Scheduler, я получаю ошибку:
SQL Error: 1054, SQLState: 42S22
Caused by: java.sql.SQLSyntaxErrorException: No such column: id
Когда я выполняю этот запрос в MariaDB, он работаетотлично:
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
Как видите, я выполняю этот собственный запрос для таблицы payment_transactions
, но ожидаю результата для таблицы payment_transactions_daily_facts
.Есть ли способ правильно реализовать этот запрос?