I am migrating an old existing project to Springboot. I have following method:
public List<T> findAll(Class<?> clazz) {
Criteria search = entityManager.unwrap(Session.class).createCriteria(clazz);
List<T> entities = search.list();
return entities;
}
And another one:
public County findByName(String name) {
Criteria search = entityManager.unwrap(Session.class).createCriteria(County.class).add(Restrictions.eq("county", name));
County county = (County) search.uniqueResult();
return county;
}
This works but when i run the project I get following warning: Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA javax.persistence.criteria.CriteriaQuery instead
How can i convert it to using javax.persistence.criteria.CriteriaQuery
and still be able to receive the same result? I have never been using both of these APIs.
Thank for the help!