title: Hibernate validator doesn't work
body: <p>I'm using Hibernate validator with Hibernate and Spring, but it seems that validations don't work. When I don't enter a String or enter a String of 1 character (which is not between <code>min=4</code> and <code>max=20</code>) is not showing any error and therefore saves in the table. What am I missing?</p>
  
  <pre><code>package dao;
  
  import java.util.Date;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import javax.persistence.Temporal;
  import javax.persistence.TemporalType;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Size;
  
  @Entity
  @Table(name="etudiant")
  public class Etudiant {
  
      @Id
      @Column(name="ID_ETUDIANT")
      @GeneratedValue
      private Long idEtudiant;
  
      @Column(name="NOM")
      @Size (min=4, max=20)
      private String nom;
  
      @Size(min=4, max=20, message="nom doit etre entre 4 et 20 svp..")
      @Column(name="PRENOM")
      private String prenom;
  
      @Column(name="DATE_NAISSANCE")
      @Temporal(TemporalType.DATE)
      private Date dateNaissance;
  
      @NotNull
      @Column(name="EMAIL")
      private String email;
  
      public Etudiant() {
          super();
      }
  
      public Long getIdEtudiant() {
          return idEtudiant;
      }
  
      public void setIdEtudiant(Long idEtudiant) {
          this.idEtudiant = idEtudiant;
      }
  
      public Etudiant(String nom, String prenom, Date dateNaissance, String email) {
          super();
          this.nom = nom;
          this.prenom = prenom;
          this.dateNaissance = dateNaissance;
          this.email = email;
      }
  
      public String getNom() {
          return nom;
      }
  
      public void setNom(String nom) {
          this.nom = nom;
      }
  
      public String getPrenom() {
          return prenom;
      }
  
      public void setPrenom(String prenom) {
          this.prenom = prenom;
      }
  
      public Date getDateNaissance() {
          return dateNaissance;
      }
  
      public void setDateNaissance(Date dateNaissance) {
          this.dateNaissance = dateNaissance;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping(value="save",method=RequestMethod.POST)
  public String  saveetudient(Model md,
          @Valid @ModelAttribute("etudiant") Etudiant et, 
          BindingResult res) {
      if (res.hasErrors()) {
          List &lt;Etudiant&gt; ets=service.listeEtudiants();
          md.addAttribute("etudiants",ets);
          return "etudiant1";
      }
      else {
          service.addEtudiant(et);
          List &lt;Etudiant&gt; ets=service.listeEtudiants();
          md.addAttribute("etudiants",ets);
          return "etudiant1";
      }
  }
  </code></pre>
  
  <p>In JSP I put this line to show errors:</p>
  
  <pre><code>&lt;form action="save" method="post"&gt;
  
    &lt;table border="1" width="500" bgcolor="grey"&gt;
  
   &lt;tr&gt; 
  
   &lt;th&gt;Nom &lt;/th&gt;
  &lt;th&gt;Prenom &lt;/th&gt;
  &lt;th&gt; Date de naissance&lt;/th&gt;
  &lt;th&gt;Email &lt;/th&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt; 
   &lt;td&gt;  &lt;input type="text" name="nom" &gt;   &lt;/td&gt;
   &lt;td&gt; &lt;input type="text" name="prenom" &gt;  &lt;/td&gt;
   &lt;td&gt;  &lt;input type="text" name="dateNaissance" &gt; &lt;/td&gt;
    &lt;td&gt; &lt;input type="text" name="email" &gt;  &lt;/td&gt;
   &lt;/tr&gt;
  
   &lt;/table&gt;  &lt;br&gt;
   &lt;input type="submit" value="ajouter"&gt;
  
   &lt;sform:errors path="etudiant.*"/&gt;
   &lt;sform:errors path="prenom"/&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>XML file configuration :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:context="http://www.springframework.org/schema/context"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://www.springframework.org/schema/aop
  http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context.xsd
  http://www.springframework.org/schema/mvc 
  http://www.springframework.org/schema/mvc/spring-mvc.xsd "&gt;
  
  &lt;context:component-scan base-package="controller"/&gt;
  &lt;mvc:annotation-driven/&gt;
  
  &lt;bean class="dao.DaoEtudiantImpl" name="daoetud"&gt;&lt;/bean&gt;
  
  &lt;bean class="service.EtudiantMetierImpl" name="servetud"&gt;
    &lt;property name="dao"  ref="daoetud"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
    &lt;bean id="viewResolver"        
  class="org.springframework.web.servlet.view.InternalResourceViewResolver" &gt;
  &lt;property name="prefix"&gt;
      &lt;value&gt;/WEB-INF/&lt;/value&gt;
   &lt;/property&gt;
   &lt;property name="suffix"&gt;
    &lt;value&gt;.jsp&lt;/value&gt;
  
   &lt;/property&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>