I'm facing an issue with Hibernate after upgrading to version 6.0.0 (it was working fine in previous versions). I have the following code snippet:

 CriteriaBuilder builder = session.getCriteriaBuilder();
 CriteriaQuery<T> criteria = builder.createQuery(classe);
 Root<?> root = criteria.from(fatherClass);
 Join<?, T> join = root.join(table);
 criteria.select(join).where(builder.equal(root.get(nameField), id));
 TypedQuery<T> query = session.createQuery(criteria); // QueryTypeMismatchException
 List<T> resultList = query.getResultList();

When I execute this code, I receive the following error:

org.hibernate.query.QueryTypeMismatchException: Specified result type [com.hcf.test.entities.TestEntitiyParent] did not match Query selection type [com.hcf.test.entities.TestEntitiyChildren] - multiple selections: use Tuple or array

This error didn't occur in previous versions of Hibernate but started happening after the update to version 6.0.0. Can someone explain why this is happening and how I can resolve this issue in Hibernate version 6.0.0?

Any help or guidance will be greatly appreciated. Thank you!

0

There are 0 answers