Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2772

One class can be mapped to multiple discriminator values

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      MySQL 5.x

      Description

      I'm not sure if this is intentional or not, but this appears to a valid discriminator map. The problem I am running into is that it's impossible to create an instance of ClassB with a discriminator value "DiscB" (it's always "DiscC" - I'm assuming last one wins here).

      <entity name="ClassB" ...>
        <discriminator-map>
          <discriminator-mapping value="DiscA" class="ClassA" />
          <discriminator-mapping value="DiscB" class="ClassB" />
          <discriminator-mapping value="DiscC" class="ClassB" />
        </discriminator-map>
      </entity>
      

      Eventhough DiscB and DiscC map to the same class, I do want to maintain some sort of logical separation in the database using the two discriminator values. That does not appear to be possible. I can provide more details about my data model, if necessary.

      These are the possible solutions I can think of.

      1. Enforce a strict one-to-one relationship between value and class. This means I would have to modify my code to reflect this.
      2. (I know this has been rejected before, but I'm in favour of this solution.) Expose the discriminator field but validate it before committing to the database. I'm actually using the discriminator as part of a compound primary key, so this would be very helpful to me.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Matthew Ouyang
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: