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

后端 未结 4 428
傲寒
傲寒 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:53

    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.

提交回复
热议问题