• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB and hibernate --same or different  RSS feed

 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of having EJB and hibernate in a project?
I thought hibernate is an alternative to EJB? Please clear me on this.
 
Michael O'Leary
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shah rah wrote:What is the purpose of having EJB and hibernate in a project?
I thought hibernate is an alternative to EJB? Please clear me on this.


Hibernate shouldn't be thought of as an alternative to EJB, with exception to CMP (container-managed persistence). Hibernate basically gives object/relational mapping functionality. Although EJB does have POJO which provides object/relational mapping. Hibernate is great if you don't want to bother writing SQL, but I much prefer EJB. As far as using both in a project...well sure its can be done (and is supported obviously), but I have never done it, nor found a good enough reason to. Hope that helps.
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shah rah wrote:What is the purpose of having EJB and hibernate in a project? I thought hibernate is an alternative to EJB? Please clear me on this.

EJBs include Session, MDB & persistence, whereas Hibernate is for the persistence (O/R Mapping framework). While EJB3 introduces the standard way for O/R Mapping (JPA) you can use hibernate (or any other O/R Mapping framework which supports JPA) behind the scene for the persistence of your application.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB (I'm speaking in-terms of EJB 3) is a specification in which JPA is a part of it and Hibernate could be said as the reference implementation of the JPA specification.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!