r/javahelp • • Jul 11 '25

nativeQuery=true is ignored in spring jpa

I want to select data, so I write a Query to select from mysql, and set nativeQuery to true.
The selection from mysql workbench returns 390 results, but from spring it returns 0!
How can it be?

date column is datetime.

@Query(value = "SELECT 
*
 " +
      "FROM twelve_data.time_series_return_minute " +
      "WHERE symbol = :symbol AND " +
      "DATE(date) = DATE(:startDate) AND TIME(date) BETWEEN '09:30:00' AND '16:00:00'", nativeQuery = true)
List<TimeSeriesReturnMinuteEntity> getSymbolsOfDay(String symbol, LocalDate startDate);
1 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/Gyrochronatom Jul 11 '25

Add 2 params startDate and endDate = startDate + x hours, then use date between startDate and endDate