所以我有这两个类,它们之间有 OneToMany 和 ManyToOne 关系:
命名空间 RM\Entity; 使用 Doctrine\Common\Collections\ArrayCollection; /** * @Table(name="用户") * @实体 * @作者萨比 */ 类用户{ /** * @ID * @Column(name="id", type="integer", nullable=false) * @GeneratedValue(strategy="IDENTITY") * @OneToMany(targetEntity="JobListing", mappedBy="ownerId", orphanRemoval=true) */ 私人 $id; /** * @var 字符串 $displayname * @Column(type="string", nullable=false) */ 私人 $displayname; }
和
命名空间 RM\Entity; 使用 Doctrine\Common\Collections\ArrayCollection; /** * @Table(name="job_listings") * @Entity(repositoryClass="RM\Entity\Repository\JobListingRepository") * @作者萨比 */ 类作业列表 { /** * @var 整数 $id * @Column(name="id", type="integer", nullable=false) * @ID * @GeneratedValue(strategy="IDENTITY") */ 私人 $id; /** * @var 用户 * @ManyToOne(targetEntity="User",cascade={"persist"}) * @JoinColumns({ * @JoinColumn(name="ownerId", referencedColumnName="id", nullable=false) * }) */ 私人 $ownerId;
但是,当保存 JobListing 时,坚持它会引发以下错误:
应用程序错误 异常信息: 消息:类不存在 堆栈跟踪: #0 library\Doctrine\ORM\Mapping\ClassMetadata.php(67): ReflectionClass->__construct(false) #1 library\Doctrine\ORM\Mapping\ClassMetadataFactory.php(350): Doctrine\ORM\Mapping\ClassMetadata->__construct(false) #2 library\Doctrine\ORM\Mapping\ClassMetadataFactory.php(260): Doctrine\ORM\Mapping\ClassMetadataFactory->newClassMetadataInstance(false) #3 library\Doctrine\ORM\Mapping\ClassMetadataFactory.php(169): Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata(false) #4 library\Doctrine\ORM\EntityManager.php(247): Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor(false) #5 library\Doctrine\ORM\UnitOfWork.php(1222): Doctrine\ORM\EntityManager->getClassMetadata(false) #6 library\Doctrine\ORM\UnitOfWork.php(1678): Doctrine\ORM\UnitOfWork->doPersist(1, Array) #7 library\Doctrine\ORM\UnitOfWork.php(1252): Doctrine\ORM\UnitOfWork->cascadePersist(Object(RM\Entity\JobListing), Array) #8 library\Doctrine\ORM\UnitOfWork.php(1201): Doctrine\ORM\UnitOfWork->doPersist(Object(RM\Entity\JobListing), Array) #9 library\Doctrine\ORM\EntityManager.php(454): Doctrine\ORM\UnitOfWork->persist(Object(RM\Entity\JobListing)) #10 library\RM\Entity\JobListingService.php(54): Doctrine\ORM\EntityManager->persist(Object(RM\Entity\JobListing)) #11 application\controllers\JobListingController.php(28): RM\Entity\JobListingService->saveJobListing(Object(RM\Entity\JobListing)) #12 library\Zend\Controller\Action.php(516): JobListingController->addAction()
我在这里想念什么?