Home Criteria API: filter by class type
 I'm relativley new to relational databases and I have some problems concerning the creation of queries. First I want to explain the situation shortly. I have several entity classes. All of them extend AbstractEntity or EntityProperty. So entities can have properties and properties have owning entities, so there is a bidirectional relation. Now let's say ConcreteEntity extends AbstractEntity and I want to create queries like this: Get all entities of type ConcreteEntity which has at least on property with a name contained in the given list propertyNames. Until now I have the following working criteria query: CriteriaQuery cq = cb.createQuery(AbstractEntity.class); Root property = cq.from(EntityProperty.class); Join entity = property.join(EntityProperty_.owningEntities); cq.where(property.get(EntityProperty_.name).in((Object[]) propertyNames)); cq.select(entity);  But now I want only those entities of type ConcreteEntity. How could I achieve this? In JPQL I wrote "SELECT entity FROM EntityProperty property JOIN property.owningEntities entity" and here I also have no idea how to write it in the way that only a specific type is returned... Thanks for answers in advance! EDIT: moved the second question to criteria query: indistinct result lists and removed distinct in the code (that didn't work)