-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
Description
Jira issue originally created by user bil5:
When having a not nullable onetoone unidirectional relation and trying to persist the parent entityn sql throws this exception : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'deliveryMode_id' cannot be null.
Scheme is Shop has a deliveryMode :
class Shop{
/**
* @ORM\OneToOne(targetEntity="acme\Bundle\DeliveryBundle\Entity\DeliveryMode", cascade={"all"}, orphanRemoval=true)
* @ORM\JoinColumn(nullable=false)
* @Assert\Valid
*/
private $deliveryMode;
}When I do a :
$shop=new Shop();
$deliveryMode=new DeliveryMode();
$shop->setDeliveryMode($deliveryMode);
...
$entityManager->persist($shop);
$entityManager->flush();Then, above exception is thrown
BUT: When I put in on a doctrine transaction, it works perfectly, and it also works when I remove the "not nullable" constraint, deliveryMode is perfectly persisted.
It seems to me there a bug with the order of executing the inserts, the deliveryMode should be inserted, then the shop, I think that is not the case
Reactions are currently unavailable