Version

Documentation » Doctrine2 ORM Admin

1. Introduction »

« 10. Doctrine ORM Proxy Query

11. Troubleshooting

11.1. Deleted elements from a one-to-many association are not removed!

Make sure the Orphan Removal option is set to true:

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Application\Sonata\MediaBundle\Entity\Gallery" table="media__gallery" >

        <one-to-many
            field="galleryHasMedias"
            target-entity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia"
            mapped-by="gallery"
            orphan-removal="true"
            >

            <orphan-removal>true</orphan-removal>

        </one-to-many>

        <!-- other definitions -->
    </entity>
</doctrine-mapping>

Note

The last Doctrine version requires to define the orphan-removal as an attribute and not as a node.

11.2. Ordered fields are not ordered!

Make sure the order-by option is correctly set:

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Application\Sonata\MediaBundle\Entity\Gallery" table="media__gallery" >

        <one-to-many
            field="galleryHasMedias"
            target-entity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia"
            mapped-by="gallery"
            >
            <order-by>
                <order-by-field name="position" direction="ASC"/>
            </order-by>

        </one-to-many>

        <!-- other definitions -->

    </entity>
</doctrine-mapping>

Found a typo? Something is wrong in this documentation? Just fork and edit it!