Why is @ForceDiscriminator
or its equivalent @DiscriminatorOptions(force=true)
necessary in some cases of inheritance and polymorphic associations?
Guys let me try to explain about @DiscriminatorOptions(Force=true)
.
Well , it is used in single table inheritence, i have recently used this in one of the scenario.
i have two entities which was mapped to single table. when i was trying to fetch the record for one entity i was getting list of result containg records from both the entities and this was my problem. To solve this problem i have used @DiscriminatorOptions(Force=true)
which will create the predicate using Discriminator column with the specified value mapped to the corresponding entity.
so the query will be look like this after i used @DiscriminatorOptions(Force=true)
select *
from TABLE
where YOUR PREDICATE AND DiscriminatorColumn = DiscriminatorValue