DDC-140: hydrateAdd does not update originalEntityData #174

Closed
opened 2026-01-22 12:29:37 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 12, 2009).

Jira issue originally created by user rickdt:

Step to reproduce :

  1. create Two entity with bidirectionnal oneToMany association.

ex :
Client (id, name | emails)
Email(id, email, client_id | clients)

Email is the owning side.

  1. Do a query using both entity
    $qb->select('client', 'emails')
    ->from('Client', 'client')
    ->leftJoin('client.emails', 'emails')
    ->where(...);
    $query = $qb->getQuery();
    $client = $query->getSingleResult();
    $em->flush();

  2. If you set listener on onUpdate event, you will notice that the Email entity is updated.

I looked deep into UnitOfWork and ObjectHydrator and I see that the originalEntityData (used to calculate modified data before update) is saved before the manyToMany relation is set by a call to hydrateAdd (ObjectHydrator line 322)

In my previously bug report : DDC-139, I tought I had to check if an entity have changed in the onUpdate. Now, I see that entity are wrongly updated.

I can provide a more detailled test case if you need more informations.

Thank you

Originally created by @doctrinebot on GitHub (Nov 12, 2009). Jira issue originally created by user rickdt: Step to reproduce : 1) create Two entity with bidirectionnal oneToMany association. ex : Client (id, name | emails) Email(id, email, client_id | clients) Email is the owning side. 2) Do a query using both entity $qb->select('client', 'emails') ->from('Client', 'client') ->leftJoin('client.emails', 'emails') ->where(...); $query = $qb->getQuery(); $client = $query->getSingleResult(); $em->flush(); 3) If you set listener on onUpdate event, you will notice that the Email entity is updated. I looked deep into UnitOfWork and ObjectHydrator and I see that the originalEntityData (used to calculate modified data before update) is saved before the manyToMany relation is set by a call to hydrateAdd (ObjectHydrator line 322) In my previously bug report : [DDC-139](http://www.doctrine-project.org/jira/browse/DDC-139), I tought I had to check if an entity have changed in the onUpdate. Now, I see that entity are wrongly updated. I can provide a more detailled test case if you need more informations. Thank you
admin added the Bug label 2026-01-22 12:29:37 +01:00
admin closed this issue 2026-01-22 12:29:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 10, 2009):

Comment created by romanb:

Can you check whether this was fixed by DDC-171 already?

If not where is the difference?

@doctrinebot commented on GitHub (Dec 10, 2009): Comment created by romanb: Can you check whether this was fixed by [DDC-171](http://www.doctrine-project.org/jira/browse/DDC-171) already? If not where is the difference?
Author
Owner

@doctrinebot commented on GitHub (Dec 10, 2009):

Comment created by rickdt:

Fixed by DDC-171

@doctrinebot commented on GitHub (Dec 10, 2009): Comment created by rickdt: Fixed by [DDC-171](http://www.doctrine-project.org/jira/browse/DDC-171)
Author
Owner

@doctrinebot commented on GitHub (Dec 10, 2009):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 10, 2009): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#174