在Symfony2中使用doctrine进行查询会产生语义错误

I'm trying to make a query in my Symfony project, I make it with the following code:

    $em = $this->getDoctrine()->getManager();

    $countUnreadPm = $em->createQueryBuilder()
    ->select('count(*)')
    ->from('Privatemessage', 'pmid')
    ->getQuery()
    ->getResult();

However this gets me a semantical error:

[Semantical Error] line 0, col 21 near 'Privatemessage': Error: Class 'Privatemessage' is not defined.

The entity class is named 'Privatemessage' so no problems there. What is the issue?

count(pmid) - DQL count objects.

->from('AcmeDemoBundle:Privatemessage') - Full path to entity eg. AcmeDemoBundle

$em = $this->getDoctrine()->getManager();

$countUnreadPm = $em->createQueryBuilder()
->select('count(pmid)')
->from('AcmeDemoBundle:Privatemessage', 'pmid')
->getQuery()
->getResult(); // or ->getSingleScalarResult(); For integer value.