I'm using JPARepository in SpringBoot and using the @Query annotation but I get an error
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
When using the nativeQuery=true
This is my function:
@Query(value = "select * from table1 where status = ?1 and time <= ?2 LIMIT 2", nativeQuery = true)
List<MyModel> findScheduledSmsMessages(Status status, LocalDateTime time);
?1and?2are incorrect for native queries. Use?by itself.LIMITis not supported by all of them.