aspose file tools*
The moose likes Object Relational Mapping and the fly likes Disappointed w/ Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Disappointed w/ Hibernate" Watch "Disappointed w/ Hibernate" New topic
Author

Disappointed w/ Hibernate

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
Well, I've spent the last two weeks cramming Hibernate into my head and I thought I'd come here and get Javaranch users' opinions.

As for myself, I'm sorely disappointed w/ it. I had heard so much hype, so much promise, etc. - Now that I realize how needlessly complex it is to implement (for simple things) - there isn't any way I can sell my boss on it to use it at work. I was intrigued by the promise of reducing coding-time in my apps, lines of code, complexity, etc...I see none of that.

What I see in Hibernate is potential but I do not see *any* savings for a developer who's familiar enough w/ JDBC, SQL, and relational databases. Perhaps, given the learning curve of Hibernate and the need for complicated design patterns to manage sessions w/o throwing errors and getting unpredictable results (see: http://www.hibernate.org/43.html) - you're probably adding more development time, if anything. At best, you shift the amount of work you'd spend writing boilerplate code using plain JDBC to writing complicated xml descriptors, trying to find a way to manage sessions across application layers, and digging yourself out of holes.

I'm relatively new to Java having spent the last five years of my life making a living writing C#/.NET applications. Before anyone starts foaming at the mouth - I think Java and all the available technologies related to Java are far superior to anything Microsoft is doing or will do in the near future, so far as I can tell. We're actually switching from ASP, COM+, .NET, etc. to the Java platform at work since we've acquired companies who run Linux and need a common platform to develop on.

That being said...in the last few months I was able to pick up a few Java/J2EE books and have already written a few applications that perform/scale quite well and have exceeded my expectations - all using JDBC to talk to the data...without a single problem.

Hibernate, on the other hand, is slowly driving me insane. I post simple, polite questions on the hibernate forums and get zero answers, zero help, and mostly non-answers for those who occasionally reply to me. Yes, I'm inexperienced, I don't get it, otherwise I wouldn't be there posting stupid questions. I bought the Hibernate in Action book...I've read 3/4 of it and tested my eyeballs out and I still have questions - forgive me for my ignorance. This, of course, is why I love JavaRanch, BTW - people here are actually helpful.

So, now, what are others' opinions and experiences w/ Hibernate...given my post, is it something I should waste more of my time on? Am I just too simple?

Go ahead, let er' rip, gimmie your best shot.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15290
    
    6

I'll go...

Now that I realize how needlessly complex it is to implement (for simple things)

My opinion is that if the application is very simple, then adding hibernate into the mix is probably not a good idea.

At best, you shift the amount of work you'd spend writing boilerplate code using plain JDBC to writing complicated xml descriptors, trying to find a way to manage sessions across application layers, and digging yourself out of holes.

If you use the tool that hibernate provides via XDoclet and Ant Tasks, you typically never have to hand write any .hbm.xml files at all. Add Spring to that to handle all your transactions and sessions for you via services and your development and debugging time can really decrease. However, there is a very steap learning curve. And you just have to grind past that.

Hibernate, on the other hand, is slowly driving me insane. I post simple, polite questions on the hibernate forums and get zero answers, zero help, and mostly non-answers for those who occasionally reply to me.

The hibernate forums are horrible. I've been scorned several times on the hibernate forums.

Personally, I try to avoid Hibernate if possible. I think it's a good technology. And I have used it on a few projects. It's usually just too much for the size of projects I work on. I prefer iBatis. It's light, it's simple, and the iBatis team is VERY helpful.

