Are Restrictions and Projections deprecated from Hibernate 5.2 onwards?

767 Views Asked by At

Are Restrictions and Projections deprecate from Hibernate 5.2 onwards? If so what are the JPA Criteria API equivalents.

Other Related Q's -

  1. Does the Hibernate Criteria Extensions API (which supports deprecated api have the Restriction an Projections as part of them still. If they do. Could you share the api doc)
  2. Is there some place where i can find what all api's/classes/methods are deprecated. I have gone through legacy-criteria , but it does not clearly say what all things are deprecated. It would have been nice if they listed them out explicitly.
2

There are 2 best solutions below

2
MWiesner On BEST ANSWER

Providing an answer for Hibernate 5.6.x:

  • Restrictions is not marked deprecated. Check the corresponding JavaDoc.

  • Projections, likewise, is also not marked deprecated, see related JavaDoc.

As it stands now, both classes are not deprecated for version 5.6.x. Nevertheless, Hibernate’s Criteria API is deprecated as such, and ongoing development (version 6+) will focus on the JPA Criteria API.

However, it seems open for debate if the JPA community will move forward towards the vendor-agnostic CriteriaBuilder.

Check the deprecation list of Hibernate‘s JavaDoc for an overview and further details.

4
Christian Beikov On

Hibernate 6 removed the legacy Hibernate Criteria API which was deprecated in 5.2 and with it, the two classes you asked for. Essentially, everything related to the legacy Criteria API (package and sub-packages of org.hibernate.criterion) is deprecated and shouldn't be used if you want to be able to easily migrate to 6.0+