DDC-1461: Possible Regression with OneToOne relation #2089

Closed
doctrinebot opened this Issue Oct 31, 2011 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user johannes:

I have the following relations:


namespace Model;

use Doctrine\ORM\Mapping as ORM;

/****
 * @ORM\Entity(repositoryClass="Model\Repository\UserRepository")
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 * @ORM\HasLifecycleCallbacks
 * @ORM\Table(name="users")
 */
class User
{
    /****
     * @ORM\OneToOne(targetEntity="Model\TwitterAccount", orphanRemoval=true, fetch="EAGER", cascade = {"persist"}, inversedBy="user")
     * @var TwitterAccount
     */
    private $twitterAccount;
}

/****
 * @ORM\Entity(repositoryClass = "Model\Repository\TwitterAccountRepository")
 * @ORM\Table(name = "twitter_accounts")
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class TwitterAccount
{
    /****
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    private $id;

    /****
     * @ORM\OneToOne(targetEntity="Model\User", fetch="EAGER")
     */
    private $user;
}

now when I add a new account, the user-side is not updated with the id of the account, but the account is still saved to the database.

$twitterAccount = new TwitterAccount();
$user->setTwitterAccount($twitterAccount);
$em->persist($user);
$em->flush();

The twitterAccountid of the users table is empty, but the new account is added to the "twitter_accounts" table with the correct userid.

@doctrinebot

Comment created by @beberlei:

Do you know when this started to happen ?

@doctrinebot

Comment created by johannes:

I have reverted some commits of the ORM, but it doesn't seem to have happened recently, or it is a combination of different changes in one of the repositories.

What's weird is that the error does not occur when the user is new, but only if it already exists. It seems like somehow the UOW does not detect that it has changed.

@doctrinebot

Comment created by @beberlei:

This is deferred explicit related it seems.

@doctrinebot

Comment created by @beberlei:

Verified

@doctrinebot

Comment created by @beberlei:

Hm no, it works for me.

See e8eda4a and reopen if you can make it fail.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment