mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Criteria in Many-To-Many relations broken if not manually accessing data before or EAGER used #5127
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @enekochan on GitHub (May 16, 2016).
I updated
doctrine/ormanddoctrine/dbaltodev-mastersome time ago to be able to use Criteria in Many-To-Many relations (with https://github.com/doctrine/doctrine2/pull/885). Suddenly today (now I'm not sure if it ever worked but I would say it did when using the same function in other places) I wasn't getting any objects in the collections of any of the sides. The only way it worked was If I added a bogus loop before the function with Criteria code was called (I suppose because the objects were being loaded beforehand and then they were available) or if I addedfetch="EAGER"in the ManyToMany relation.I'll try to resume my code bellow as best as I can. The function with the Criteria is
getActiveServicesinside theResourceclass. It's used to get the Services from the Resource that are available depending on their start/end date (both can have a value or be null at the same time: no dates, only start date, only end date or both dates specified).The action in the controller:
The model:
Resource class:
Service class:
@jaikdean commented on GitHub (May 17, 2016):
Criteriais broken in so many ways, I'm not sure why it's included in stable releases, it's totally unfinished.