With mapping class hierarchy to same table criteria query selects to many entities

Hello Hibernate Support,

I have two concrete classes, the base class DocumentContent and a derived class DocumentContentWithData:

DocumentContent {
    private Long documentContentId;
    private InputStream contentStream;
    private File importFile;
    ... and several other attributes
}

DocumentContentWithData extends DocumentContent {}

I defined a hibernate mapping for the two classes, for the class DocumentContent a mapping without the contentStream and for the class DocumentContentWithData a mapping with the contentStream .

Saving the data with the class DocumentContentWithData works and also getting the instances for both classes works with the method Session.get(Class, ID) .

However the query in the following code returns two entities in the contentList, one as instance of DocumentContent and the other as instance of DocumentContentWithData although there is only one entry with the importFile in the database (the importFile columns is unique):

CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
CriteriaQuery<DocumentContent> criteriaQuery = criteriaBuilder.createQuery(DocumentContent.class);
Root<DocumentContent> root = criteriaQuery.from(DocumentContent.class);
criteriaQuery.select(root).where(criteriaBuilder.equal(root.get("importFile"), importFile));
Query<DocumentContent> query = session.createQuery(criteriaQuery);
List<DocumentContent> contentList = query.getResultList();

Can someone explain this behavior. When I do not derive the class DocumentContentWithData from DocumentContent and duplicate all attributes it works. However this is not a very nice solution.

Kind regards
Thomas Mayr