Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARN [deprecation] HHH90000022: Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA javax.persistence.criteria.CriteriaQuery instead #558

Open
natechadwick opened this issue Jul 27, 2022 · 1 comment · Fixed by #1086, #1108 or #1101
Assignees
Labels
dependencies Pull requests that update a dependency file techdebt Technical debt
Milestone

Comments

@natechadwick
Copy link
Member

natechadwick commented Jul 27, 2022

The old hibernate Criteria query has been deprecated and is removed in hibernate 6.0 the next version. We need to update all of the places that we are using the old Criteria query to use the new JPA style query.

Old Example:

Session session = getSession();
        List<PSIntegrityStatus> results = new ArrayList<>();

        Criteria crit = session.createCriteria(PSIntegrityStatus.class);
        if (status != null)
            crit.add(Restrictions.eq("status", status));
        crit.addOrder(Order.desc("startTime"));
        results = crit.list();


        return results;

Fixed Code:

Session session = getSession();

        CriteriaBuilder builder = session.getCriteriaBuilder();
        CriteriaQuery<PSIntegrityStatus> criteria = builder.createQuery(PSIntegrityStatus.class);
        Root<PSIntegrityStatus> critRoot = criteria.from(PSIntegrityStatus.class);

        if (status != null)
            criteria.where(builder.equal(critRoot.get("status"), status));

        criteria.orderBy(builder.desc(critRoot.get("startTime")));

        return entityManager
                .createQuery(criteria)
                .getResultList();
@natechadwick natechadwick added bug Something isn't working dependencies Pull requests that update a dependency file labels Jul 27, 2022
@natechadwick natechadwick added this to the 8.1.2 milestone Jul 27, 2022
@natechadwick natechadwick added the In Progress Work is in progress label Jul 27, 2022
@natechadwick natechadwick removed the In Progress Work is in progress label Sep 13, 2022
@natechadwick natechadwick added techdebt Technical debt and removed bug Something isn't working labels Aug 30, 2023
@natechadwick natechadwick modified the milestones: 8.1.2, Future, 8.1.4 Aug 30, 2023
@natechadwick
Copy link
Member Author

This needs broken down as it is used all over the place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment