Skip to content
This repository

doctrine:generate:entities AnnotationException (b2/master) #1083

Closed
LaKrue opened this Issue May 25, 2011 · 9 comments

6 participants

Lars Krüger Fabien Potencier Benjamin Eberlei Christophe Coevoet dukeofgaming David Ward
Lars Krüger
LaKrue commented May 25, 2011

Hi,

today I updated from sf2 b1 to b2 SE and updated to the master branch.
Of cause I read about the changed use of annotations in the update file and modified my creation script.
But now I can't generate my entities based on the database anymore.

The following command is executed like expected and generates all the entity files in my projects entity folder:

php app/console doctrine:mapping:import "MyXBundle" annotation --em=withport;

This command fails with the following error message:

php app/console doctrine:generate:entities MyXBundle/Entity;

Error message:

[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@orm:Table" in class My\XBundle\Entity\XY was never imported.

The doctrine:mapping:import command still generates old syntax entities.

Thanks for looking into this,
Lars

Fabien Potencier
Owner
fabpot commented May 25, 2011

This is a known issue, but a Doctrine one. The Doctrine command is not updated yet. Ping @beberlei.

Benjamin Eberlei
Collaborator

Changing the prefix from orm: to orm\ is a symfony issue though. The generator is only missing to generate the use statement then.

Christophe Coevoet
Collaborator
stof commented May 25, 2011

Well, DoctrineBundle could be changed to set orm\ as prefix of the annotations but this would not solve the issue that the use statement is not set by the EntityGenerator (and the prefix to use depends of the way the statement is written).

Fabien Potencier
Owner
fabpot commented May 25, 2011

I have already removed the prefix in beta2. So, as soon as Doctrine adds the required use statements, it will work.

Christophe Coevoet
Collaborator
stof commented May 25, 2011

@fabpot Removing the prefix entirely means that the use statement is needed for all annotations used in the class (which depends of the mapping). It would be better to set the prefix to ORM\ in the EntityGenerator which will allow to use a single use statement

Christophe Coevoet
Collaborator
stof commented May 25, 2011

I just submitted a PR to update the EntityGenerator: doctrine/doctrine2#61

dukeofgaming

Just as a note until this is fixed and for anyone that bumps into this issue and its not as obvious to fix, just:

0) Import your schema using annotations, i.e. app/console doctrine:mapping:import "MyTestBundle" annotation
1) Add use Doctrine\ORM\Mapping as ORM; before the annotated class
2) Find and replace @orm: to @ORM\
3) Run import command as usual

Fabien Potencier
Owner
fabpot commented June 13, 2011

Doctrine PR61 has been merged into master. So, as soon as it is also merged into the 2.0.x branch and if a new 2.0 version is released, it will fix this bug automatically. So, I"m closing the issue.

Fabien Potencier fabpot closed this June 13, 2011
David Ward

For others running into this problem, it seems that running app/console doctrine:mapping:import "MyTestBundle" annotation followed by app/console doctrine:generate:entities "MyTestBundle" still does not work in the Symfony Standard 2.0 RC1 edition (where no prefix at all is being added to the annotations).

Setting the annotation prefix in ImportMapingDoctrineCommand.php like 94b0a01 seems to fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.