title: Validator for MethodArgumentNotValidException only handles constraint of same type
body: <p>I'm trying to validate my form against constraints set on my bean. Spring-MVC version i am using is 3.2.4. The problem is that default Spring validator does not validate all constraints; only the ones that are of the same type.</p>
  
  <p>I have the following controller code:</p>
  
  <pre><code>@Controller
  @SessionAttributes()
  public class FormSubmitController {
  
      @RequestMapping(value = "/saveForm", method = RequestMethod.POST)
      @ResponseBody
      public ModelMap saveForm(@Valid @RequestBody Form form, HttpSession session) {
          session.setAttribute("form", form);
          ModelMap map = new ModelMap();
          map.addAttribute("hasErrors", false);
          return map;
      }
  }
  </code></pre>
  
  <p>and the following bean:</p>
  
  <pre><code>public class Form implements IForm, Serializable {
  
      @NotNull(message = "Category should not be empty")
      protected String category;
      @NotNull(message = "Sub-Category should not be empty")
      protected String subCategory;
  
      @Size(min=0, message="Firstname should not be empty")
      protected String firstName;
      @Size(min=0, message="Lastname should not be empty")
      protected String lastName;
  
     @Pattern(regexp="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\\d\\d$",     message="Date of birth should be in dd-mm-jjjj format")
      protected String dateOfBirth;
  
      //getters and setters
  }
  </code></pre>
  
  <p>The handler for MethodArgumentNotValidException looks like this:</p>
  
  <pre><code>@ControllerAdvice
  public class FormExceptionController {
  
      @ExceptionHandler(MethodArgumentNotValidException.class)
      @ResponseStatus(HttpStatus.BAD_REQUEST)
      @ResponseBody
      public ModelMap     handleMethodArgumentNotValidException(MethodArgumentNotValidException error) {
          List&lt;FieldError&gt; errors = error.getBindingResult().getFieldErrors();
          ModelMap map = new ModelMap();
          ModelMap errorMap = new ModelMap();
          map.addAttribute("hasErrors", true);
          for (FieldError fieldError : errors) {
              errorMap.addAttribute(fieldError.getField(), fieldError.getDefaultMessage());
          }
          map.addAttribute("bindingErrors", errorMap);
          return map;
      }
  }
  </code></pre>
  
  <p>So, an empty form results in the first two error messages.
  The firts two properties of the form filled results in the third and fourth error messages.</p>
  
  <p>Only when i use the same contraint type (i.e. NotNull) for all properties on my bean it will return all error messages.</p>
  
  <p>What can be wrong here?</p>