[ September 23, 2005: Message edited by: Gregg Bolinger ]
[ September 23, 2005: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

well thats pretty much the same with JDO. However, JDO does make good sense and you can make some resonable headway from just a few sources. Well, there are actually _only_ a few sources anyway

I wont repeat myself here, but you can see my post a few posts down. I actually got it to work, now I need to pound it for a while and see what falls off.

I personally dont like xdoclet nor ant too much. Im sick of holding all these various technologies in my head. I have yet to even learn what / how spring works.

Why dont you try JPOX JDO and tell me which is better, tht way I wont have to try hibernate unless it is
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207

My opinion is that if the application is very simple, then adding hibernate into the mix is probably not a good idea.


I would agree...but I would say that a technology like this is useful if you're using a real object model vs. a hokey little app just spitting out raw JDBC ResultSet data. Mapping single classes to single tables is cake...and still convenient enough.


If you use the tool that hibernate provides via XDoclet and Ant Tasks, you typically never have to hand write any .hbm.xml files at all. Add Spring to that to handle all your transactions and sessions for you via services and your development and debugging time can really decrease. However, there is a very steap learning curve. And you just have to grind past that.


Well sure. My Honda sedan does great on the highway but if I want to go into outer space, all I have to do is weld rockets to the frame, build a launchpad, and take off! If that doesn't make any sense, let's put it this way. We can make anything work if we throw enough technologies at it and have all the time in the world...but I was under the impression that this stuff was meant to *reduce* complexity!?


The hibernate forums are horrible. Several hibernate team members are asses when it comes to answering newbie questions. I've been scorned several times on the hibernate forums. I'd also note that the hibernate team has recently removed any links and mentionings of Spring from their website. The reason being they want you to use (pay for) JBoss instead of using Spring's nice, easy, light container for session and transaction management.


After googling for hours this seems to be the general opinion - they're not very "open" or helpful at all. I've obviously wasted precious time posting elaborate examples of what I'm trying to do...and have gotten no help at all...even after buying their lame-ass book (which somehow, got rave reviews!?)


Personally, I try to avoid Hibernate if possible. I think it's a good technology. And I have used it on a few projects. It's usually just too much for the size of projects I work on. I prefer iBatis. It's light, it's simple, and the iBatis team is VERY helpful


I hear good things about iBatis but honestly, writing SQL, for me, has gotten so old, so tiring, that I was really expecting Hibernate to live up to the hype. As I said before, one to one mapping w/ single table to single object works great in Hibernate....I was even able to work through the session management nightmares...until I tried to map a persistent list...then all hell broke loose and I went and ranted about it!

It's exhuasting to work with if you're familiar w/ relational databases and aren't afraid of what's under the hood, I'm not sure about any real gains in productivity.

Thanks for the info!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

To me, the biggest selling point is about maintenance, and loose coupling. This is what creates less complex code. Sure writing JDBC works, but you are working at the low level, which makes maintenance later on more difficult.

Relationship mapping is always the biggest pain, but it is the learning curve that is the pain. Once you have successfully implemented the different types of relationships, then there are no more gotchas, because you have hit them all already. Makes for remembering what not to do next time.

Basically the development of these technologies stems from them first using JDBC first, and realizing the maintenance and tight coupling that occurs, then they try to decouple the SQL, and that helps, but not enough. Then they get the great idea that it would be great if all they had to do was deal with Objects that represent the data. And that leads to the mapping files. Then they want to get more OO on the object representation so that it can be represented in better OO principles and that leads to the complexity to learn.

No technology, as we know, is the Golden Hammer, the Answer to everything, and in some cases Hibernate will be overkill, and in cases of just a Client-Server application, RMI is overkill.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Christian Bauer
author
Ranch Hand

Joined: Aug 31, 2004
Posts: 45
Some factual corrections to the statemens made by Mr. Bollinger.


The hibernate forums are horrible. [removed my own hateful remark] I've been scorned several times on the hibernate forums.


This is not true. Your posting history on the Hibernate forum (http://forum.hibernate.org/search.php?search_author=gdboling) shows that you started 13 threads. Only one of them did not get any answers (not unusual for a forum with more than 150 questions/day). Some of your postings you answered yourself a few minutes later. In other threads you personally thanked David, Steve, Gavin, and me, for the help we provided you (and quite quickly, I might add). In not a single thread have you been "scorned" by anybody.

Personally, I think it would be great if you would stop calling people who helped you "asses" and something they spend a lot of time on "horrible".


[removed statement that was based on bad information and lack of research by myself]


This is not true. The page in question ("Hibernate with Spring" or something) was removed after

1) I made updates to the 2 year old page, adding content for Hibernate3, effectively showing that many things Spring did (quite well) for Hibernate2 are no longer necessary.

2) Juergen Hoeller, a prominent Spring developer, requested the page to be removed.

The reason certainly wasn't that we want people to "pay for JBoss", which would be quite difficult - it is free software.

---

As for the original poster: Nobody forces you to use an ORM tool. If it doesn't work for you, don't use it.
[ September 23, 2005: Message edited by: Gregg Bolinger ]

