我在 SpringBoot 中使用 JPARepository 并使用@Query
注释,但我收到错误
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
使用nativeQuery=true
时
这是我的函数:
@Query(value = "select * from table1 where status = ?1 and time <= ?2 LIMIT 2", nativeQuery = true)
List<MyModel> findScheduledSmsMessages(Status status, LocalDateTime time);
我在查询上方添加了以下代码,并且
@Modifying
@Transactional
喜欢这个:
@Modifying
@Transactional
@Query(value = "DELETE FROM played_sheet WHERE user_id = ?1 AND sheet_music_id = ?2", nativeQuery = true)
void deleteByUserIdAndSheetMusicId(Integer userId,Integer sheetMusicId);