Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA or Hibernate for Java Persistence?

I'm researching the development of Enterprise Applications in Java, .NET and Groovy. For each platform, we're going to try how hard it is to realize a simple SOAP web service. We'll use the tools and libraries that are most commonly used, to research the real world as accurately as possible.

In this regard, when using Hibernate for persistence, would it better reflect the real world to use the new JPA (Java Persistence API), or the Hibernate custom API that existed before JPA came around?

like image 675
Bart van Heukelom Avatar asked May 08 '09 08:05

Bart van Heukelom


People also ask

Is JPA a persistence layer?

JPA and EJBEach EJB container includes a persistence layer, which is defined by the JPA specification.

Why we use Hibernate instead of 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.

Which is better Spring data JPA or Hibernate?

Conclusion. Hibernate is a JPA provider and ORM that maps Java objects to relational database tables. Spring Data JPA is an abstraction that makes working with the JPA provider less verbose. Using Spring Data JPA you can eliminate a lot of the boilerplate code involved in managing a JPA provider like Hibernate.

What is hibernate in JPA?

Hibernate. 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.

What is JPA (Java Persistence API)?

What is JPA? A JPA (Java Persistence API) is a specification of Java which is used to access, manage, and persist data between Java object and relational database. It is considered as a standard approach for Object Relational Mapping.

What is the difference between JPA and Dao and hibernate?

JPA: Agnostic way to do Java persistence without coupling your clients to Hibernate, TopLink, etc. Hibernate: Good choice if you have an object model to map to. JDBC: All Java persistence is built on this. Lowest level. DAO: More of a pattern than a technology; CRUD operation interface.

Which of the following ORM tools implements JPA specifications for data persistence?

So, ORM tools like Hibernate, TopLink, and iBatis implements JPA specifications for data persistence. What is Hibernate? A Hibernate is a Java framework which is used to store the Java objects in the relational database system.


1 Answers

As you're probably already aware, as of 3.2 Hibernate is JPA certified. You can easily use Hibernate as your JPA provider without having to use any of Hibernate's "custom" APIs.

I'd recommend using straight JPA with Hibernate as the provider. And use annotations rather than XML (much nicer).

Then when you need a little something extra you can always get the Hibernate Session. For example I often find I need to do this in order to pass a collection to a query as a parameter (setParameterList).

like image 106
Damo Avatar answered Sep 24 '22 05:09

Damo