我有两个类User和UserMobile,一对一关系
namespace AppBundle\Entity;
/**
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
* @ORM\Table(name="users")
* @ORM\HasLifecycleCallbacks
* @UniqueEntity("email")
* @UniqueEntity("username")
*/
class User implements UserInterface
{
/**
* @ORM\OneToOne(targetEntity="UserMobile")
* @ORM\JoinColumn(name="user_mobile_id", referencedColumnName="id")
*/
private $user_mobile;
.....................................................................
/**
* Set user_mobile.
*
* @param \stdClass $user_mobile
*
* @return User
*/
public function setUserMobile($user_mobile): User
{
$this->user_mobile = $user_mobile;
return $this;
}
/**
* Get UserMobile.
*
* @return UserMobile
*/
public function getUserMobile()
{
return $this->user_mobile;
}
类UserMobile:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* UserMobile
*
* @ORM\Table(name="user_mobile")
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserMobileRepository")
*/
class UserMobile
{
/**
* @ORM\OneToOne(targetEntity="User", mappedBy="user_mobile")
*/
private $user;
我有两个对象UserMobile $ user_mobile和User $ user。我想在这两个对象之间建立关系。我做了以下事情:
$user->setUserMobile($userMobile);
$this->em->persist($user);
$this->em->persist($userMobile);
$this->em->flush();
我在'AppBundle \ Repository \ User'附近收到错误“[语义错误]第0行第14行:错误:未定义类'AppBundle \ Repository \ User'。”, “class”:“Doctrine \ ORM \ Query \ QueryException”,