Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA v/s Hibernate

 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I was creating a Struts+Spring+hibernate+JPA application, as on the struts web site. I was wondering, what is the reason to use JPA and hibernate, as either of them are also fine as for an ORM. And also which one is better and why???

Regards,
Rudradutt Joshi
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rudradutt,

JPA is a specification which lays down a set of standard rules which are followed by implementations of that specification. Hibernate is just one such implementation of that specification. Hibernate in addition to complying with JPA, might provide its own vendor specific features.
 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply,

At a phase, I required to build a query with criteria (hibernate), but as I am using JPA over hibernate, Entitymanager do not provides support for criteria, and indeed its a power full api. Can you please explain me how or why for the same?
 
Damodar Mukherjee
Ranch Hand
Posts: 135
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran Pai,

Can You please explain how Hibernate fits with EJB3?

Why people use Hibernate in EJB3 projects as EJB3 has a rich Entity Bean?

Thank You in Advance...
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Damodar Mukherjee:
Can You please explain how Hibernate fits with EJB3?

To be very clear Hibernate is not part of the EJB3 spec. Hibernate is an ORM tool and is an implementation of the JPA specification. The JPA spec is part of EJB3.

Originally posted by Damodar Mukherjee:
Why people use Hibernate in EJB3 projects as EJB3 has a rich Entity Bean?



In EJB3, the entity beans are refered to as just Entities (since they are just Plain Old Java Objects). The persistence capabilities for Entities are provided by persistence providers (Ex: Hibernate, TopLink etc...) which follow the JPA spec.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:Rudradutt,

JPA is a specification which lays down a set of standard rules which are followed by implementations of that specification. Hibernate is just one such implementation of that specification. Hibernate in addition to complying with JPA, might provide its own vendor specific features.



First of all sorry for extending the Thread .

What advantage do we get by getting Hibernate instances / components through JPA specified API .(instead of using Hibernate directly)??

Waiting for your valuable responses
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same advantage you have getting any implementation through an interface. You can change the implementation without changing your application logic.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think JPA was enriched as part of EJB3 and many companies like to follow standards, and EJB is one such standard prevalent throughout the industry.
If a particular organisation is using EJB stateless session beans, it may use JPA over hibernate.
In other words, its all about standards that organisations follow.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic