title: Spring MVC with JPA databinding
body: <p>My problem is with having Spring bind the data I get from a form to a JPA entity.  The wierd part is, it works just fine if I do not look at the BindingResults.  The BindingResults says there were binding errors when an empty string is passed in for the field graduation, but I know it does bind them correctly because when I don't check Hibernate updates the database perfectly.  Is there a way to not have to write logic to circumnavigate the wrongly fired binding errors?</p>
  
  <pre><code>    @Entity
      @Table(name="child")
      public class Child {
  
          @Id
          @Column(name="id")
          private Integer childId;
  
          @ManyToOne(fetch=FetchType.EAGER )
          @JoinColumn(name="house", referencedColumnName="house")
          private House house;
  
          @NotNull()
          @Past()
          @Column(name="birthday")
          private Date birthday;
  
          @Column(name="graduation_date")
          private Date graduationDay;
  
      }
  </code></pre>
  
  <p>I have tried the following lines in a property editor to no avail</p>
  
  <pre><code>    SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy");
      registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
  </code></pre>
  
  <p>Here is the method signature for the controller method Handling the request</p>
  
  <pre><code>    @Controller
      @SessionAttributes(value="child")
      @RequestMapping(value="child")
      public class ChildModController {
  
      @RequestMapping(value="save-child.do", params="update", method = RequestMethod.POST)
      public @ResponseBody Map&lt;String,?&gt; updateChild(
  
          HttpServletRequest request,
          @Valid @ModelAttribute(value="child")Child child,
          BindingResult results)
      }
  </code></pre>
  
  <p>This is what I get from the BindingResult class as a message</p>
  
  <pre><code>    09:01:36.006 [http-thread-pool-28081(5)] INFO  simple - Found fieldError: graduationDay, 
      Failed to convert property value of type java.lang.String to required type java.util.Date for property graduationDay; 
      nested exception is org.springframework.core.convert.ConversionFailedException: 
      Failed to convert from type java.lang.String to type @javax.persistence.Column java.util.Date for value '; 
      nested exception is java.lang.IllegalArgumentException
  </code></pre>