symfony2로 작업하고 있습니다. 테이블이있어서 수동으로 ID를 할당하고 싶습니다. 교리의 문서에서Symfony2, 수동으로 테이블 id 값을 할당합니다.
내가 이걸 발견했습니다
식별자 발전 전략
이에"NONE: Tells Doctrine that the identifiers are assigned (and thus generated)
by your code. The assignment must take place before a new entity is passed to
EntityManager#persist.
NONE is the same as leaving off the @GeneratedValue entirely."
에주의를 : "새 엔티티가 욕실에 전달되기 전에 할당이 이루어져야한다 .. "
어떻게 달성 할 수 있습니까?
나는이 일을 해요 :
$empleado->setId("989865446");
을하지만 말한다 :
Entity of type Entity\Empleado is missing an assigned ID. The identifier
generation strategy for this entity requires the ID field to be populated before
EntityManager#persist() is called. If you want automatically generated
identifiers instead you need to adjust the metadata mapping accordingly.
편집 :
/**
* @var integer $id
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
*/
private $id;
및
public function setId($id)
{
$this->id = $id;
}
당신이 우리에게 관련 코드를 표시 할 수 있습니다 : 코드는 (너무) 방식 내가 생성자가 필요로하는 ID와 어떻게 작동하는지 보여주는거야,하지만이 setId (함께 작동합니다 여기)과 같아야합니다 '$ empleado-> setId()'를 둘러싸고 있습니까? – Problematic
어떻게'setId()'를 구현 했습니까? – greg0ire
그리고 말할 필요도없이 (하지만 어쨌든 그것을 말할 것입니다) id 속성이 id라고 확인해야합니다. – Cerad