[DDC-1210] if I call computeAssociationChanges twice it will add this collection twice Created: 16/Jun/11  Updated: 15/Oct/11  Resolved: 15/Oct/11

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

Type: Bug Priority: Major
Reporter: Konstantin Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

For example, if I call computeChangeSets() by myself before calling flush() it will result in errors.



 Comments   
Comment by Benjamin Eberlei [ 16/Jun/11 ]

The API is marked as internal.

Comment by Konstantin [ 16/Jun/11 ]

Method computeChangeSets is not marked as internal (https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L500).

If it is then how can I find out was entity changed or not? I need to know it before making other changes (update time, updater name and etc.).

Comment by Konstantin [ 16/Jun/11 ]

Another example of using computeAssociationChanges via computeChangeSet described here:
http://www.doctrine-project.org/docs/orm/2.0/en/reference/events.html

So I can't use this example because of the problem with collections. onFlush rises AFTER computeChangeSets and BEFORE any changes, so if I call computeChangeSets inside onFlush event it will break commit (twice insert of equal index).

Comment by Benjamin Eberlei [ 15/Oct/11 ]

The documentation was a bit unclear about this.

The computeChangeSet API is internal. Its only allowed to be called for new entities after they have been persisted inside the onFlush.

You can use "getEntityChangeSet()" inside preUpdate for example to get all the changes that are done.

Generated at Thu Jul 31 07:49:38 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.