【问题标题】:Symfony2 + Doctrine MongoDM document generation issueSymfony2 + Doctrine MongoDM 文档生成问题
【发布时间】:2011-12-19 01:59:22
【问题描述】:

我正在尝试为我的 Doctrine Mongo 文档类生成 getter/setter。

文档代码如下所示:

namespace MySite\GameBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

use MySite\GameBundle\Document\User;

/**
 * @MongoDB\Document
 */
class Game {
    /**
     * @ReferenceOne(targetDocument="User")
     */
    protected $user;

    /** @Date */
    protected $start_time;

}

但是,当我尝试使用 CLI command php app/console doctrine:mongodb:generate:documents SiteGameBundle 生成 getter 和 setter 时,我得到以下信息:

[Doctrine\Common\Annotations\AnnotationException]                                                      
  [Semantical Error] The annotation "@ReferenceOne" in property Site\GameBundle\Document\Game::$user was never imported. Did you maybe forget to add a "use" statement for this annotation?

这个让我很难过,因为从命名空间的角度来看,我认为我已经正确地包含了所有内容。

【问题讨论】:

    标签: php mongodb doctrine symfony


    【解决方案1】:

    您将原则注释导入为 MongoDB 命名空间。所以你应该使用@MongoDB\ReferenceOne,比如@MongoDB\Document

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-26
      • 2013-06-01
      • 2015-04-19
      • 2011-04-02
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      • 2011-08-19
      相关资源
      最近更新 更多