Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Support priming references on non-hydrated results #468

kevou84 opened this Issue · 7 comments

4 participants


Hi all,

I'm trying to get raw results when using prime(true) option on referenced objects like this :

    $dm = $this->get('doctrine_mongodb')->getManager();
    $qb = $dm->createQueryBuilder('MyBundle:Document');
    $query = $qb->hydrate(false)->getQuery();
    // 2 larger queries are performed eagerly to fetch documents and documentSimpleReferences
    $results = $query->execute();

It triggers the following error message :

Warning: get_class() expects parameter 1 to be object, array given in C:\Users...\sf\vendor\doctrine\mongodb-odm\lib\Doctrine\ODM\MongoDB\Persisters\DocumentPersister.php line 522

It seems that hydration should occur before prime and is globally disabled by hydrate(false) option... Or something like that... Looks like you had issues upon this matter before : #300

DocumentPersister:primeCollection() works fine if hydration enabled, but I'd like a flat array as result...

Thanks for your feedback,


I didn't intend to allow this functionality. I will throw an exception in this case.


I felt it would've been interesting to get results as raw data in array while prime option allowed to retrieve referenced data as well... Do you see something wrong with this ?


I don't see anything wrong with it, it's just not a supported feature right now.


Alright, is there a way to declare this as a feature request instead of issue ?


Have just come across this issue. As of today, is there any way to get an array with referenced data?


This feature has not been implemented.


I renamed this issue and applied the new-feature tag for tracking.

Recent changes in #717 should avoid any errors/exceptions, as the Query class will only attempt priming if hydration is enabled (even if priming was specified in using the Builder).

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.