title: How to override attributes in validate annotation in Hibernate?
body: <p>I have custom annotation, like this:</p>
  
  <pre><code>@Documented
  @Constraint(validatedBy = MyValidator.class)
  @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
  @Retention(RetentionPolicy.RUNTIME)
  public @interface MyAnnotation {
  
      String message() default "message";
  
      Class&lt;?&gt;[] groups() default {};
  
      Class&lt;? extends Payload&gt;[] payload() default {};
  }
  </code></pre>
  
  <p>And validator in order to validate stuff:</p>
  
  <pre><code>public class MyValidator implements ConstraintValidator&lt;MyAnnotation, String&gt; {
  
      @Override
      public void initialize(MyAnnotation myAnnotation) {
      }
  
      @Override
      public boolean isValid(String value, ConstraintValidatorContext context) {
          ConstraintValidatorContextImpl con = (ConstraintValidatorContextImpl)context;
  
          String diff = getDiff(value, cleanForHTMLContext(value));
          if(diff.isEmpty()){
              return true;
          }
          return false;
      }
  
      private cleanForHTMLContext(String value) {
         // Some stuff to clean up value
      }
  
      private String getDiff(String value, String cleanedValue) {
         // Some stuff to compare values
      }
  }
  </code></pre>
  
  <p>My goal is to add <strong>"diff" to annotation attributes</strong>, then later have possibility to resolve message by key and attributes from ResourceBundle.</p>
  
  <p>As example: when use type invalid date, it should see the folloiwng message:</p>
  
  <p><strong>Data invalid, because contain this text: {diff}.</strong> Where diff will be runtime comparison result between two strings that will be evaluated in <strong>isValid()</strong> method.</p>
  
  <p>I have tried to ovverrite value from map arguments like this:</p>
  
  <pre><code>ConstraintValidatorContextImpl con = (ConstraintValidatorContextImpl)context;
  con.getConstraintDescriptor().getAttributes().put("diff", value);
  </code></pre>
  
  <p>But unfortunatly I got exception regarding unmodifible map that are created in <code>ConstraintDescriptorImpl</code></p>
  
  <p>Is any other possibility to add custom attributes that will be resolved then with error code?</p>