troubleshootings.rst 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Troubleshooting
  2. ===============
  3. Deleted elements from a one-to-many association are not removed!
  4. ----------------------------------------------------------------
  5. Make sure the Orphan Removal option is set to ``true``
  6. .. code-block:: xml
  7. <?xml version="1.0" encoding="utf-8"?>
  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">
  9. <entity name="Application\Sonata\MediaBundle\Entity\Gallery" table="media__gallery" >
  10. <one-to-many
  11. field="galleryHasMedias"
  12. target-entity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia"
  13. mapped-by="gallery"
  14. orphan-removal="true"
  15. >
  16. <orphan-removal>true</orphan-removal>
  17. </one-to-many>
  18. <!-- other definitions -->
  19. </entity>
  20. </doctrine-mapping>
  21. .. note::
  22. The last Doctrine version requires to define the ``orphan-removal`` as an attribute and not as a node.
  23. Ordered fields are not ordered!
  24. -------------------------------
  25. Make sure the ``order-by`` option is correctly set.
  26. .. code-block:: xml
  27. <?xml version="1.0" encoding="utf-8"?>
  28. <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">
  29. <entity name="Application\Sonata\MediaBundle\Entity\Gallery" table="media__gallery" >
  30. <one-to-many
  31. field="galleryHasMedias"
  32. target-entity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia"
  33. mapped-by="gallery"
  34. >
  35. <order-by>
  36. <order-by-field name="position" direction="ASC" />
  37. </order-by>
  38. </one-to-many>
  39. <!-- other definitions -->
  40. </entity>
  41. </doctrine-mapping>