title: HasLifecycleCallbacks on a MappedSuperclass Entity
body: <p>I am trying to make an abstract class to extend my entity from in order to give them some basic functionalities such as automatic timestamp. </p>
  
  <p>So I created this abstract class:</p>
  
  <pre><code>/**
   * Class Model
   * @package AppBundle
   * @ORM\MappedSuperclass
   */
  abstract class Model 
  {
      /**
       * @var \DateTime $created_at
       *
       * @ORM\Column(type="datetime")
       */
      protected $created_at;
  
      /**
       * @var \DateTime $updated_at
       *
       * @ORM\Column(type="datetime")
       */
      protected $updated_at;
  
      /**
       *
       * @ORM\PrePersist
       * @ORM\PreUpdate
       */
      public function updatedTimestamps()
      {
          $this-&gt;setUpdatedAt(new \DateTime('now'));
  
          if ($this-&gt;getCreatedAt() == null) {
              $this-&gt;setCreatedAt(new \DateTime('now'));
          }
      }
  
     public function getUpdatedAt()
     {
         return $this-&gt;updated_at;
     }
  
     public function setUpdatedAt($updated_at)
     {
         $this-&gt;updated_at = $updated_at;
     }
  
     public function getCreatedAt()
     {
         return $this-&gt;created_at;
     }
  
     public function setCreatedAt($created_at)
     {
         $this-&gt;created_at = $created_at;
         return $this;
     }
  
  }
  </code></pre>
  
  <p>So now, I just need to extend my entity from this class:</p>
  
  <pre><code>class MyEntity extends Model 
  {
      ....
  }
  </code></pre>
  
  <p>However, if I want my timestamps to work, I still need to add the <code>@ORM\HasLifecycleCallbacks</code> on top of MyEntity class to trigger the <code>updatedTimestamps()</code> method on persist and on update. </p>
  
  <p>I tried to add the annotation on top of my super class but it does not work. </p>
  
  <p>Would someone have a solution to avoid to add the annotation on top of every entity? </p>
  
  <p>I just want to extend my superclass and that's it... </p>
  
  <p>Thank you for your answers and have a nice day!</p>