Reputation: 4561
I dont really what means the error that I put in the title:
This is how I build my query builder :
$qb = $this->em->createQueryBuilder()
->select('etablissement.numetb AS id')
->addSelect("concat('Etablissement ', etablissement.numetb) AS name")
->addSelect("etablissement.raisonsoc AS description")
->addSelect("etablissement.datcreation AS datcreation")
->addSelect("11 AS type")
->addSelect("identity(etablissement.statut) AS statut")
->from('MyBundle:MyEntity', 'etablissement')
->orderBy('datcreation', 'DESC');
My repository is a service not linked to an entity (if it can help).
Can you explain what means this error ? and how to solve it ?
thank you
Upvotes: 5
Views: 8101
Reputation: 331
For me solution was to change select method to addSelect, i.e.:
$this->em->createQueryBuilder()->select('e.id')
to
$this->em->createQueryBuilder()->addSelect('e.id')
Upvotes: 9
Reputation: 324
For me solution was setting paginator's output walkers to false.
$paginator->setUseOutputWalkers(false);
Upvotes: 17
Reputation: 4561
I found the answer and how i have to write the query builder to make it work :
Doing this makes the error going away :
$qb = $this->em->createQueryBuilder()
**->select('etablissement')
->addSelect('etablissement.numetb AS id')**
->addSelect("concat('Etablissement ', etablissement.numetb) AS name")
->addSelect("etablissement.raisonsoc AS description")
->addSelect("etablissement.datcreation AS datcreation")
->addSelect("11 AS type")
->addSelect("identity(etablissement.statut) AS statut")
->from('MyBundle:MyEntity', 'etablissement')
->orderBy('datcreation', 'DESC');
Upvotes: 3
Reputation: 4012
This error means that you have to select in your query all identifiers of your entity. Identifiers are the fields with a @id annotation in your entity.
Upvotes: 4