Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JPA v/s Hibernate

 
Ranch Hand
Posts: 45
Google Web Toolkit Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Google Web Toolkit Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic