title: @PrePersist with entity inheritance
body: <p>I'm having some problems with inheritance and the <strong>@PrePersist</strong> annotation.
  My source code looks like the following:</p>
  
  <p>_the 'base' class with the annotated updateDates() method:</p>
  
  <pre><code>@javax.persistence.Entity
  @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
  public class Base implements Serializable{
  
      ...
  
      @Id
      @GeneratedValue
      protected Long id;
      ...
      @Column(nullable=false)
      @Temporal(TemporalType.TIMESTAMP)
      private Date creationDate;
      @Column(nullable=false)
      @Temporal(TemporalType.TIMESTAMP)
      private Date lastModificationDate;
      ...
      public Date getCreationDate() {
          return creationDate;
      }
      public void setCreationDate(Date creationDate) {
          this.creationDate = creationDate;
      }
      public Date getLastModificationDate() {
          return lastModificationDate;
      }
      public void setLastModificationDate(Date lastModificationDate) {
          this.lastModificationDate = lastModificationDate;
      }
      ...
      @PrePersist
      protected void updateDates() {
        if (creationDate == null) {
          creationDate = new Date();
        }
        lastModificationDate = new Date();
      }
  }
  </code></pre>
  
  <p>_ now the 'Child' class that should inherit all methods <strong><em>"and annotations"</em></strong> from the base class:</p>
  
  <pre><code>@javax.persistence.Entity
  @NamedQueries({
      @NamedQuery(name=Sensor.QUERY_FIND_ALL, query="SELECT s FROM Sensor s")
  })
  public class Sensor extends Entity {
      ...
      // additional attributes
      @Column(nullable=false)
      protected String value;
      ...
      // additional getters, setters
      ...
  }
  </code></pre>
  
  <p>If I store/persist instances of the Base class to the database, everything works fine. The dates are getting updated.
  But now, if I want to persist a child instance, the database throws the following exception:</p>
  
  <pre><code>MySQLIntegrityConstraintViolationException: Column 'CREATIONDATE' cannot be null
  </code></pre>
  
  <p>So, in my opinion, this is caused because in Child the method "@PrePersist protected void updateDates()" is not called/invoked before persisting the instances to the database.</p>
  
  <p>What is wrong with my code?</p>