mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1644: Using full annotation namespace breaks annotations #2064
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Feb 10, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user jreed:
I have created my own custom annotations. They work fine when I use them in a normal class file, but if I try to use them inside of a Doctrine Model class then the base Doctrine annotations don't work. My understanding is I have to specify the full namespace for the default Annotations in order for them to work with custom annotations. However, when I do this I get the dreaded error:
Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class xxx is not a valid entity or mapped super class.' in /Magnet/winlibrary/doctrine-orm/Doctrine/ORM/Mapping/MappingException.php:142
In order to test this further I used the quick start documentation and modified it to use full annotation namespaces. Here is the code:
When I run this I get the error:
Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class Post is not a valid entity or mapped super class.' in /Magnet/winlibrary/doctrine-orm/Doctrine/ORM/Mapping/MappingException.php:142
If I remove the "ORM" from the annotations and remove "use Doctrine\ORM\Mapping as ORM;" then it works properly. I can't seem to find why the full annotation namespaces don't work properly as I've seen a number of examples that do this.
Also, I noticed that if I specify the full namespace without the "use Doctrine\ORM\Mapping as ORM;" alias (i.e. @Doctrine\ORM\Mapping\Entity) then it works on 2.1.x but does not work on 2.2.0. Using the ORM alias does not work on either version. Given I've followed the documentation and have found inconsistencies between the versions it seems this is a bug in either the code or the documentation.