Why is criteria query deprecated in Hibernate 5?

Pritam Banerjee :

As we already know, criterion query is deprecated in Hibernate 5. It was such a useful feature in the previous versions of Hibernate. And it still performs better than HQL.

So what is the reason of it's deprecation in Hibernate 5 ?

And also this question is not a duplicate of this question as I want to know the reason of the deprecation of criteria query.

This is from here.

Hibernate offers an older, legacy org.hibernate.Criteria API which should be considered deprecated. No feature development will target those APIs. Eventually, Hibernate-specific criteria features will be ported as extensions to the JPA javax.persistence.criteria.CriteriaQuery. For details on the org.hibernate.Criteria API, see Legacy Hibernate Criteria Queries.

Naros :

We are deprecating the Criteria API in lieu of JPA extension support.

Consider this:

CriteriaBuilder cb = entityManager.getCriteriaBuilder();
HibernateCriteria hc = cb.unwrap( HibernateCriteria.class );
...
query.where( hc.someAwesomeThing( ... ) );
List<SomeEntity> entities = entityManager.createQuery( query ).getResultList();

Contrary to comments, we do intend to continue to deliver Hibernate-specific features, but we want to introduce those through the standard API instead rather than trying to manage keeping two very different APIs that are meant to be complementary in sync.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=421784&siteId=1