使用@OneToOne注解的语句 - Doctrine2
使用@OneToOne注解的语句 - Doctrine2
我有一个包含产品的表格和另一个包含注释的表格。每个产品可以有或没有一些注释。我只需要知道注释是关于哪个产品的,但是产品不需要知道它的注释。我认为这应该是我的代码:
namespace EM\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM; use EM\MyBundle\Entity\Productss; /** * @ORM\Entity * @ORM\Table(name="notes") */ class Notess { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @OneToOne(targetEntity="Productss") * @JoinColumn(name="products_id", referencedColumnName="id") **/ private $products; //... } namespace EM\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity * @ORM\Table(name="domains") */ class Domains { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; // ... }
但是它报错了:[Doctrine\Common\Annotations\AnnotationException] [语义错误] 属性EM\MyBundle\Entity\Notes::$products中的注释“@OneToOne”从未导入。您是否可能忘记为此注释添加“use”语句?请问您能帮助我修复这个问题吗?