小编eri*_*sho的帖子

OneToOne 实体不会在 Symfony2 中坚持使用 Doctrine

我在用户和学生之间的 Symfony 中有一个 OneToOne 关系,其中用户是所有者,当我尝试坚持更改时,双方都没有进行更改,这是我的最后一个配置:

<?php

/**
 * User
 *
 * @ORM\Table(name="user")
 * @ORM\Entity(repositoryClass="BackendBundle\Repository\UserRepository")
 */
class User  implements UserInterface, \Serializable
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
    * @ORM\OneToOne(targetEntity="Student", mappedBy="user")
    */
    private $student;

    public function __construct() {
    }


    /**
     * Set student
     *
     * @param \BackendBundle\Entity\Student $student
     *
     * @return User
     */
    public function setStudent(\BackendBundle\Entity\Student $student)
    {
        $this->student = $student;

        return $this;
    }

    /**
     * Get student
     *
     * @return …
Run Code Online (Sandbox Code Playgroud)

doctrine one-to-one persistent symfony

1
推荐指数
1
解决办法
2466
查看次数

标签 统计

doctrine ×1

one-to-one ×1

persistent ×1

symfony ×1