@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
public abstract class BaseClass {
private String baseClassProperty;
}
@Entity
@DiscriminatorValue(value = "A")
public class SubClassA extends BaseClass {
private String subClassAProperty;
}
@Entity
@DiscriminatorValue(value = "B")
public class SubClassB extends BaseClass {
private String subClassBProperty;
}
final TypedQuery<BaseClass> query = manager.createQuery("SELECT d FROM BaseClass b WHERE b.baseClassProperty='some value'", BaseClass.class);