I have an entity class and a subclass based on that entity:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class A
As you've probably seen, the Hibernate team hasn't put a lot of work into defining how you do this.. the documentation simply states:
16.1.6. Handling inheritance
Native SQL queries which query for entities that are mapped as part of an inheritance must include all properties for the baseclass and all its subclasses.
So if you want to use Native queries it looks like you're stuck doing something like this. Regarding the concern about the subclass B changing, perhaps a slightly less onerous way of implementing this would be to try using LEFT OUTER JOIN syntax on the shared ID property:
entityManager.createNativeQuery("select a.*, b*, 1 as clazz_, from A a LEFT OUTER JOIN B b on id = a.id where procedure(f)",A.class).getResultList()
That way you'll always get all of the properties from B if you add or remove some.