title: Hibernate Delete Error: Batch Update Returned Unexpected Row Count
body: <p>I wrote this method below that is suppose to delete a member record from the database. But when I use it in my servlet it returns an error.</p>
  
  <p><strong>MemberDao Class</strong></p>
  
  <pre><code>public static void deleteMember(Member member) {
      Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
      Transaction tx = hibernateSession.beginTransaction();
      hibernateSession.delete(member);
      tx.commit();
  }
  </code></pre>
  
  <p><strong>Controller Part</strong></p>
  
  <pre><code>if(delete != null) {
      HttpSession httpSession = request.getSession();
      Member member = (Member) httpSession.getAttribute("member");
  
      MemberDao.deleteMember(member);
  
      nextPage = "ledenlijst.jsp";
  }
  </code></pre>
  
  <p><strong>HTTP Status 500</strong></p>
  
  <pre><code>org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
  </code></pre>
  
  <p>Sometimes it even throws this error when I try to execute the page multiple times.</p>
  
  <pre><code>org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
  </code></pre>
  
  <p>Does anybody know what exactly is causing these errors?</p>