2
votes

I using symfony2 and doctrine and I am getting the following error:

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\RuleId" in property Wibiya\WebsiteBundle\Entity\Rules::$RuleId does not exist, or could not be auto-loaded.

The Rules entity contain the column/field in it.

    /**
     * @var integer $RuleId
     * @ORM\RuleId
     * @ORM\Column(name="RuleId", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $RuleId;

This is the function I am trying to run:

$em = $this->getDoctrine()->getEntityManager();
$Rules = $em->getRepository('WibiyaWebsiteBundle:Rules')->findAllOrderedByName();

The RulesRepository class:

    public function findAllOrderedByName()
    {
        return $this->getEntityManager()
            ->createQuery('SELECT p FROM WibiyaWebsiteBundle:Rules p ORDER BY p.RuleName ASC')
            ->getResult();
    }

I tried to put this line at the bottom of the autoload.php:

require __DIR__ . "/../vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php";

But, I got the same error.
I'm using Symfony 2.0.16 and Doctrine 2.1.6

2

2 Answers

3
votes

There is no RuleId annotation in Doctrine, just Id [see docs].

Just use @ORM\Id on the primary key field all entities you define.

0
votes

@ORM\Id is just annotation for your primary key field in doctrine mapping, its independent of column name of primary key in your MySql table. You can keep any name for your primary key field and specify it on mapping as @ORM\Column(name="column_name", type="integer").