DDC-2667: Collections for OneToMany&ManyToMany relations generated by entity's repository #3346

Closed
opened 2026-01-22 14:18:24 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Sep 10, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user morgen:

The ArrayCollection object for OneToMany or ManyToMany relations is
generated by Doctrine. There is no ability within entity to get acces to it's repository.

This would be very useful nice to specify additionally the method in entity's repository, which could generate collection for the given entity.

An example annotation
/*** @ORM\OneToMany(targetEntity="Person", repositoryMethod="findAllowedPersons") **/
private $persons;

Advantages

  • optimized query for collection (or even php script)
  • generation of collections can depends on external parameters or internal fields

Problems

  • for such collections adding/removing of elements is not allowed or has be limited
Originally created by @doctrinebot on GitHub (Sep 10, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user morgen: The ArrayCollection object for OneToMany or ManyToMany relations is generated by Doctrine. There is no ability within entity to get acces to it's repository. This would be very useful nice to specify additionally the method in entity's repository, which could generate collection for the given entity. An example annotation /**\* @ORM\OneToMany(targetEntity="Person", repositoryMethod="findAllowedPersons") **/ private $persons; Advantages - optimized query for collection (or even php script) - generation of collections can depends on external parameters or internal fields Problems - for such collections adding/removing of elements is not allowed or has be limited
admin added the Improvement label 2026-01-22 14:18:24 +01:00
admin closed this issue 2026-01-22 14:18:24 +01:00
Author
Owner

@beberlei commented on GitHub (Feb 18, 2020):

The solution here is to call $personRepository->findAllowedPersonsBy($other) yourself in your code.

@beberlei commented on GitHub (Feb 18, 2020): The solution here is to call `$personRepository->findAllowedPersonsBy($other)` yourself in your code.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3346