Possible regression 5.6 to 6.1 - [SqmRoot not yet resolved to TableGroup]

I solved it this way for Hibernate 6:

    public PagedList<AufgabeDTO> getAufgabeDTOs(final LoadOptions loadOptions) {
        PagedList<AufgabeDTO> result = PagedList.empty();

        final var funktionFilter = loadOptions.detachFilterOption(Constants.FUNKTION_FILTER_OPTION).orElse(null);
        final var benutzerFilter = loadOptions.detachFilterOption(Constants.BENUTZER_FILTER_OPTION).orElse(null);
        final var fixedLoadOptions = fixLoadOptions(loadOptions);

        CriteriaBuilder countBuilder = repository.getEntityManager().getCriteriaBuilder();
        CriteriaQuery<Long> countQuery = countBuilder.createQuery(Long.class);
        Root<AufgabeDTO> countRoot = countQuery.from(AufgabeDTO.class);
        countQuery.select(countBuilder.countDistinct(countRoot));
        countQuery.where(getPredicates(countBuilder, countRoot, loadOptions, funktionFilter, benutzerFilter));
        final var tqCount = repository.getEntityManager().createQuery(countQuery.distinct(true));
        final var count = tqCount.getSingleResult();
        if (count > 0) {
            CriteriaBuilder cb = repository.getEntityManager().getCriteriaBuilder();
            CriteriaQuery<AufgabeDTO> cq = cb.createQuery(AufgabeDTO.class);
            Root<AufgabeDTO> aufgabeRoot = cq.from(AufgabeDTO.class);
            cq.select(aufgabeRoot);
            cq.where(getPredicates(cb, aufgabeRoot, loadOptions, funktionFilter, benutzerFilter));
            final var tq = repository.getEntityManager().createQuery(cq.distinct(true));
            final var data = tq.getResultList();
            result = new PagedList<>(count, data);
        }
        return result;
    }