I'll start with a sanitized example.
In my system, I've got the class Car. Car has a number of fields, among which is the gearShift instance of class GearShift.
public class Car {
private GearShift gearShift;
// Snip
}
GearShift is an abstract class, from which AutomaticShift and StickShift inherit. This is mapped in Hibernate as table-per-subclass.
Now, say I want to get the cars with automatic gear shifts. I'd prefer doing this through Hibernate criteria, so I'm imagining an "ofType" restriction I can add, like shown below.
getSession().createCriteria(Car.class)
.add(Restrictions.ofType(AutomaticShift.class)
.list();
Is this possible in any way?
OLD:
How about this?
EDIT:
This should do the trick;