JPA entity with abstract field needs discriminator


#1

Hello,
this is my first message.

Explaining my problem, i have some entities A,B,C,D that extend from an abstract class X, using @DiscriminatorColumn (so these entities use @DiscriminatorValue to define specific types).

I have another entity that has to contain a field of type X. How can i define this column in JPA? For example, the column has to accept only A,B values (types).
Can i use something like @DiscriminatorValue for the field?

Thanks


#2

What inheritance strategy are you using?


#3

I’m using @MappedSuperclass


#4

Discriminator column is not for MappedSuperclass. You should read the Hibernate User Guide for more details about entity inheritance.