title: Getting InvocationTargetException on my Spring Hibernate Project
body: <p><a href="https://i.stack.imgur.com/0kQd7.png" rel="nofollow noreferrer">Here is the table of data</a>   </p>
  
  <p>I have created a simple hibernate/spring with crud with a database in my mySQL. Everything works but my edit function. It says This error.</p>
  
  <pre><code>root cause
  
  org.springframework.beans.InvalidPropertyException: Invalid property 'id' of bean class [org.jjm.test.model.Phone_$$_jvst33c_0]: Getter for property 'id' threw exception; nested exception is java.lang.reflect.InvocationTargetException
      org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:704)
      org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:610)
      org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99)
      org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:229)
      org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:120)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:141)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:132)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:116)
      org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)
      org.springframework.web.servlet.tags.form.HiddenInputTag.writeTagContent(HiddenInputTag.java:79)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
      org.apache.jsp.WEB_002dINF.views.phoneDetails_jsp._jspx_meth_form_005fhidden_005f0(phoneDetails_jsp.java:322)
      org.apache.jsp.WEB_002dINF.views.phoneDetails_jsp._jspx_meth_form_005fform_005f0(phoneDetails_jsp.java:231)
      org.apache.jsp.WEB_002dINF.views.phoneDetails_jsp._jspService(phoneDetails_jsp.java:175)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
      org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>It says the error is do with my id but I cannot see an error with my code.</p>
  
  <pre><code>package org.jjm.test.model;
  
  import javax.persistence.Column;  
  import javax.persistence.Entity;  
  import javax.persistence.GeneratedValue;  
  import javax.persistence.GenerationType;  
  import javax.persistence.Id;  
  import javax.persistence.Table;  
  /* 
   * This is the model class and it corresponds to Phone table in the database 
   */  
  @Entity
  @Table(name="PHONE")
  public class Phone {
  
       @Id  
       @Column(name="id")  
       @GeneratedValue(strategy=GenerationType.IDENTITY)  
       int id;  
  
      @Column(name="phoneName")
      String phoneName;
  
      @Column(name="make")
      String make;
  
      @Column(name="price")
      double price;
  
      @Column(name="storage")
      String storage;
  
      @Column(name="camera")
      String camera;
  
  
      public Phone() {
          super();
      }
  
  
      public Phone(int i, String phoneName, String make, double price, String storage, String camera) {
          super();
          this.id = i;  
          this.phoneName = phoneName;
          this.make = make;
          this.price = price;
          this.storage = storage;
          this.camera = camera;
      }
  
      public int getId() {
          return id;
      }
  
  
      public void setId(int id) {
          this.id = id;
      }
  
  
      public String getPhoneName() {
          return phoneName;
      }
  
  
      public void setPhoneName(String phoneName) {
          this.phoneName = phoneName;
      }
  
  
      public String getMake() {
          return make;
      }
  
  
      public void setMake(String make) {
          this.make = make;
      }
  
  
      public double getPrice() {
          return price;
      }
  
  
      public void setPrice(double price) {
          this.price = price;
      }
  
  
      public String getStorage() {
          return storage;
      }
  
  
      public void setStorage(String storage) {
          this.storage = storage;
      }
  
  
      public String getCamera() {
          return camera;
      }
  
  
      public void setCamera(String camera) {
          this.camera = camera;
      }
  
  }
  </code></pre>
  
  <p>And this is where I am displaying the data </p>
  
  <pre><code>&lt;table&gt;  
          &lt;tr&gt;  
              &lt;th colspan="2"&gt;Add Phone&lt;/th&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;  
          &lt;form:hidden path="id" /&gt;  
            &lt;td&gt;&lt;form:label path="phoneName"&gt;Phone Name:&lt;/form:label&gt;&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="phoneName" size="30" maxlength="30"&gt;&lt;/form:input&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;  
                  &lt;td&gt;&lt;form:label path="make"&gt;Make:&lt;/form:label&gt;&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="make" size="30" maxlength="30"&gt;&lt;/form:input&gt;&lt;/td&gt;  
          &lt;/tr&gt;
          &lt;tr&gt;  
                  &lt;td&gt;&lt;form:label path="price"&gt;Price:&lt;/form:label&gt;&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="price" size="30" maxlength="30"&gt;&lt;/form:input&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;  
                  &lt;td&gt;&lt;form:label path="storage"&gt;Storage:&lt;/form:label&gt;&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="storage" size="30" maxlength="30"&gt;&lt;/form:input&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
          &lt;tr&gt;  
                  &lt;td&gt;&lt;form:label path="camera"&gt;Camera:&lt;/form:label&gt;&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="camera" size="30" maxlength="30"&gt;&lt;/form:input&gt;&lt;/td&gt;  
          &lt;/tr&gt;    
          &lt;tr&gt;  
              &lt;td colspan="2"&gt;&lt;input type="submit"  
                  class="blue-button" /&gt;&lt;/td&gt;  
          &lt;/tr&gt;  
      &lt;/table&gt;   
  </code></pre>