• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Why use JPA over Hibernate?  RSS feed

 
Ranch Hand
Posts: 611
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why should I use Hibernate using it's java persistence layer i.e JPA. I can directly use Hibernate without the JPA. One reason I definitely know, I can switch between multiple JPA implementation frameworks without any pain. But if I am not wrong, anyone would change the ORM framework very rarely, unless they have a strong reason to do so.
Are there any other benefits of using JPA? But pros are backed with some cons as well. Are there any other cons of using JPA over Hibernate. Can someone please give me good exposure on this?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA is Specification, Hibernate is reference Implementation Hibernate is Implemented as per JPA Standards hope it gives some thought to it
 
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sanjeev Biradar wrote:JPA is Specification, Hibernate is reference Implementation Hibernate is Implemented as per JPA Standards hope it gives some thought to it


But that doesn't really address the question: with Hibernate, you can choose to use a proprietary Hibernate API, or JPA. I'd recommend going with JPA, not only because the code then adheres to a standard interface that can be independent of the specific implementation (which is almost always the right approach), but also because the JPA community will be wider. When you are looking for answers, help for JPA will be more widely available.
 
Puspender Tanwar
Ranch Hand
Posts: 611
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:But that doesn't really address the question: with Hibernate, you can choose to use a proprietary Hibernate API, or JPA. I'd recommend going with JPA, not only because the code then adheres to a standard interface that can be independent of the specific implementation (which is almost always the right approach), but also because the JPA community will be wider. When you are looking for answers, help for JPA will be more widely available.

Along with the plus point of community support, if someday I find JPA can't do any task but Hibernate can do, I can directly use Hibernate without JPA standards, right?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dunno. In almost 10 years of using JPA/Hibernate, I've never come across such a situation.
 
Puspender Tanwar
Ranch Hand
Posts: 611
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Dunno. In almost 10 years of using JPA/Hibernate, I've never come across such a situation.

Hello Bear, since you are the right person to ask, what would be the best way to learn JPA/Hibernate. Ofcourse I know the best way is to get hands-on, but I should know the basics first. As of now I have gone through the basics of JPA-Hibernate from an online video course and implemented whatever is adviced in that. But I really want to know, what book should I follow, since you know I am a beginner to persistence world. I already bought high-performance java persistence by Vlad Mihalcea, but that's not a beginners book actually(I bought because it was on black Friday sale).
It would be a great help if you can consult me the best resources.
 
Saloon Keeper
Posts: 4702
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sanjeev Biradar wrote:Hibernate is reference Implementation


No, EclipseLink is. Hibernate is probably more widely used, though.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:what would be the best way to learn JPA/Hibernate. Ofcourse I know the best way is to get hands-on


Yup. Write lots of code. But I got my start with Cameron McKenzie's book Hibernate Made Easy. I don't know if it still in print. The formatting is a bit wonky, but I found it a good place to start.
 
Puspender Tanwar
Ranch Hand
Posts: 611
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Puspender Tanwar wrote:what would be the best way to learn JPA/Hibernate. Ofcourse I know the best way is to get hands-on


Yup. Write lots of code. But I got my start with Cameron McKenzie's book Hibernate Made Easy. I don't know if it still in print. The formatting is a bit wonky, but I found it a good place to start.

It's not under print now. Amazon is selling a 2008 version copy which covers Hibernate 3.2.
So definitely it's not good for today actually.
 
Bartender
Posts: 19672
92
Android Eclipse IDE Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a real good reason to prefer Hibernate JPA over legacy Hibernate.

The Hibernate team was one of the most active participants in the creation of JPA.

Effectively, then, it was how they would have designed Hibernate with the resources and knowledge that they gained from their previous architecture.

The fact that you can (and I have done so) switch between JPA providers (from Apache OpenJPA to Hibernate JPA) with just 3 changes to a project's Maven POM and the addition of 2 simple config files is nice, too.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:So definitely it's not good for today actually.


Hibernate may have changed, but the core of JPA covered still exist. Hmm, perhaps yet another argument for JPA over the proprietary API.

In fact, I kinda look at it as a more general instance of "code to the interface, not the implementation".

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also read Java Persistence with Hibernate and found it to be very complete, but not as quite as approachable. There is a second edition out; not sure how up-to-date it is.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!