我正在尝试更新我的JPA存储库
@Transactional
public interface UserRepository extends JpaRepository<User, Integer> {
User findByUsername(String username);
User findById(Long id);
@Query(value = "update user t set t.rule_id = NULL where t.rule_id = :id", nativeQuery = true)
List<User> setNUll(@Param("id") String id);}
Run Code Online (Sandbox Code Playgroud)
这是我的控制器的一部分:
@RequestMapping(value = "/admin/rule/{id}/edit", method = RequestMethod.GET)
public String editRule(@PathVariable Integer id, Model model)
{
userService.setNUll(Integer.toString(id));
model.addAttribute("rule", ruleCrudService.getRuleById(id));
updateUserData();
return "ruleForm";
}
Run Code Online (Sandbox Code Playgroud)
并且此错误在我的浏览器中出现:
发生意外错误(类型=内部服务器错误,状态= 500)。无法提取ResultSet;嵌套的异常是org.hibernate.exception.GenericJDBCException:无法提取ResultSet
服务器还说:
SQL错误:0,SQLState:S1009 2017-06-18 12:51:15.778错误10388 --- [nio-8080-exec-4] ohengine.jdbc.spi.SqlExceptionHelper:无法使用executeQuery()发出数据操作语句。2017-06-18 12:51:15.844错误10388 --- [nio-8080-exec-4] oaccC [。[。[/]。[dispatcherServlet]:Servlet [dispatcherServlet]的Servlet.service()路径[]引发异常[请求处理失败;嵌套的异常是org.springframework.orm.jpa.JpaSystemException:无法提取ResultSet。嵌套的异常是org.hibernate.exception.GenericJDBCException:无法从根本原因中提取ResultSet]
java.sql.SQLException:无法使用executeQuery()发出数据操作语句。