Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we use jpa without hibernate

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

  1. Can I use JPA alone using EntityManager methods, not using Hibernate?

Please mention some useful link or example.

Much appreciate response.
Thanks.

like image 420
Ali Avatar asked Mar 18 '13 21:03

Ali


People also ask

Does JPA need Hibernate?

Hibernate provides a reference implementation of the Java Persistence API that makes it a great choice as an ORM tool with the benefits of loose coupling. Remember, Spring Data JPA always requires the JPA provider such as Hibernate or Eclipse Link.

Why we use Hibernate over JPA?

Java Persistence API (JPA) defines the management of relational data in the Java applications. Hibernate is an Object-Relational Mapping (ORM) tool which is used to save the state of Java object into the database. It is just a specification. Various ORM tools implement it for data persistence.

Does spring data JPA use Hibernate?

This is the type of code Spring Data JPA helps to avoid. Spring Data JPA is really a set of dependencies that makes it easier to work with a JPA provider. Hibernate is one of several JPA providers. This means you can use Spring Data JPA without using Hibernate (if you really wanted to).

Can we use both JPA and Hibernate?

You cant actually use both of them in the same application.


1 Answers

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.

like image 112
bornleo Avatar answered Oct 04 '22 16:10

bornleo