I will start with a disinfected example.
In my system, I have a Car class. The car has several fields, including an instance of the GearShift of the GearShift class.
public class Car {
private GearShift gearShift;
}
GearShift is an abstract class from which AutomaticShift and StickShift are inherited. This maps to Hibernate as a table per subclass.
Now, let's say I want to get cars with an automatic transmission. I would prefer to do this using the Hibernate criteria, so I present the "ofType" constraint that I can add as shown below.
getSession().createCriteria(Car.class)
.add(Restrictions.ofType(AutomaticShift.class)
.list();
Is this possible anyway?
source
share