About the use of @ForceDiscriminator/@DiscriminatorOptions(force=true)

后端 未结 4 412
傲寒
傲寒 2021-01-04 04:43

Why is @ForceDiscriminator or its equivalent @DiscriminatorOptions(force=true) necessary in some cases of inheritance and polymorphic associations?

4条回答
  •  清酒与你
    2021-01-04 04:59

    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
    

提交回复
热议问题