Skip to content

Issue when using DoctrineWriter for one-to-one #50

Open

Description

@phpPhil

Hi, when trying to use DoctrineWriter to insert values for my associated one-to-one (unidirectional) entity I receive the following error:

The identifier id is missing for a query of MyVendor\ServicesBundle\Entity\MyAssociatedEntity

It is properly important to mention that the record of the parent entity already exists when running this script. At the time of execution there is a null key value for the associated entity stored in the parent entity.
These entities have been tested with CRUD functionality both with and without NULL values and they seem to behave fine except in combination with DoctrineWriter.

My Doctrine Parent Entity:

    /**
     * @ORM\OneToOne(targetEntity="MyAssociatedEntity", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="myassociatedentity_id", referencedColumnName="id", nullable=true)
     */
    private $myAssociatedEntity;

Here is some stack trace:

2. at ORMException ::missingIdentifierField ('MyVendor\\ServicesBundle\\Entity\\MyAssociatedEntity', 'id') 
in vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php at line 481   + 
3. at EntityManager ->getReference ('MyVendor\\ServicesBundle\\Entity\\MyAssociatedEntity', array('languages' => 'Dutch,Papiamento')) 
in vendor\portphp\doctrine\src\DoctrineWriter.php at line 266   + 
4. at DoctrineWriter ->loadAssociationObjectsToObject (array('isoAlpha2' => 'AW', 'isoAlpha3' => 'ABW', 'capital' => 'Oranjestad', 'continent' => 'Americas', 'region' => 'Caribbean', 'myAssociatedEntity' => array('languages' => 'Dutch,Papiamento'), 'currencyCode' => 'AWG'), object(Country)) 
in vendor\portphp\doctrine\src\DoctrineWriter.php at line 180   + 
5. at DoctrineWriter ->writeItem (array('isoAlpha2' => 'AW', 'isoAlpha3' => 'ABW', 'capital' => 'Oranjestad', 'continent' => 'Americas', 'region' => 'Caribbean', 'myAssociatedEntity' => array('languages' => 'Dutch,Papiamento'), 'currencyCode' => 'AWG')) 
in src\MyVendor\AdminBundle\Service\Importer.php at line 163   + 

Is there a workaround for this issue?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions