Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Index in Doctrine2 / Symfony2 Throws Semantical Error

I'm trying to create a simple index to a table in Doctrine2 / Symfony2 using annotations and I'm getting the following error:

[Semantical Error] The annotation "@Index" in class {My\Namespaces\Here} was never imported. Did you maybe forget to add a "use" statement for this annotation?

I can't find in any documentation what namespace I'm supposed to "use" to add the Index functionality. Here's my annotation:

@ORM\Table(indexes={@Index(name="email_address_idx", columns={"email_address"})})

And here are the namespaces I'm already using:

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;

What namespace do I need to use to add this functionality?

like image 218
Dan Avatar asked Mar 04 '12 19:03

Dan


2 Answers

Looks like you need:

@ORM\Table(indexes={@ORM\Index(name="email_address_idx", columns={"email_address"})})
like image 104
rojoca Avatar answered Nov 13 '22 12:11

rojoca


You can use the following to solve the issue:

use Doctrine\ORM\Mapping\Index;
like image 16
johnmadrak Avatar answered Nov 13 '22 10:11

johnmadrak