-2
nullにすることはできません「整合性制約違反を:1048列 『ecriture_idは』 nullにすることはできません」:は、エンティティを永続:私はこのコードを使用すると、私はこのエラーを持っている
私は "$をコメント解除した場合this-> em-> persist($ ecriture) "それは本当です。私の "Produit" 実体はカスケードを持っているので、私は理解していない
はを持続:
エンティティ "Produit":
class Produit
{
/**
* @ORM\OneToOne(targetEntity="LogicielBundle\Entity\Ecriture", inversedBy="gestionLocativeProduit", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
*/
private $ecriture;
public function setEcriture(\LogicielBundle\Entity\Ecriture $ecriture)
{
$ecriture->setGestionLocativeProduit($this);
$this->ecriture = $ecriture;
// Similar problem if I add "$ecriture->setGestionLocativeProduit($this);" right here
return $this;
}
public function getEcriture()
{
return $this->ecriture;
}
エンティティ "Ecriture":
class Ecriture
{
/**
* @ORM\OneToOne(targetEntity="LogicielBundle\Entity\GestionLocative\Produit", mappedBy="ecriture")
* @ORM\JoinColumn(nullable=true)
*/
private $gestionLocativeProduit;
public function setGestionLocativeProduit(\LogicielBundle\Entity\GestionLocative\Produit $gestionLocativeProduit)
{
$this->gestionLocativeProduit = $gestionLocativeProduit;
return $this;
}
public function getGestionLocativeProduit()
{
return $this->gestionLocativeProduit;
}