We have an inheritance hierarchy say like this:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery("select NEW package.BaseClass(bc.field1, bc.field2) from BaseClass b")
public abstract BaseClass {
public BaseClass(int field1, String field2) {
}
}
@Entity
public SubClass1 extends BaseClass {
}
and similarly SubClass2
Now the problem I face is with the @NamedQuery
syntax here, which does not allow me to create List objects because it cannot instantiate BaseClass using constructor. So can anyone suggest how to solve this while leaving the named query in base class itself?
Or please tell me if there is a way to exclude a column in the select as in
select bc.*Field3 from BaseClass
or some syntax like that prevents the lazy loading of association field3 that I don't need in this case?