mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Annotation Error : should be catched and feedback should be better #5341
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 @kcassam on GitHub (Dec 6, 2016).
I have a repository with these annotations (blame copy-paste) :
and a custom function in it (
getNextFoo())When I call
$em->getRepository('AppBundle:Foo')->getNextFoo();I have an error :
BadMethodCallException: Undefined method 'getNextFoo'. The method name must start with either findBy or findOneBy!The code does not find my repository
I found the bug :
Because there are 2
@ORM\Entity(), the second one overrides the first one.If I delete the line
* @ORM\Entity(), everything works well.A better error message/feedback could be fired in that case : "You have 2 @ORM\Entity annotations, you should have only one" or "You have 2 @ORM\Entity annotations, and the latter is empty and will override the former
@Ma27 commented on GitHub (Dec 23, 2016):
Well I'm not sure if this causes issues with inheritance. If an entity inherits from another entity which contains a
ORM\Entityannotation and noORM\MappedSuperclassannotation (http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html#single-table-inheritance for instance) this might lead to twoEntityannotations here (https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php#L71), but should not cause an exception, right?