How to refer to a subclass specific field in a CriteriaQuery where the super class is queried?
I'm trying to achieve something like the following, using the JPA Criteria API: SELECT b FROM Box b JOIN SpecialItem s WHERE s.specialAttr = :specialAttr The objects are Box @Entity public class Box implements Serializable { ... @ManyToOne @JoinColumn( name = "item_id" ) Item item; ... } Item @Entity @Inheritance( strategy = InheritanceType.JOINED ) public class Item implements Serializable { @Id private String id; ... } SpecialItem @Entity public class SpecialItem extends Item { private String specialAttr; ... } My attempt EntityManager em = getEntityManager(); CriteriaBuilder cb = em