4

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.

alambrache
  • 108
  • 1
  • 9

1 Answers1

8

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!

ConMan
  • 1,642
  • 1
  • 14
  • 22
  • 2
    It seems to be now, Hibernate 5.2. – Damian Jun 16 '16 at 14:25
  • ish, I believe the situation is as it was last year, in that Hibernate haven't @Deprecated the api, but are telling people to stop using it in favor of using JPA (which you should be doing anyway!) – ConMan Jul 06 '16 at 14:25
  • They're causing a lot of pain. How to accomplish spatial queries right now? It was a pretty way to run queries through hibernate criteria... – joninx Jul 12 '16 at 13:12