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)
;