• 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

Hibernat versus EJB 3.0

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Someone asked me to help decide whether this company should launch a new project using Hibernate or JEE5 (with EJB 3.0 for persistence). i.e. should they use an implementation of Hibernate or the JEE5 application server, considering mostly the persistence and object-relational functionality, but with interest in general capability to grow.

I don't know Hibernate. So, I reviewed the tutorial
http://www.hibernate.org/hib_docs/v3/reference/en/pdf/hibernate_reference.pdf

The following comparisons seem to suggest that if they use EJB, which entails that they would be using JEE5 in this case, then they would have all of the capabilities of Hibernate and some that Hibernate does not (or not cleanly).

I would appeciate some constructive comments about my comparisons.
I have already passed this by a Hibernate enthusiast (self-proclaimed expert) but he didn't know about some of Hibernate's capabilities that are mentioned here (in the Tutorial). I will edit this comparison if people give me verifiable corrections.

Thanks in advance for your thoughts.

COMPARISON...

(I added 'EJB3' where the feature is provided directly by the
EJB3 container implementation and JEEx features cooperating with the JPA
or the EJB3 feature is very closely integrated within the JEE5 framework.)

-end- (so far)

[ I made some of my wording more precise to what I intended, based on the following people's responses. ]
[ May 23, 2008: Message edited by: juan prieur ]
 
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
I'm not sure I follow your comparison. EJB 3.0 provides enterprise components that do a whole bunch of "enterprisy" things, Hibernate is an ORM that does specifically ORM things. Sure Hibernate doesn't provide all the things EJBs do, but why should it?

That aside, EJB doesn't provide most of the things you list, something that implements the JEE standard does. Its also worth noting that JEE doesn't in itself provide an ORM framework. It defines a standard (JPA) that providers can implement. And one of the providers available is .... Hibernate.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the big things I'd be interested in is vendor support.

You can use Hibernate pretty much anywhere. And you can use Hibernate with JPA on any JVM that supports annotations. Now, how many servers support JEE5 and EJB 3.0?

So I might add pervasiveness to the comparison list. Hibernate is much more pervasive.

-Cameron McKenzie
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul, Thanks for your insightful feedback. I updated my wording quite a bit. It would help me a great deal if you would point out 2 or 3 of the features in my updated list that seem to you to not be true of EJB3 or JEE5 as I defined them for my comparison table. I don't know what you were referring to (even in my original wording) by "most of the things".... Maybe my rewording clears that up?

Originally posted by Paul Sturrock:
... EJB doesn't provide most of the things you list, something that implements the JEE standard does. ...


[ May 23, 2008: Message edited by: juan prieur ]
 
Paul Sturrock
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
Ah. You've updated your table, so it makes more sense now.

However JEE vs Hibernate still doesn't. For example, comparing JMX support in JEE and Hibernate: JEE provides JMX support, Hibernate does not. But then why should Hibernate provide anything other than ORM capabilities? JMX is not an ORM capability. So I'm still not sure I follow what it is you are trying to achieve by doing this?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right now you are comparing apples to oranges, or actually I should say comparing apples to a slice of an apple.

EJB 3.0 and JEE 5 are specifications, within that specification is the JPA specification, which Hibernate implements. so JPA is a slice of EJB 3.0 and JEE 5.0 (you can even run JPA outside of EJB 3.0 and JEE 5), and Hibernate is an implementation of that slice.

So if you go EJB 3.0 and JEE 5 it doesn't disallow the use of Hibernate.

Like was said before Hibernate is an ORM, not an implementation of the Web Services spec of JEE 5, or an implementation of JSF or Servlets, etc.

"custom SQL is encouraged to be in business tier and use JDBC."
and yes to EJB 3.0?

I highly highly recommend not putting JDBC code in your business tier (using any technology)

What do you define business tier? You could have JDBC code in your Data Access Layer, and that layer might reside in the business tier machine, but that is a more a different decision that is not based on the technology/apis you choose.

Hope this helps.

Mark
[ May 23, 2008: Message edited by: Mark Spritzler ]
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My purpose is
"to help decide whether this company should launch a new project using Hibernate or JEE5 (with EJB 3.0 for persistence). "

I don't mean to suggest that one framework is "better" than the other. The project in question faces having to train (maybe hire) staff to start using java (yikes!), administrating, and the rest. As such, they wouldn't want to encourage people to mix frameworks if it could be avoided by using just one. The managers don't know enough about either (any) such frameworks to make a decision for the organization alone. They need to be concerned with longer term viability, as the larger organization mandates use of web services, single-signon, soap, etc.
I don't want them to stumble and blame me later for advising what may later seem to have been the less flexible approach.

Originally posted by Mark Spritzler:
... if you go EJB 3.0 and JEE 5 it doesn't disallow the use of Hibernate. ...

If they go EJB3/JEE5, is there any compelling reason to start off with Hibernate?

Of course, my point of view is limited by not knowing Hibernate. Frankly, I was told that because I'm familiar with J2EE/JEE5/EJB2.1/3 that I would love it. But Hibernate's annotations, DDs, and things look really wierd to me.
Again, thanks for your help.
[ May 23, 2008: Message edited by: juan prieur ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Juan, I am not trying to argue here, just to point out that it isn't an either/or question.

It is, are you going to use the JPA part of the EJB 3.0 specification? And if so, what implementation? It could be Hibernate.

Also, EJB 3.0 is a specification and not a framework. Hibernate is an ORM framework that implements part of the EJB 3.0 specification.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The project in question faces having to train (maybe hire) staff to start using java (yikes!), administrating, and the rest. As such, they wouldn't want to encourage people to mix frameworks if it could be avoided by using just one.



If they go EJB3/JEE5, is there any compelling reason to start off with Hibernate?



I'd say the compelling reason being the number of people that use Hibernate, so it would be easier to find people, then say a framework that no one has heard of. And if later you need to bring someone in that already has Hibernate experience, it would be easier to find such a person that can read an understand your code. If you use just the JPA implementation in Hibernate, then you don't even need to hire someone that just knows Hibernate, you can hire someone that only knows the JPA specification, and they can read and maintain your code.

Also, to bring up other ORM products that also implement JPA. You have Toplink, and openJPA. Both of which are also fantastic products.

Mark
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
I appreciate your constructive points. In regard to the advantages of Hibernate which stem from lots of people knowing Hibernate's JPA:

Originally posted by Mark Spritzler (excerpted):
I'd say the compelling reason being the number of people that use Hibernate, so it would be easier to find people, ... that can read and understand your code. ... you can hire someone that only knows the JPA specification, and they can read and maintain your code.



I see it like this:

1. Lots of people know JPA, as a result of knowing Hibernate.
2. Hibernate supports JPA. They can read your Hibernate or EJB3.0 JPA code.
3. therefore, Hibernate has an advantage over other frameworks.

Lets apply the same reasoning to JEE5 with EJB 3.0:

1. Lots of people know JPA, as a result of knowing Hibernate.
2. EJB 3.0 supports JPA. They can read your EJB3.0 or Hibernate JPA code.
3. therefore, EJB 3.0 has the same advantage over other frameworks.

Since we reach the same advantage with EJB 3.0 as with Hibernate, considering this point alone, premise #1 (lots of people...) does not provide a "compelling" reason for choosing Hibernate instead of EJB 3.0.

Of course, there might be other reasons to consider. e.g. the xxx.cfg.xml conventions are very different, so this reasoning applies to the annotations of JPA, not the whole thing.
Cheers!
[ June 04, 2008: Message edited by: juan prieur ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic