Skip to content

Loading…

DDC-1465: Fetching partial objects doesn't work if HINT_FORCE_PARTIAL_LOAD is not explicitly used #2094

Open
doctrinebot opened this Issue · 1 comment

2 participants

@doctrinebot

Jira issue originally created by user jpauli:

Using the DQL "partial" keyword is not enough to get a partial entity as a result.
The DQL hint HINTFORCE_PARTIALLOAD must be used as well.

$q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');
$r = $q->getResult() /** HYDRATE_OBJECT is the default hydration mode **/

Here, $r contains the full Entity, a SELECT * has been sent

$q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');
$q->setHint(Doctrine\ORM\Query::HINT*FORCE_PARTIAL*LOAD, 1);

$r = $q->getResult() /** HYDRATE_OBJECT is the default hydration mode **/

Here, $r contains only the selected fields, hence a true partial Entity

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.