If I have a single table where I need multiple columns for discriminator, is my only solution to use a @DiscriminatorFormula?
I ask because some prototyping gave us some results that I cannot explain.
Failed Prototype: Initially we prototyped a 3-deep class hierarchy using one @DiscriminatorColumn on the super class and included the second @DiscriminatorColumn on subclasses. Of course we got this warning:
Discriminator column has to be defined in the root entity, it will be ignored in subclass
We found that updates worked, but inserts did not. So we scrapped that idea.
Successful? prototype: We then tried the following which seems to work: Omit the second @DiscriminatorColumn on the subclasses and just include the @JoinColumn on a foreign key (which we were going to need anyway). Perhaps, since the joins are to different types of objects, Hibernate/JPA seems to be able to figure out which subclass is correct. Can anyone explain that?
Should we scrap that and just use @DiscriminatorFormula to get the explicit relationship defined on the 2 discriminator columns?