我写下这个方法是假设从数据库中删除成员记录。但是当我在我的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
有没有人知道究竟是什么导致了这些错误?
可能的重复:http://stackoverflow.com/questions/3853106/org-hibernate-stalestateexception-batch-update-returned-unexpected-row-count-fr –
你是否试图删除同一个'member'两次? –