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

时间:2015-02-06 13:11:54

标签: php symfony orm doctrine-orm doctrine

我使用--filter从标记表生成"Tag"之类的特定实体,但是,Doctrine返回以下错误:

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

因此,我从项目中删除整个Entities文件夹,以通过逆向工程从数据库重新生成所有实体。

但是,当运行以下命令以生成带注释的实体/文件夹的所有实体时:

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

Doctrine返回相同的错误:

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


修改

如果我按Entities/目录清空实体,则会生成新实体。因此,我生成之前不存在的所有新实体,使用git add [filePath]添加,并使用git checkout -- .返回旧实体,并使用files~清除git clean -f。承诺并且一切正常。


为什么Doctrine会返回错误:

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

发生什么事了? 什么时候


ProjectStepConfigElement内容

<?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;
    }
}


表格与相关实体(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 个答案:

没有答案