DDC-2772: One class can be mapped to multiple discriminator values #3519

doctrinebot opened this Issue Nov 1, 2013 · 0 comments

2 participants


Jira issue originally created by user mouyang:

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-mapping value="DiscA" class="ClassA" />
    <discriminator-mapping value="DiscB" class="ClassB" />
    <discriminator-mapping value="DiscC" class="ClassB" />

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.
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment