Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Hibernate Criteria API Deprecated and if so what API should we use?

Just as the title says. Is it deprecated? It says in the dev manual that it is and we should user JPA Criteria, but in the user manual there is no mention of this.

like image 650
alambrache Avatar asked Feb 09 '23 16:02

alambrache


1 Answers

AFAIK and off looking at the Javadocs, the Hibernate Criteria API is not deprecated. However, there is a very good argument for using JPA over hibernate, as it means you can switch between persistence providers without having to modify your code. Where as if you go with the Hibernate Criteria API, then your code is completely tied in to Hibernate.

Update 06/07/16

From the Hibernate 5.2 documentation.

"This appendix covers the legacy Hibernate org.hibernate.Criteria API, which should be considered deprecated.

New development should focus on the JPA javax.persistence.criteria.CriteriaQuery API. Eventually, Hibernate-specific criteria features will be ported as extensions to the JPA javax.persistence.criteria.CriteriaQuery. For details on the JPA APIs, see Criteria.".

This means, the Hibernate criteria is usable as it isn't officially @Deprecated, but you should be using JPA instead!

like image 187
ConMan Avatar answered Feb 13 '23 02:02

ConMan