DDC-75: Lifecycle Events are not inherited #92

Closed
opened 2026-01-22 12:26:46 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 29, 2009).

Jira issue originally created by user nicokaiser:

When inheriting from classes that have Lifecycle Events (with @HasLifecycleCallbacks), these events are not called anymore.

  • Create an entity, let's say "User"
  • Set up a lifecycle event like "PrePersist"
  • Instantiate a new User and call em->persist(...)
  • The PrePersist function gets called.
  • Now set up @InheritanceType etc. and create a subclass ("SubUser") which can extend User (the class body can be empty)
  • Instantiate a new SubUser and call em->persist(...)
  • The PrePersist function (inherited from User!) does not get called.
Originally created by @doctrinebot on GitHub (Oct 29, 2009). Jira issue originally created by user nicokaiser: When inheriting from classes that have Lifecycle Events (with @HasLifecycleCallbacks), these events are not called anymore. - Create an entity, let's say "User" - Set up a lifecycle event like "PrePersist" - Instantiate a new User and call em->persist(...) - The PrePersist function gets called. - Now set up @InheritanceType etc. and create a subclass ("SubUser") which can extend User (the class body can be empty) - Instantiate a new SubUser and call em->persist(...) - The PrePersist function (inherited from User!) **does not get called**.
admin added the Bug label 2026-01-22 12:26:46 +01:00
admin closed this issue 2026-01-22 12:26:46 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 29, 2009):

Comment created by nicokaiser:

When adding "@HasLifecycleCallbacks" to the subclass' header docblock, event inheritance works again.

(See DDC-73 about removing @HasLifecycleCallbacks completely?)

@doctrinebot commented on GitHub (Oct 29, 2009): Comment created by nicokaiser: When adding "@HasLifecycleCallbacks" to the subclass' header docblock, event inheritance works again. (See [DDC-73](http://www.doctrine-project.org/jira/browse/DDC-73) about removing @HasLifecycleCallbacks completely?)
Author
Owner

@doctrinebot commented on GitHub (Feb 7, 2010):

Comment created by @beberlei:

Not an issue, closed.

@doctrinebot commented on GitHub (Feb 7, 2010): Comment created by @beberlei: Not an issue, closed.
Author
Owner

@doctrinebot commented on GitHub (Feb 7, 2010):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Feb 7, 2010): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Feb 10, 2010):

Comment created by romanb:

This should now work without the need for specifying @HasLifecycleCallbacks on the child entity. Of course, if the child entity defines new callback methods, it is still needed. See DDC-311.

@doctrinebot commented on GitHub (Feb 10, 2010): Comment created by romanb: This should now work without the need for specifying @HasLifecycleCallbacks on the child entity. Of course, if the child entity defines new callback methods, it is still needed. See [DDC-311](http://www.doctrine-project.org/jira/browse/DDC-311).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#92