DDC-2484: Lazy loaded associated entities do not trigger the postLoad event #3203

doctrinebot opened this Issue Jun 3, 2013 · 3 comments

2 participants


Jira issue originally created by user tom_anderson:

An entity retrieved with $entity = $em->find will correctly trigger the postLoad event but an entity associated with that entity $association = $entity->association which is lazy loaded will retrieve and return the associated entity without triggering postLoad. Eager loading does follow the lifecycle path of triggering postLoad.

Functional Test:


Comment created by @FabioBatSilva:

Hi Tom,

You CANNOT check the entity class by using get*class, doctrine uses the pattern proxy to delay the load from database.

Then $args->getEntity() might be a different class that extends your entity
In this case you should always check using instanceof :

$entity = $args->getEntity();

if ($entity instanceof DDC2484_Car) {

Also when you try to load the same entity more than once :


The entity will be cached at the first time, triggering onLoad just once.

It means that the entity will be always the same instance,
it's not loaded from database untill you clean up the entity manager.

assertSame($eagerDriver->getCar(), $lazyDriver->getCar());


Comment created by @beberlei:

Wrong assumption using get_class


Issue was closed with resolution "Invalid"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment