Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
Symfony2 DoctrineMongoDBBundle: Getting empty result after creating Repository classes

Sorry for the long question, but i think its simple for experienced symfony and mongodb developer. Q: If i generate repository class, all repository findAll(), findBy(), findOneBy(), findBy*() gets failed. Why it fails? below my composer state.

"require":
 {
        "php": ">=5.3.9",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.11.3",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "doctrine/mongodb-odm": "^1.1",
        "doctrine/mongodb-odm-bundle": "^3.2"
    }

Controller method as below

     /**
     * @Route("survey/{token}", name="survey_index")
     */
    public function indexAction($token){
        // if i remove repository, below query gives perfect result.
        $survey = $this->get('doctrine_mongodb')
        ->getRepository('CoreBundle:Survey')->findAll();

        return $this->render('CoreBundle:Survey:index.html.twig',array('survey'=>$survey));
    }

Document class as below

namespace CoreBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
 * @ODM\Document(collection="survey_master")
 * @ODM\Document(repositoryClass="CoreBundle\Repository\SurveyRepository")
 */
class Survey {

    /**
     * @ODM\Id
     */
    protected $id;

    /**
     * @ODM\Field(type="string")
     */
    protected $name;

// setters and getters below
}

If I remove

* @ODM\Document(repositoryClass="CoreBundle\Repository\SurveyRepository")

and perform cache clear, everything works perfect.

SurveyRepository class

namespace CoreBundle\Repository;

use Doctrine\ODM\MongoDB\DocumentRepository;

/**
 * SurveyRepository
 *
 * This class was generated by the Doctrine ODM. Add your own custom
 * repository methods below.
 */
class SurveyRepository extends DocumentRepository
{


}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Survey has two annotations with @ODM\Document which override themselves.

Put both parameters to a single annotation.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!