2011-12-19 81 views
1

我試圖爲我的Doctrine Mongo文檔類生成getters/setters。Symfony2 + Doctrine MongoDM文檔生成問題

文件的代碼看起來是這樣的:

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? 

這其中有我難住了,因爲從命名空間的角度來看,我認爲我已經包含了一切。

回答

4

您輸入的學說標註爲MongoDB命名空間。所以你應該使用@MongoDB\ReferenceOne,比如@MongoDB\Document