title: Spring Validation rejectValue for inherited fields
body: <p>I get Exception</p>
  
  <pre><code>org.springframework.beans.NotReadablePropertyException: Invalid property 'entries[0].reason' of bean class [my.company.data.SDROrder]: Bean property 'entries[0].reason' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
  </code></pre>
  
  <p>from the following code snippet:</p>
  
  <pre><code>Errors errors = new BeanPropertyBindingResult(new SDROrder(), "sdr");
  orderValidator.validate(order, errors);
  </code></pre>
  
  <p>for validator:</p>
  
  <pre><code>public class OrderValidator implements Validator
  {
  
      @Override
      public boolean supports(Class&lt;?&gt; clazz)
      {
          return Order.class.isAssignableFrom(clazz);
      }
  
      @Override
      public void validate(final Object target, final Errors errors)
      {
          errors.rejectValue("entries[0].reason", "Wrong Reason");
      }
  
  }
  </code></pre>
  
  <p>where we have such data hierarchy</p>
  
  <pre><code>public class Order
  {
      private List&lt;AbstractOrderEntry&gt; entries;
  
      public List&lt;AbstractOrderEntry&gt; getEntries()
      {
          return entries;
      }
  
      public void setEntries(List&lt;AbstractOrderEntry&gt; entries)
      {
          this.entries = entries;
      }
  }
  
  public class SDROrder extends Order
  {
  
  }
  
  public class AbstractOrderEntry
  {
  
  }
  
  
  public class SDROrderEntry extends AbstractOrderEntry
  {
      private String reason;
  
      public String getReason()
      {
          return reason;
      }
  
      public void setReason(String reason)
      {
          this.reason = reason;
      }
  }
  </code></pre>
  
  <p>Please see working example here: <a href="https://github.com/ZPetrovich/SpringValidationInheritance" rel="nofollow">here</a></p>
  
  <p><strong>Update 1</strong>: Just to clarify. The problem is I try to <em>rejectValue</em> on object that has Collection of objects where each element has specific attribute at Runtime but has not it at Compile time. Spring uses Bean's properties to resolve these fields and can't find inherited attribute. The question is: can I explain Spring to resolve inherited fields somehow?</p>