title: How to get Eclipselink to fire JSR303 constraints in mapped super class?
body: <p>EclipsLink doesnt' seem to detect or fire JSR303 annotation constraints in a base class that is the mapped super class of an entity during a persist() operation. </p>
  
  <p>For example: </p>
  
  <pre><code>public Base
  {
      @NotNull
      private Integer id; 
  
      private String recordName; 
  
      //other stuff (getters etc) 
  }
  </code></pre>
  
  <p>and then </p>
  
  <pre><code>public class MyObject
      extends Base
  {
       //stuff...
  }
  </code></pre>
  
  <p>and then: </p>
  
  <pre><code>&lt;mapped-superclass class="Base"&gt;
      &lt;attributes&gt;
           &lt;basic name="recordName"&gt;
               &lt;column name = "NAME" /&gt;
           &lt;/basic&gt;
      &lt;/attributes&gt;
  &lt;/mapped-superclass&gt; 
  </code></pre>
  
  <p>and finally: </p>
  
  <pre><code>&lt;entity class="MyObject"&gt;
      &lt;table name="TheTable"/&gt;
          &lt;attributes&gt;
              &lt;id name="id"&gt;
                  &lt;column name="recordId" /&gt;
              &lt;/id&gt;
          &lt;/attributes&gt;
  &lt;/entity&gt;     
  </code></pre>
  
  <p>Some other relevant parameters: </p>
  
  <ul>
  <li>using jpa 2.1 -- specifically eclipslink 2.6.2 and 2.6.3</li>
  <li>I am integration testing - so java se  (and spock)</li>
  <li>JDK 1.8.77</li>
  <li>I do have hibernate validator in my classpath (org.hibernate:hibernate-validator:5.2.4.Final) </li>
  <li>If I write a test fixture and use validitor.validate() directly (no jpa or persist) hibernate validator works as expected.</li>
  <li>I do NOT use JPA annotations and only use ORM xml to declare entity mappings. </li>
  <li>I do use JSR303 annotations to mark attrs and props with constraints. </li>
  <li>persistence.xml is marked with validation "AUTO" and many variations of properties like javax.persistence.validation.group.pre-persist with FQDN of marker interfaces have been tried.</li>
  </ul>
  
  <p>As mentioned, calling em.persist(myObjectInst) will not fire any 303 annotations added to class 'Base'.   </p>
  
  <p><strong>* Is there some tuning parameter or switch I can tinker with that will make this work? *</strong></p>
  
  <p>Note:   I did a deep-dive debug on this and can see that org.eclipse.persistence.internal.jpa.metadata.beanvalidation.BeanValidationHelper.detectConstraints() does NOT look at any parent classes for JSR303 annotations.   It seems to only want to look at the specific entity class.     I'd hazard to guess that if I moved my JSR303 constraints to the concrete (or entity class); it may just work.   But then I would loose the extension and mapped super class stuff.  So what fun is that?</p>
  
  <p><strong>UPDATE</strong>
  Looks like issue in EclipseLink 2.6.x.    See here ( <a href="https://www.eclipse.org/forums/index.php?t=msg&amp;th=1077658&amp;goto=1732842&amp;#msg_1732842" rel="nofollow">https://www.eclipse.org/forums/index.php?t=msg&amp;th=1077658&amp;goto=1732842&amp;#msg_1732842</a> )  for more details.   </p>