Skip to content


DDC-1585: Doctrine2 doesn't check for the correct entity type on @ManyToOne relations #2222

doctrinebot opened this Issue · 5 comments

2 participants


Jira issue originally created by user felicitus:

I made a mistake when creating a @ManyToOne entity:


  • @ManyToOne(targetEntity="Entities\EntityA") */ private $test;

However, I was setting Entities\EntityB into $test.

Doctrine2 doesn't check for this, resulting in a hard-to-find issue.


Comment created by @guilhermeblanco:



Comment created by @beberlei:

This is not a duplicate, its a runtime issue in the code when setting the wrong target entity type.


Comment created by @beberlei:

Implemented an instanceof check.


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.2 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
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.