title: Add a Custom message for the Unique Constraints in hibernate
body: <pre><code>@Entity @Table(name="users",uniqueConstraints = {@UniqueConstraint(columnNames = {"email"})})
  public class User implements Serializable {
      @Column(unique = true,name = "email")
      @NotNull(message = "{NotNull.email}")
      @Email(message = "{Pattern.email}")
      @Size(min=10, max=50)
      private String email;
  
      public String getEmail() { return email; }
      public void setEmail(String email) { this.email = email; } 
  }
  </code></pre>
  
  <p>I have the message.properties file which is working fine</p>
  
  <pre><code> NotNull.email = Email is required
  
   Pattern.email = Enter a valid email address
  </code></pre>
  
  <p>can i add another field in the message.properties file like </p>
  
  <pre><code> Unique.email = Email already exits 
  </code></pre>
  
  <p>and give this Unique.email to the</p>
  
  <pre><code>@Column(unique = true,name = "email",message="{Unique.email}")
  </code></pre>
  
  <p>I know, we cannot keep message="{Unique.email}" in the above line.</p>
  
  <p>but how can we give "Unique.email" to the above column in order to get the custom error message</p>
  
  <p>??</p>
  
  <p>Thanks in advance</p>