title: HTTP Status 500 – Internal Server Error
body: <p>I am trying to update my DB rows by using primary key.But facing this Exception</p>
  
  <h2>Exception</h2>
  
  <pre><code>HTTP Status 500 – Internal Server Error
  
  Type Exception Report
  
  Message Request processing failed; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
  
  Description The server encountered an unexpected condition that prevented it from fulfilling the request.
  
  Exception
  
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  </code></pre>
  
  <h2>Controller</h2>
  
  <pre><code>@RequestMapping(value="edit/product/success" ,method=RequestMethod.POST)
  public ModelAndView editProduct(@ModelAttribute ("prdt") Product p)
  {   
  ModelAndView model=new ModelAndView("pl");
  model.addObject("Update","Updated Successfully");
  pd.update(p);
  return model;       
  }
  </code></pre>
  
  <h2>Dao Impl</h2>
  
  <pre><code>public void update( Product p) {
  Session session=sessionFactory.openSession();
  session.update(p);
  session.flush();
  session.close();
  }
  </code></pre>
  
  <h2>Jsp</h2>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ include file="header.jsp"%&gt;
  &lt;%@ page isELIgnored="false"%&gt;
  &lt;%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt; 
  &lt;%@ page isELIgnored="false" %&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"&gt;
  &lt;script src="https://code.jquery.com/jquery-1.12.4.js"&gt;&lt;/script&gt;
    &lt;script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"&gt;&lt;/script&gt;
    &lt;script&gt;
    $( function() {
      $( "#mfg" ).datepicker();
    } );
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;br&gt;
  
  &lt;h2 align="center"&gt;PRODUCT FORM&lt;/h2&gt;&lt;hr&gt;
  &lt;div class="col-md-2 "&gt;&lt;/div&gt;
  &lt;div align="center"&gt;&lt;div class="container"&gt;&lt;div class="col-md-8 "&gt;
  
  
  &lt;form:form method="POST" action="${pageContext.request.contextPath}/edit/product/success" commandName="prdt" enctype="multipart/form-data" &gt;
  &lt;table class="table table-hover"&gt;
  
  &lt;tr&gt;
  &lt;td&gt; &lt;form:label  path="product_Name"&gt; Enter Product Name&lt;/form:label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input type="text" path="product_Name" class="form-control" value="${d.product_Name }"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt; &lt;form:label path="descripction"&gt; Enter Product Descripction&lt;/form:label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input type="text" path="descripction"  class="form-control" value="${d.descripction }"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt; &lt;form:label  path="price"&gt; Enter Product Price&lt;/form:label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input type="text" path="price"  class="form-control" value="${d.price }" /&gt;
  &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt; &lt;form:label  path="mfg_Date"&gt; Enter Manufacture Date&lt;/form:label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input type="text" id="mfg" path="mfg_Date" class="form-control" value ="${d.mfg_Date}"/&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt; &lt;label&gt; Choose Image&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input type="file" path="image" class="form-control" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
   &lt;input type="submit" class="btn btn-primary btn-block" value="Save Changes" class="form-control"/&gt;
  
  &lt;/form:form&gt;
  
  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>please check and let me know my Mistake..i have looked in it.but not found any irregularity.</p>
  
  <h2>Note:</h2>
  
  <p>Data retrieve works fine.facing trouble in Update only  </p>