Jira issue originally created by user romanb:
A new fetch mode EXTRA_LAZY for one-to-many and many-to-many associations could have the following effects on PersistentCollection methods:
This mode would usually be useful for (potentially) large collections.
We need to work out concrete use-case examples and implementation proposals before implementation.
The semantics of the mentioned methods with EXTRA_LAZY need to be carefully worked out, i.e. what happens to already managed instances in case of the remove operations and stuff like that.
Comment created by mjh_ca:
Wow, this is an excellent idea. I was just thinking how it is unfortunate that there aren't ways to manipulate large collections without resorting to DQL.
If nothing else, having access to a count() would be particularly great.
Comment created by romanb:
@Marc: You might then also be interested in a related ticket: http://www.doctrine-project.org/jira/browse/[DDC-547](http://www.doctrine-project.org/jira/browse/DDC-547)
This would basically allow you to craft special implementations that inherit from PersistentCollection that are "optimized" in some way for a specific association (i.e. write your own custom SQL query when count() is invoked). Your wrapper class is then used by Doctrine instead of the default one, thats the idea. Of course implementing such a custom collection and overriding methods needs to be done carefully to fully preserve the public API contract (PersistentCollection wrappers are supposed to be "invisible" to the user after all). So this would be an advanced feature. EXTRA_LAZY I think is a pretty easy feature, accessible for all users with no further knowledge required. It just means that the collection delays initialization even more, whereever possible, which is a good thing for large collections which you normally don't really want to load, yet it allows you to use the normal OO API of your domain model without resorting to special (DQL) queries.
Oh, I just saw you're watching that one already :) sorry for the noise
Rescheduling for beta3 as we're running out of time.
Comment created by @beberlei:
Additional features that have been requested by users:
I don't know about the remove() and removeElement() operations, would they register with the UoW or directly execute the DELETE or UPDATE stements themselves?
Pushing back to beta4.
Moved to 2.1 due to lack of time for larger new stuff for 2.0.
https://github.com/doctrine/doctrine2/tree/[DDC-546](http://www.doctrine-project.org/jira/browse/DDC-546) first prototype implementation with tests.
Necessary for later scheduling (only make sense when persisting keys):
I updated the branch to include XML, YAML support, refactored a little bit and added contains() support.
The RemoveElement() support should be put into its own ticket that relates to the EntityManager#link() / EntityManager#unlink() functionality.
Issue was closed with resolution "Fixed"
Usage would be inside a @OneToMany or @ManyToMany definition set