カスタムクエリを呼び出すメソッドを持つリポジトリクラスがあります。コントローラの内部から呼び出そうとするとfindAllWithRating()、次の例外が発生しました。
[2/2] QueryException: [Syntax Error] line 0, col 156: Error: Unexpected 'NULL'
phpmyadmin内でクエリを呼び出そうとすると、クエリはうまく機能します。
何か案が?
<?php
namespace Anchorbrands\Bundle\MessageBundle\Entity;
use Doctrine\ORM\EntityRepository;
class MessageRepository extends EntityRepository
{
    public function findAllWithRating() {
        return $this->getEntityManager()
            ->createQuery("SELECT id, user_id, title, slug, content, question, image_name, created_at, updated_at,
                    MAX(CASE WHEN rating = '1' THEN totalCount ELSE NULL END) 'Rating 1',
                    MAX(CASE WHEN rating = '2' THEN totalCount ELSE NULL END) 'Rating 2',
                    MAX(CASE WHEN rating = '3' THEN totalCount ELSE NULL END) 'Rating 3'
            FROM
            (
                SELECT  a.id, a.user_id, a.title, a.slug , a.content, a.question, a.image_name, a.created_at, a.updated_at,
                        rating, COUNT(*) totalCount
                FROM    AnchorbrandsMessageBundle:Message a
                        LEFT JOIN AnchorbrandsMessageBundle:Rating b
                            ON a.id = message_id
                GROUP BY a.id, a.user_id, a.title, a.slug, a.content, a.question, a.image_name, a.created_at, a.updated_at, rating
            ) r
            GROUP BY id, user_id, title, slug, content, question, image_name, created_at, updated_at")->getResult();
    }
}