1

What is the real difference beetwen javax api about jpa and persist method and save method about hibernate?

For example: If a use javax package and api , I will use persist method. But what is the difference about persist in javax package and save for hibernate?

developing
  • 11
  • 1
  • 2
    Not quite the answer, but I recommend reading https://stackoverflow.com/q/9881611/11948496, jpa is not actually doing anything, it is just a specification. – MDK Jul 23 '22 at 09:40
  • 3
    Hibernate is a (the reference-)implementation of JPA. Thus, Hibernate implements all JPA-specified methods, plus some extra. – Turing85 Jul 23 '22 at 09:49
  • You write your code. If you deploy it, for example to a wildfly server, then it's hibernate who does the job. If you deploy it to a payara server, it will be EclipseLink. – grigouille Jul 23 '22 at 13:14

2 Answers2

0

To be specific

  1. JPA is a specification for the ORM. JPA does not provide any implementation.

  2. Hibernate is a implementation of the JPA specification. Hibernate also provide some extra feature on top of JPA.

  3. Not only hibernate, there are other implementations available of JPA.

If any hibernate specific implementation is used, after that we change the underlying jpa implementation, then your code base needed to be update.

Ratul Sharker
  • 7,484
  • 4
  • 35
  • 44
  • jpa for example does not have persist method? Implemented in package javax? Or this is always hibernate? – developing Jul 26 '22 at 08:06
  • What should be the method name, the resulting entity state upon calling that method these specification is defined inside JPA. These specification is defined inside the `javax` package as a interface. Those implementation is provided by `hibernate` like jpa implementation provider. Hiberate implements those interfaces to provide implementations. – Ratul Sharker Jul 26 '22 at 10:01
0

Hibernate includes all the JPA API, as JPA is a specification and Hibernate its implementation. At the same time, Hibernate provides some features on top of standard JPA. So, simply saying, Hibernate embraces the JPA API and extends it with additional features.

aleksey.stukalov
  • 706
  • 4
  • 16