Is it not possible to query by superclass?
ie if I have superclass that may or may not be persistent, may or may not be abstract and a bunch of concrete persistent subclasses.
(eg in a single table per hierachy where MyTop maps to the single table)
Code:
MyTop
/ \
MyMiddle ClassA
/ | \
ClassX ClassY ClassZ
Can I not say:
select x.id from MyTop x where x.class = MyMiddle
or possibly
select x.id from MyTop x where subclassOf(MyMiddle)
returning the ids of any persisted objects of classes: MyMiddle.class, ClassX.class, ClassY.class, ClassZ.class
Is there no mechanism to achieve this? I'm resorting to a boolean flag when the information is already there in the discriminator. Surely hibernate can construct the necessary SQL ie:
Where discriminator='MM' or discriminator='X' or discriminator='Y' or discriminator='Z'
If I have to do that then my code is not future proof when I add more subclasses.
Thanks.