doctrinefindall

Doctrine : findAll returns the same object several times


I was wondering if it ever happened to someone ?

In my table I have two records. When I do the findAll on the repository it returns an array of 2 records but it is the same one (the first one).

Note : the findAll is the simplest one...no join, nothing. it is just a select on the table.

Somebody can explain that ?


Solution

  • It just happened to me now; I encountered the same issue with the first line returned by my findAll() method from my entity.

    The problem was that I had a composite primary key in my table. The solution is to add * @ORM\Id() in every definition of your entity that is a primary key of your table.