Symfony 4 with JMS.
The Parent class is associated with the OneToMany child class. In the repository, I get some parents, and some children (leftJoin with the condition). However, when trying to serialize Parents, JMS automatically gets all (!) Children from database, making additional queries to the database. How can I avoid this? Is there any option in the JMS config?
The only thing that comes to my mind is the VirtualProperty()
version, in which I will filter the children already inside the entity. But this is not very effective.
UPD.
I want to serialize this field, but not all child entities. Only satisfying the condition. In the repository I do ->leftJoin('p.children', 'c', 'WITH', 'c.foo = bar')
, but the serializer loads the elements that are not in the condition by separate requests. This is the problem