Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2531

ManyToManyPersister does not take Custom Types into account

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3, 2.4, 2.5
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      When two entities, both using a custom type for the "@Id" column, have a "@ManyToMany" (bidirectional) relationship, the ManyToManyPersister does not take into account the custom type of the referenced id columns and therefore does not convert the values using the appropriate "convertToDatabaseValue" function.

      The entities themselves are saved propery, but the insertion into the join table always fails.

        Activity

        Hide
        Ben Getsug added a comment -

        My scenario:

        • EntityA uses a custom type for its @Id column (specifically so I can store UUIDs in a binary column...see DDC-3721)
        • EntityA has a (unidirectional) many-to-many association with EntityB, and the usual ArrayCollection initialization on the property
        • I clear the entire collection by calling ArrayCollection::clear()
        • I call EntityManager::flush()
        • No errors occur, but no rows actually get deleted from the database.

        Through debugging, I found that ManyToManyPersister::getDeleteSQL() does not handle custom types like ManyToManyPersister::getDeleteRowSQL() or ManyToManyPersister::removeElement(). So the proper SQL DELETE statement doesn't get executed.

        My current workaround is to loop through my collection of EntityB, calling ArrayCollection::removeElement() with each entity. Given the complexity of ManyToManyPersister, I'm a bit leery of attempting a fix and submitting a PR, but at least wanted to document my issue here.

        Show
        Ben Getsug added a comment - My scenario: EntityA uses a custom type for its @Id column (specifically so I can store UUIDs in a binary column...see DDC-3721 ) EntityA has a (unidirectional) many-to-many association with EntityB, and the usual ArrayCollection initialization on the property I clear the entire collection by calling ArrayCollection::clear() I call EntityManager::flush() No errors occur, but no rows actually get deleted from the database. Through debugging, I found that ManyToManyPersister::getDeleteSQL() does not handle custom types like ManyToManyPersister::getDeleteRowSQL() or ManyToManyPersister::removeElement(). So the proper SQL DELETE statement doesn't get executed. My current workaround is to loop through my collection of EntityB, calling ArrayCollection::removeElement() with each entity. Given the complexity of ManyToManyPersister, I'm a bit leery of attempting a fix and submitting a PR, but at least wanted to document my issue here.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            George van Vliet
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: