Why has javax.persistence-api been replaced by jakarta.persistence-api in spring data jpa starter?
Asked Answered
C

3

71

I've recently started to learn spring boot, data jpa. As I can see from this, the spring boot data jpa starter uses jakarta.persistence-api instead of javax.persistence-api:

   <artifactId>spring-boot-starter-data-jpa</artifactId>
   ...
   <dependencies>
      <dependency>
         <groupId>jakarta.persistence</groupId>
         <artifactId>jakarta.persistence-api</artifactId>
      </dependency>

      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <exclusions>
            <exclusion>
               <groupId>javax.persistence</groupId>
               <artifactId>javax.persistence-api</artifactId>
            </exclusion>
            ...
         </exclusions>
      </dependency>
   </dependencies>

What is the differences between jakarta.persistence-api and javax.persistence-api? What is the reason of this replacement?

Cheka answered 1/2, 2020 at 23:0 Comment(0)
C
115

From Java Persistence API on Wikipedia:

The Java Persistence API (JPA), in 2019 renamed to Jakarta Persistence, is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition/Jakarta EE.

After Java EE was open sourced by Oracle and gave the rights to the Eclipse Foundation they were legally required to change the name from Java as Oracle has the rights over the Java brand. The name Jakarta was chosen by the community. You can find more information by reading Transition from Java EE to Jakarta EE and Jakarta EE - No Turning Back.

Catchascatchcan answered 2/2, 2020 at 9:24 Comment(3)
Thanks - but which API shall be used and when? I started a new spring-boot project after a long time, and now I am confused about the correct package to use and why?Florentinoflorenza
@AbdealiChandanwala you can refer to this answer as it's a bit more complicated than that: #71180160Catchascatchcan
Spring Boot 3/Spring Framework 6 have upgraded to Jakarta EE 9+, hence the corresponding version of Spring Data JPA is now on the "jakarta" versions of things. Spring Boot 2.7 and earlier are still on "javax" versions of things.Bethought
A
1

That's because Oracle has the rights over the “Java” brand. So to choose the new name, the community voted and picked: Jakarta EE. Here is what has changed from javax. to jakarta.

you should search for your library here as well to make sure it has been changed to jakarta. note that not all libraries changed some are still the same with javax like javax.naming

Alphonsealphonsine answered 15/5 at 12:55 Comment(0)
F
0

I'm also not getting javax.persistence-api but for me jakarta.persistence-api working fine we can use it. I think so, well I'm working on java 17 with Starting Servlet engine: [Apache Tomcat/10.1.24] + Hibernate ORM core version 6.4.8.Final.

Fattish answered 10/6 at 6:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.