我正在嘗試更新資料,但它給了我例外,我不知道我該怎么辦,因為我嘗試了很多方法,甚至添加了@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 型別?
uj5u.com熱心網友回復:
將@Modifying 注釋放在@Query 注釋之上
因為@Modifying注解增強了@Query注解來執行INSERT、UPDATE、DELETE和DDL查詢
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/453529.html
