5

After updating hibernate-core from 5.6.9.Final to 6.0.2.Final my javax.persistence.Entity imports couldn't resolve. I discovered the dependency to javax.persistence-api is removed in hibernate-core 6.0.2.Final.

In 5.6.9.Final it's still here: https://search.maven.org/artifact/org.hibernate/hibernate-core/5.6.9.Final/jar

In 6.0.2.Final it's gone: https://search.maven.org/artifact/org.hibernate/hibernate-core/6.0.2.Final/pom

Can anyone please explain why it is removed? Should I add it myself or is it missing (is it a bug) in 6.0.2.Final?

Reporter
  • 3,897
  • 5
  • 33
  • 47
Raymond Domingo
  • 173
  • 2
  • 9
  • "Can anyone please explain why it is removed?" This is a question for manufactor. – Reporter Jun 02 '22 at 11:43
  • 1
    HIbernate 6 is a JakartaEE implementation and not a JavaEE implementation. So no it isn't gone it uses a different API. – M. Deinum Jun 02 '22 at 11:43
  • You should also switch your coordinates to [`org.hibernate.orm:hibernate-core`](https://search.maven.org/artifact/org.hibernate.orm/hibernate-core/6.0.2.Final/jar). Then you might have noticed that `javax.persistence:javax.persistence-api` had been **replaced** with `jakarta.persistence:jakarta.persistence-api` instead of simply removed. – Mark Rotteveel Jun 02 '22 at 13:00

1 Answers1

6

Hibernate 6 is an implementation of the Jakarta Persistence API not the Java Persistence API. See also the initial release notes.

So no it is not a bug it is intended as there is no Java Persistence API after version 2.2, as the development/maintenance of the EE APIs has been moved from Oracle to a foundation. With the new releases the packages have also changed (due to legal implication) and those are now in jakarta.persistence instead of javax.persistence.

All this is also why there is en extensive migration guide for moving to Hibernate 6.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224