【发布时间】:2014-02-03 03:37:29
【问题描述】:
我在下面写了这个方法,假设从数据库中删除一个成员记录。但是当我在我的 servlet 中使用它时,它会返回一个错误。
MemberDao 类
public static void deleteMember(Member member) {
Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = hibernateSession.beginTransaction();
hibernateSession.delete(member);
tx.commit();
}
控制器部分
if(delete != null) {
HttpSession httpSession = request.getSession();
Member member = (Member) httpSession.getAttribute("member");
MemberDao.deleteMember(member);
nextPage = "ledenlijst.jsp";
}
HTTP 状态 500
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
当我尝试多次执行页面时,有时它甚至会抛出此错误。
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
有人知道究竟是什么导致了这些错误吗?
【问题讨论】:
-
您是否尝试将相同的
member删除两次?
标签: java hibernate methods dao