Co-Author of <a href="http://www.manning.com/bauer" target="_blank" rel="nofollow">Hibernate in Action</a>
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
The "gotchas" are what I've been plowing through, one-by-one...so yeah it sucks but it's getting easier. It makes me think that, given the popularity of Hibernate, there's a void that someone should fill with a Hibernate Gotchas & Workarounds book and/or wiki - this information is so dispersed it can take a dev a long time to assemble a working app!

I wish I had more time, I might assemble some kind of knowledge base like this.

The biggest gotcha is session management and lifecycle. This is complicated enough for users who are used to writing boilerplate code to bring data into an object model to step back and re-assess whether or not you're really creating more maintainable software.

Gregg, I looked into Spring and I thank you for the advice. I picked up the APress book "Pro Spring" and I'm going to dive into it this weekend...maybe next week I can bring Spring and Hibernate together to leap over the session management problems I'm having.

Thanks for the info guys.
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
Hi Vinnie,

Hibernate is very popular. I can confirm this from CodeFutures experience, where we had very many requests for Hibernate support with our FireStorm/DAO data persistence code generator. Hibernate support is the most requested

Hibernate a sophisticated solution to a complex object relational mapping problem. So it's hardly suprising that its a) not ideal for certain use cases and b) it's compex to use.

But then, there's no ideal Java persistence technology. The big debates between JDO and Hibernate are exactly because each has strengths and weaknesses. The same applies to JDBC and EJB CMP.

CodeFutures' position is that you choose the most appropriate persistence technology for the project - but we always recommend using data access objects to insulate your application from your persistence technology choice.

Your difficulties using Hibernate are hardly unique. It's got a very steep learning curve - no pain, no gain. A sure sign of this is that CodeFutures is already had strong sales for a new product release that has Hibernate support, despite the fact that its only a release candidate.

My take away message: You're not alone in having difficulties but don't give up on Hibernate.


PJ Murray -
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15290
    
    6

Christian,

A. You are not an individual I was speaking of.
B. You are assuming that is my only account on the hibernate forums, which it is not. There was a need during a period of time to post anonymously.
C. My mistake on the Spring info. I was misinformed and did not look close enough. I apologize for that statement being incorrect.

Vinnie,

Pro Hibernate 3 was an excellent book. You might take a look at that if you consider staying with Hibernate.

We can make anything work if we throw enough technologies at it and have all the time in the world...but I was under the impression that this stuff was meant to *reduce* complexity!?

As Mark stated no tech is the end all solution. Get past the mapping headaches, and hibernate solves more problems than it creates. It is not something you learn overnight. But it also is not the solution for every persistence problem. With anything, choosing the right tool for the job is just as important as everything else.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

from what I have seen the strengths vs weaknesses debate between hibernate and jdo are trivial. They have little to do with how you write your code. Just implementation details.

its always the compile time enhancement or runtime enhancement issue. I havent seen many argue that either is better.

As for mapping, I have dont all sorts of funky mappings in JDO and they have worked. My only headache with JDO was detach/attach stuff that I now feel is pretty useless. Once I stopped the attach/detach, im in the house. And im really speaking more of JPOX than JDO in general.
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
Probably very similar to my session management headaches w/ Hibernate. I've gotten my mappings to work...I'm doing great with it! However, The simple act of opening and closing a session is *very* frustrating as it has to either be managed by a container (Seam, Spring, JBoss, etc.) or you have to create one session per-request in order not to have threading wreak havoc and close one before you need it to be closed.

For example...If I create a servlet and open/close sessions *right* within the request inside of the servlet itself...everything works *swimmingly*. If I move this logic to a different layer...fughettaboutit. Now the context issue comes into play which was left unfinished by the Hibernate folks...hence the creation of "Seam" on their part.

Hibernate is a great, great technology, IMO (I can't speak for JDO, haven't tried it) - I'm just miffed about the session management thing...the rest of it was so intuitive and simple to learn...I was off and running in a few hours...doing most of the basics w/o a problem.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15290
    
    6

Vinnie,

I noticed a big improvement in Session management in Hibernate 3.x over Hibernate 2.x. Do you still have issues with Session management and H3?
Clark Anderson
Greenhorn

Joined: Sep 27, 2005
Posts: 1
Where can I find some real world case studies on succesful Hibernate implementations? I'm trying to justify a proof of concept project and I need some information for management.

Thanks,
Clark
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
Originally posted by Clark Anderson:
Where can I find some real world case studies on succesful Hibernate implementations? I'm trying to justify a proof of concept project and I need some information for management.

Thanks,
Clark


