【问题标题】:Doctrine2 @Version annotation in yaml fileyaml文件中的Doctrine2 @Version注释
【发布时间】:2015-10-20 00:03:21
【问题描述】:

我想在我的项目中使用可版本化的学说。在注解映射中它看起来像这样:

/*
 * @ORM\Column(type="integer")
 * @ORM\Version
 */
private $version;

我使用 yaml - 我必须在我的代码中添加什么?我有:

SMS\MyBundle\Wykbadpoz:
    type: entity
    table: wykbadpoz
    fields:
        version: 
            type: integer

【问题讨论】:

    标签: symfony doctrine-orm doctrine yaml


    【解决方案1】:

    今天刚遇到同样的问题,您正在寻找的解决方案是:

    SMS\MyBundle\Wykbadpoz:
        type: entity
        table: wykbadpoz
        fields:
            version: 
                type: integer
                version:
                    type: integer
                    default: 1
    

    【讨论】:

      【解决方案2】:

      您似乎使用了错误的注释,请使用Loggable 扩展名。查看扩展文档了解更多信息:https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/loggable.md

      因此,实体应标记为@Gedmo\Loggable,属性应标记为@Gedmo\Versioned。也不要忘记导入注解:

      use Gedmo\Mapping\Annotation as Gedmo;
      

      您可以使用StofDoctrineExtensionsBundle 来简化激活扩展程序。

      【讨论】:

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