[DDC-128] Consider adding EntityManager#link/unlink methods for direct association manipulation Created: 07/Nov/09 Updated: 24/Feb/15
|Project:||Doctrine 2 - ORM|
|Reporter:||Roman S. Borschel||Assignee:||Roman S. Borschel|
A problem when working with collection-valued associations is that almost all operations except add($obj) require the collection to become initialized in order for the operation to be performed properly. While this is all correct and beautiful OO-wise it may be problematic at times with regards to performance. Hence we might want to consider to provide some convenient methods along the lines of link/unlink (name suggestions?) which allow more direct, less OO collection manipulation. Such methods obviously would bypass the normal object lifecycle and the changes done through these methods will not be reflected in the in-memory objects and collections, unless the user keeps them in-synch himself.
|Comment by Benjamin Eberlei [ 11/Dec/09 ]|
Regarding the naming, i like link/unlink.
|Comment by Roman S. Borschel [ 17/Dec/09 ]|
What do you mean by "handled by UnitOfWork commit" ? Whether the SQL is "scheduled" or executed immediately? Interesting question.
As far as usage is concerned, I currently imagine it as follows:
"What happens if: an entity is linked with a collection, although they are already connected."
Probably an SQL error which results in an exception from the driver. Depends on the database constraints though.
"What happens if: an entity is unlinked from a collection it is not in"
Probably nothing, at least not from the SQL side. An exception could be thrown from Doctrine itself if the update affected 0 rows.
Thanks for these initial questions. Thats definitely food for thought. Keep it coming.
|Comment by Roman S. Borschel [ 26/Aug/10 ]|