• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

difference between hibernate and ejb

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
by my understanding, i believe that ejb is just api , but hibernate is bunch of concrete classes that implement the ejb api.

so what is the difference between them?


 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not really, Hibernate is just a persistence framework, where you map beans to DB tables, however EJB is much bigger than hibernate and it mainly consists of:

1) persistence layer which are named entity beans.
2) session beans, which contain the business of your operations.
3) message driven beans which are used for Java Messaging.

in addition EJB forces the container to deal with Transaction management, demarcation, resource look up... etc. so when using EJB you will be just seeing business logic and not code used to open sessions, close sessions, manage transactions, timer services ... etc. code is much cleaner and the programmer focus only on the business, and the container does all the job of transactions, sessions etc.

in addition with EJB 3 a new concept of Dependency Injection has been introduced, which makes coding much more easier. don't forget that EJB 3 is a specification and when you are working on big projects (distributed projects) you would feel how much EJB is great.

finally in EJB 3 a new API has been introduced that allows you to map beans to tables using annotations which is the Java Persistence API, and its also used by hibernate . and a new query language somehow similar to HQL but much more powerfull where it allows you to make insert/update queries too.

for my experience EJB 2 is hell, while EJB 3 is really heaven. the only missing thing is the ability of using DI in POJO's too.
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your valuable reply
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why do people always combine hibernate and ejb3 to code their application, instead of just using ejb3? since to me, i feel like ebj3 can do everything hibernate does, and it does something extra, such MDB.
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim,

Hibernate 3 implements JPA 1.0, which is part of EJB 3.0 (in fact, becoming EJB 3.0 compliant was the major feature for Hibernate 3, including annotation support). In terms of Hibernate specific features that have not been standardized in EJB 3.0, really the criteria API is the most significant, which is being standardized in JPA 2.0. I personally have never had a reason to use the Hibernate criteria API, so do not consider it that important.

As to POJO injection with EJB 3.0, you can use Seam, Guice or even Spring with EJB 3.0 for that.

Hope it helps,
Reza
 
reply
    Bookmark Topic Watch Topic
  • New Topic