Doctrine Error: The partial field selection of class must contain the identifier.

Whenever performing a partial selection, you need to include the primary key of the class you’re selecting from.

In my case, this error occurred when I tried to select a partial class without selecting the id field.

Here is my previous code:

$qb = $this->createQueryBuilder('d')
           ->select(array('partial d.{title, description}'));

Here is my final code:

$qb = $this->createQueryBuilder('d')
           ->select(array('partial d.{id, title, description}'));