I am new to JPA.
As per my understanding, JPA is specification and Hibernate implements JPA and provide add on features along with JPA methods.
But I was going through JPA tutorials, where using EntityManager
object we can perform CRUD on data, without using Hibernate libraries!
So can anyone please let me know
EntityManager
methods, not using Hibernate?Please mention some useful link or example.
Much appreciate response.
Thanks.
You are right JPA is a specification. Hibernate, and EclipseLink are a couple of its implementations.
You have to specify the persistence provider(Hibernate, EclipseLink) in order to use the JPA implementation. The persistence providers have the implementation classes for JPA specifications.
You can't just use JPA, cause it is an API =), but there are plenty JPA implementations:
If you don't want to use Hibernate (or any other JPA provider), then you must implement your own provider, by giving an implementation for the javax.persistence.spi.PersistenceProvider interface. The question, is, why do you need re-invent the wheel ? If you don't like Hibernate, you can use one of the so many other JPA-Providers to choose from
JPA can be used without a JPA provider aka Hibernate, EclipseLink and so on only if the application server has already a JPA implementation. Most likely on the tutorials you have seen demos that were perfomed on such an application server.
Though this thread is pretty old, I felt it is worth breaking things down.
JPA: It Is just a specification. In simpler words. Set of interfaces.
Hibernate, Eclipse Link: Two of the many implementations of JPA. In addition to providing the basic implementations for the JPA specifications, Hibernate and Eclipse Link provide their additional functionalities. You can choose based on your need
Spring Data:
Maven:
mvn dependency:tree
Gradle:
gradle dependencies
You can use JPA alone without using Hibernate and Before should know about major points in between Hibernate vs JPA as given below.
Hibernate
JPA
you can't use JPA on its own. JPA is a specification, which defines an API for object-relational mappings and for managing persistent objects and you need a JPA provider to implement it, like Hibernate, EclipseLink.
No, you cannot perform CRUD operations with JPA alone. As JPA is just a specification, you need the implementation to perform database operations. The implementations are provided by Hibernate, EclipseLink, Ibatis, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.