Why is @ForceDiscriminator
or its equivalent @DiscriminatorOptions(force=true)
necessary in some cases of inheritance and polymorphic associations?
I think this is more of my opinion but I think some will agree with me. I prefer the fact that Hibernate enables you to not use a discriminator. In several cases the discriminator isn't necessary.
For example, I have a Person
entity which contains stuff like a name, a date of birth, etc. This entity can be used by several other entities like Employee
or Customer
. When I don't reference Person
from other entities, but reference Employee
or Customer
instead, the discriminator isn't used as Hibernate is instructed to fetch either one.