title: Can not save the foreign key in Spring form select tag
body: <p>I'm trying to save a form that has a foreign key in select tag but it's always null. When I use the inspect element it posts the selected id so I can't say it's problem with form. Can someone please help.
  Form</p>
  
  <pre><code>   &lt;form:select path="categoryId"&gt;
              &lt;form:option value="0" label="   -- Please Select --" /&gt;
              &lt;form:options items="${categoryList}"  itemValue="categoryId" itemLabel="categoryName"/&gt;
      &lt;/form:select&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>@RequestMapping(value = "product", method = RequestMethod.POST)
  public String addNewProduct(@ModelAttribute("product") Product product, Model model){
      model.addAttribute("product", product);
      purchaseOrderService.addProduct(product);
      return "categories";
  }
  </code></pre>
  
  <p>JPA</p>
  
  <pre><code>@Transactional(propagation = Propagation.REQUIRED)
      public boolean saveProduct(Product product) {
          EntityManager em = getEm();
          em.persist(product);
          return true;
      }
  </code></pre>
  
  <p>Persistence Object</p>
  
  <pre><code>@ManyToOne(fetch=FetchType.LAZY)
  @JoinColumn(name = "CATEGORY_ID", referencedColumnName = "CATEGORY_ID")
  private Category categoryId;
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/hibernate/exception/LockTimeoutException
  org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1328)
  org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
  org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:80)
  org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512)
  org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
  org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
  org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:394)
  org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
  $Proxy34.addProduct(Unknown Source)
  com.logicalideas.purchaseorder.ProductController.addNewProduct(ProductController.java:30)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:601)
  org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  </code></pre>
  
  <p>root cause</p>
  
  <p>java.lang.ClassNotFoundException: org.hibernate.exception.LockTimeoutException
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
      org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1328)
      org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
      org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:80)
      org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512)
      org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
      org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
      org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:394)
      org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      $Proxy34.addProduct(Unknown Source)
      com.logicalideas.purchaseorder.ProductController.addNewProduct(ProductController.java:30)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:601)
      org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
      org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
      org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
      org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)</p>
  
  <p>Many Thanks</p>