doujuegai8830 2015-02-06 13:11
浏览 42

Doctrine 2 orm:尝试生成实体时的转换映射错误

I use --filter to generate an specific entity like "Tag" from tag table but, Doctrine returning the following error:

doctrine orm:convert-mapping --from-database annotation Entities/ --filter "Tag"

[Doctrine\ORM\Mapping\MappingException] 
Property "pseReference" in "ProjectStepConfigElement" was already declared, but it must be declared only once

So I remove the entire Entities folder from my project to regenerate all Entities from database via reverse engineering.

But when run the following command to generate all entities to Entities/ folder with annotations:

doctrine orm:convert-mapping --from-database annotation Entities/

Doctrine return the same error:

[Doctrine\ORM\Mapping\MappingException] 
Property "pseReference" in "ProjectStepConfigElement" was already declared, but it must be declared only once


EDIT:

If I filter by entity with Entities/ directory empty the new entities is generated. So I generate all new entities that not exists before, add with git add [filePath], and return the old entities with git checkout -- . and clean files~ with git clean -f. Commit and all is working fine.


Why Doctrine returning the error:

[Doctrine\ORM\Mapping\MappingException] 
Property "pseReference" in "ProjectStepConfigElement" was already declared, but it must be declared only once

What's happen? when


ProjectStepConfigElement Content

<?php

namespace Entities;

use Doctrine\ORM\Mapping as ORM;

use Symfony\Component\Validator\Constraints as Assert;

/**
 * ProjectStepConfigElement
 *
 * @ORM\Table(name="project_step_config_element")
 * @ORM\Entity
 */
class ProjectStepConfigElement
{
    /**
     *
     * @ORM\Column(name="pse_id", type="bigint", nullable=false)
     *
     * @ORM\Idwhen 
     * @ORM\GeneratedValue(strategy="SEQUENCE")
     * @ORM\SequenceGenerator(sequenceName="project_step_config_element_pse_id_seq", allocationSize=1, initialValue=1)
     */
    private $pseId;

    /**
     *
     * @ORM\Column(name="pse_category", type="smallint", nullable=false)
     *
     * @Assert\NotBlank(groups={"save"})
     * @Assert\Type(type="integer")
     */
    private $pseCategory;

    /**
     *
     * @ORM\Column(name="pse_dt_created", nullable=false)
     */
    private $pseDtCreated = 'now()';

    /**
     *
     * @ORM\ManyToOne(targetEntity="ProjectStepConfig")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="psc_id", referencedColumnName="psc_id")
     * })
     */
    private $pseConfig;

    /**
     *
     * @ORM\Column(name="pse_reference_id", nullable=true)
     *
     * @Assert\Type(type="integer")
     */
    private $pseReferenceId;



    /**
     * Get pseId
     *
     * @return integer
     */
    public function getPseId()
    {
        return $this->pseId;
    }

    public function setPseId($pseId)
    {
        $this->pseId = $pseId;

        return $this;

    }

    /**
     * Set pseCategory
     *
     * @param integer $pseCategory
     * @return ProjectStepConfigElement
     */
    public function setPseCategory($pseCategory)
    {
        $this->pseCategory = $pseCategory;

        return $this;
    }

    /**
     * Get pseCategory
     *
     * @return integer
     */
    public function getPseCategory()
    {
        return $this->pseCategory;
    }

    /**
     * Set pseDtCreated
     *
     * @param \DateTime $pseDtCreated
     * @return ProjectStepConfigElement
     */
    public function setPseDtCreated($pseDtCreated)
    {
        $this->pseDtCreated = $pseDtCreated;

        return $this;
    }

    /**
     * Get pseDtCreated
     *
     * @return \DateTime
     */
    public function getPseDtCreated()
    {
        return $this->pseDtCreated;
    }

    /**
     * Set pseConfig
     *
     * @param \ProjectStepConfig $pseConfig
     * @return ProjectStepConfigElement
     */
    public function setPseConfig(ProjectStepConfig $pseConfig = null)
    {
        $this->pseConfig = $pseConfig;

        return $this;
    }

    /**
     * Get pseConfig
     *
     * @return \ProjectStepConfig
     */
    public function getPseConfig()
    {
        return $this->pseConfig;
    }

    /**
     * Set pseReference
     *
     * @param \ClientImage $pseReference
     * @return ProjectStepConfigElement
     */
    public function setPseReferenceId($pseReferenceId)
    {
        $this->pseReferenceId = $pseReferenceId;

        return $this;
    }

    /**
     * Get pseReferenceId
     *
     * @return \ClientImage
     */
    public function getPseReferenceId()
    {
        return $this->pseReferenceId;
    }
}


Table to entity in question(postgresql):

CREATE TABLE "public"."project_step_config_element" (
"pse_id" int8 DEFAULT nextval('project_step_config_element_pse_id_seq'::regclass) NOT NULL,
"psc_id" int8 NOT NULL,
"pse_category" int2 DEFAULT 1 NOT NULL,
"pse_dt_created" timestamp(6) DEFAULT now() NOT NULL,
"pse_reference_id" int8,
CONSTRAINT "project_step_config_element_pkey" PRIMARY KEY ("pse_id")
)
WITH (OIDS=FALSE)
;
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c