【发布时间】:2017-11-20 21:28:16
【问题描述】:
我正在尝试更新我的 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);}
这是我的控制器的一部分:
@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";
}
这个错误出现在我的浏览器中:
出现意外错误(类型=内部服务器错误,状态=500)。 无法提取结果集;嵌套异常是 org.hibernate.exception.GenericJDBCException: could not extract ResultSet
服务器还说:
SQL 错误:0,SQL 状态:S1009 2017-06-18 12:51:15.778 错误 10388 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper:无法使用 executeQuery() 发出数据操作语句。 2017-06-18 12:51:15.844 错误 10388 --- [nio-8080-exec-4] oaccC[.[.[/].[dispatcherServlet]:Servlet.service() 用于 servlet [dispatcherServlet] path [] 抛出异常 [请求处理失败;嵌套异常是 org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet;嵌套异常是 org.hibernate.exception.GenericJDBCException: could not extract ResultSet] with root cause
java.sql.SQLException: 无法使用 executeQuery() 发出数据操作语句。
【问题讨论】:
标签: java hibernate model-view-controller spring-data-jpa