You are filtering a fetch-joined association: that will break hydration. We
never manager to add error messages for this type of query, since that
would be a BC break, but the DQL is invalid.

On 23 Aug 2017 9:15 AM, "Andreas Goetz" <[email protected]> wrote:

I have a simple ER diagram with entities and properties 1:n. Retrieving an
entity by its uuid will also obtain all it's properties:

$dql = 'SELECT a, p
FROM Volkszaehler\Model\Entity a
LEFT JOIN a.properties p
WHERE a.uuid = :uuid';

$q = $em->createQuery($dql)
->setParameter('uuid', $uuid);

$entity = $q->getSingleResult();

var_dump($entity->getProperties()); // all properties

Now, for some cases I'm identifying the entity by name (and make sure it's
of public type), obtain the uuid and then pass it through the above query:

$dql = 'SELECT e, p
FROM Volkszaehler\Model\Entity e
LEFT JOIN e.properties p
JOIN e.properties public
WHERE p.key = :key
AND p.value = :name
AND public.key = :key2
AND public.value = 1';

$q = $this->em->createQuery($dql)
->setParameter('key', 'title')
->setParameter('name', $name)
->setParameter('key2', 'public');

$entity = $q->getSingleResult();

Now, calling the first query with the UUID, only a single property is
returned but not all of them as expected:

var_dump($entity->getProperties()); // only 'title' property is shown

SQL trace shows that the exact same queries are executed, only in the 2nd
case the properties apparently are swallowed by the ORM.

Any idea what's wrong here?

Thanks,
Andreas

-- 
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to