-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
Jira issue originally created by user pcnc:
Good afternoon,
When hydrating an Embeddable with nullable attributes the result is an instance of the Embeddable class , this is obviously correct and expected behavior.
If all the attributes are null the hydrator will still return an instance of the class with all of its properties null , even if I persist and flush my Entity with the Embeddable being set as null .
For clarification :
class MyEntity
{
protected $myEmbeddable;
public function setMyEmbeddable(MyEmbeddable $myEmbeddable = null)
{
$this->myEmbeddable = $myEmbeddable;
}
[...]
}
$newEntity = new MyEntity();
$newEntity->setMyEmbeddable(null);
$em->persist($newEntity);
$em->flsuh($newEntity);
Calling $newEntity->getMyEmbeddable() will return an instance of the MyEmbeddable object with all of it's attributes set to null .
I expected $newEntity->getMyEmbeddable() to be NULL .
Can someone clarify is this is expected behaviour ? In case it is , how can I achieve what I'm looking for ?
Best regards
afoeder, idr0id, tinpansoul, BenMorel and kekko1212