Skip to content

Loading…

DDC-3069: [GH-1000] [DDC-3068] EntityManager::find accept array of object as id #3841

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of giosh94mhz:

Url: #1000

Message:

Pull Request for ticket http://www.doctrine-project.org/jira/browse/[DDC-3068](http://www.doctrine-project.org/jira/browse/DDC-3068)
Here follow the ticket description for you convenience.

According to the documentation, EntityManager::find should return one entity given it's primary key. When a primary key of an entity is composed of multiple associations, one (me :)) would expect that the following works, but it doesn't:

$entity = $_em->find('My\EntityClass', array(
    'assoc1' => $instance1,
    'assoc2' => $instance2
));
PHP Fatal error:  Object of class My\EntityClass could not be converted to string

The only working way I've found is the following:

$entity = $_em->find('My\EntityClass', array(
    'assoc1' => $instance1->getId(),
    'assoc2' => $instance2->getId()
));

I think that this second scenario is not correct, since expose implementation details.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1000] was closed:
#1000

@doctrinebot

Comment created by @guilhermeblanco:

As of 10a0daf this issue was fixed.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.5 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.