Error: Method threw 'org.springframework.dao.InvalidDataAccessResourceUsageException' exception

Error: Method threw 'org.springframework.dao.InvalidDataAccessResourceUsageException' exception

我正在尝试更新数据,但出现异常,我不知道该怎么办,因为我尝试了很多方法,甚至添加了 @Transactional -

 @RequestMapping(value = "/make-zero",method = RequestMethod.GET)
    public String home(Model model ) {
        try {
            int x = employeeEventRepository.setToZero();
            System.out.println("login is: " + x);
            model.addAttribute("login", x);
        }
        catch (Exception e){
            System.out.println(e);
                    }
        return "redirect:/timetracking/compensatory/pereschet";

    }

这是我的SQL方法

 @Transactional
    @Query(value = "update TT_EMPLOYEE_EVENT set status = 0  where is_approved = 1 and status = 1 and create_date < current_timestamp - numtodsinterval(30, 'minute');COMMIT ;",nativeQuery = true)
    int setToZero();

也许更新查询没有给我 int 类型?

将@Modifying 注释放在@Query 注释之上

因为@Modifying注解增强了@Query注解来执行INSERT、UPDATE、DELETE和DDL查询