Hi Clark,

Hibernate's LGPL license is a fundamental characteristic of the product that detemines how its promoted. It's not a product that is sold - so there's not really need for product sales material like case studies and testimonials. The sales focus in JBoss is support, professional services, and training - that's the product.

Hibernate is very much a bottom up product - it arrives in organizations via developers. The LGPL ensures that. The theory/hope is that somewhere between 1 in 20,000 and 1 in 50,000 downloaders will purchase related services. It does not always work out that way of course - not many open source products achieve that conversion rate. All that means is that top down sales tools like case studies are not that relevant.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Clark, I work for Gateway computers and we use Hibernate and it works fine for our Order Processing System.

Mark
George Daswani
Greenhorn

Joined: Sep 28, 2005
Posts: 12
Hibernate is good for people who are actually using object models. Yes, it has a learning curve but once you get the hang of it, you change your habits and design your object model first before the DB.

Most Java developers tend to create code based on their DB designs which eventually leads to some half baked/hackish object models.

A large part of development time is spent on mapping objects -> databases, and it's an area where in my experience hibernate helped a lot.
[ September 28, 2005: Message edited by: George Daswani ]
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
Originally posted by George Daswani:
Hibernate is good for people who are actually using object models. Yes, it has a learning curve but once you get the hang of it, you change your habits and design your object model first before the DB.


[ September 28, 2005: Message edited by: George Daswani ]


Is that a natural way to work if you're dealing with a database application? It seems more natural to design the data model for the database first in many if not most applications?

Andy Grove wrote some comments on this issue in his blog:

http://www.codefutures.com/weblog/andygrove/archives/2005/01/choosing_a_java.html

The database first approach to database-based applications still does not exclude using Hibernate, of course.
[ September 30, 2005: Message edited by: PJ Murray ]
George Daswani
Greenhorn

Joined: Sep 28, 2005
Posts: 12
IMHO, it's only unnatural if you are coming from a Relational DB / Procedural background (or forced into write an OO system based on an existing relational design).

What if the app I'm writing does not use a Relational DB, instead it uses LDAP, Object Database, XML, or even a Flat File?

Isn't this the reason why people spend alot of time writing DAO's?

Object Model first, before DB. Relational db's are a form of persistance store(s) for data, it does not model the system and it's runtime.

Try writing a Word Processor by designing the database first - if that makes any sort of sense.
[ September 29, 2005: Message edited by: George Daswani ]
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
Originally posted by George Daswani:
IMHO, it's only unnatural if you are coming from a Relational DB / Procedural background (or forced into write an OO system based on an existing relational design).

What if the app I'm writing does not use a Relational DB, instead it uses LDAP, Object Database, XML, or even a Flat File?



Yes - I agree. My comments are related to applications that use relational databases, which is the most common form of data peristence in enterprise applications.

JDO is an obvious choice if you're looking at multiple data sources (take a look at Xcalia's product for a good example).


Originally posted by George Daswani:


Isn't this the reason why people spend alot of time writing DAO's?



Yes, one of many good reasons to use DAOs. In fact, even if you 'only' require data persistence from a database, you should still use a DAO because it can shield you from the underlying persistence techology (JDO, Hibernate, etc).
[ September 30, 2005: Message edited by: PJ Murray ]
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
Vinnie I know the feeling. Been working on getting started with Java over the last 8 months and I just can't seem to find the end to it. JSP soon lead to Hibernate which later lead to JSF which took me to stumble upon Castor. Hopping over stuff like Log4j etc. Finally now I'm beginning to get my apps rolled out in Java and I wouldn't trade the JSF/Hibernate for nothing.

I can recommend you get a hold of MyEclipse (www.myeclipseide.com. It has a nice dbase tool that lets you create hbms out of the database structure all with a single click. Creates Java code too. With this and MyEclipse's JSF and Hibernate support you can roll stuff out in a few hours.

I think it is worth it. Over time I've learned the hard way that nothing stays the same forever. Apps evolve and if you code at the JDBC level you'll have more problems in the end.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Great comments Gerardo. It is a never ending world of new TLAs, new technology. Something you haven't used before. What you really learn over time is how to learn, becoming a JIT Learner. Just In Time Learner.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disappointed w/ Hibernate
 
Similar Threads
Passed java 5 exam
Session maintenance in Hibernate
Somewhat frustrated
Why do we need an O-R mapping framework or tool?
all this O/R stuff...my questions