[DDC-2157] @HasLifecycleCallbacks does not fire events when set on @MappedSuperclass Created: 20/Nov/12  Updated: 27/Nov/12  Resolved: 27/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Frederic Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: HasLifecycleCallbacks, MappedSuperclass

Windows 7 x64 / Apache 2.4.2 / MySQL server 5.1.62

Attachments: File DDC2157Test.php    


I am unable to fire any of the "HasLifecycleCallbacks" when defined on a MappedSuperclass... (neither PreUpdate, PostUpdate,PrePersist, PostPersist and others)

I have even tried to put @ORM\HasLifecycleCallbacks on the child class with onPostRemove() on mapped => not working anymore

It only works when i put @ORM\HasLifecycleCallbacks and onPostRemove() both in child class "MyMappedTask"...

Is this a bug ..?

To reproduce :

namespace MyProject\Entity;

use Doctrine\ORM\Mapping as ORM;

 * @ORM\MappedSuperclass
 * @ORM\HasLifecycleCallbacks
class MyMappedTask
    * @ORM\PreRemove
    * @ORM\PostRemove
    * @ORM\PreUpdate
    * @ORM\PostUpdate
    public function onPostRemove()
        echo "here is never reached !";

 * @ORM\Entity(repositoryClass="MyProject\Repository\MyTaskRepository")
 * @ORM\Table()
class MyTask extends MyMappedTask


Comment by Fabio B. Silva [ 22/Nov/12 ]

code format

Comment by Fabio B. Silva [ 22/Nov/12 ]

Hi Frederic,

It failed for all events or just for @PostRemove ?

Could you try to add a failing test case ?


Comment by Frederic [ 23/Nov/12 ]

Hi Fabio,

1) Thank you for the "code" tag, i didn't know to do

2) Is fails with all the Annotations "Pre/Post*" ...

Did you try this test case ?

Thank you

Comment by Fabio B. Silva [ 23/Nov/12 ]

Hi Frederic,

Can't reproduce..
Could you try to change the attached test case and make it fails ?


Comment by Frederic [ 27/Nov/12 ]

Hi Fabio,

Thank you for the test case, it is OK !

I found what the problem was :
I use Symfony2 and i have one bundle with the @MappedSuperclass entity and its callbacks (@HasLifecycleCallbacks), and another bundle with the child class (@Entity/@Table).
In that case, you must register the 2 bundles on the mappings (config.yml) otherwise it fails.
(I only registered the bundle which contains the child class but was not enough for Doctrine to understand...)

I don't know if it is a bug on Symfony2, not well documented in this case...

Thank you for all

Generated at Fri Aug 22 07:59:51 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.