Skip to content

Loading…

DDC-2080: Entity's association changes after first call #2763

Closed
doctrinebot opened this Issue · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user iamkoby:

i am using the latest version of doctrine: 2.3

when you call a generated association function, the first time everything is fine:

$authors = $book->getBookToAuthors();
//$authors = array(5)
but the second time instead of returning the array of all associations it returns the last hydrated entity:

$authors = $book->getBookToAuthors();
//$authors = BookToAuthor entity
that happens even when there is nothing else happening:

$authors = $book->getBookToAuthors(); //will work
$authors = $book->getBookToAuthors(); //won't work
the function of getBookToAuthors() is:

public function getBookToAuthors()
{
return $this->bookToAuthors;
}
and the mapping is as follows:

/****

  • @var BookToAuthor[] *
  • @OneToMany(targetEntity="BookToAuthor", mappedBy="book", cascade={"persist"})
  • @JoinColumn(name="id", referencedColumnName="book_id", onDelete="cascade") */ private $bookToAuthors; please advise. i don't know what to do... :-(
@doctrinebot

Comment created by iamkoby:

sorry sorry sorry
it was a mistake in the association target side.

the target had One-To-One association instead of Many-To-One

@doctrinebot

Issue was closed with resolution "Invalid"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.3 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.