Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate disadvantages

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to understand the Hibernate advantages and disadvantages.

Hibernate is good because
  • Maintenance is easy
  • You concentrate on business logic and not on SQL
  • Can work with different database with little change in code
  • Performance optimization and caching possible


  • Let me know if there are other advantages. I want to understand what kind of optimizations are possible ?

    Coming to disavantages, the learning curve is steep. Any more ? thanks
     
    David Newton
    Author
    Rancher
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hibernate is bad because:

    * Maintenance is difficult
    * You have to focus on SQL to avoid poor performance
    * Performance optimization is difficult because you have to back down into raw SQL

    In other words, for simple usecase, Hibernate is easy... almost *too* easy, because it can lull you into a false sense of complacency, and poor performance can sneak up on you before you know what happened. For simple usecases it's easy to tune. For very complicated models, I find Hibernate to be awkward and irritating. For some things I'd just as soon use SQL or an object DB.
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8933
    Firefox Browser Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks. How are queries generated. Will that impact performance ?
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    David Newton wrote:Hibernate is bad because:

    * Maintenance is difficult
    * You have to focus on SQL to avoid poor performance
    * Performance optimization is difficult because you have to back down into raw SQL



    I think our experiences may be different David, but I don't find these things to be true when compared to implementing JDBC support for multiple database platforms. I'm very aware that before Hibernate existed I wrote my own very similar data access technology because I was sick of writing and maintaining the same boiler plate code over multiple databases. I've also yet to come across a situation where I have had to favour SQL over Criteria or HQL for performance reasons (though that's not to say one doesn't exist). It is true that Hibernate doesn't do well with poorly modelled database, e.g. where the principals of relational modelling have been abandoned, but that is not a surprise really. What is it you find difficult about maintenance, especially when compared to JDBC? Or are you comparing against another ORM?


    How are queries generated. Will that impact performance ?

    Perhaps. There is nothing intrinsic in any technology that will produce good or bad query logic; that is almost entirely down to how the developer uses said technology.
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8933
    Firefox Browser Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Can you give example of poorly modeled database ?
     
    David Newton
    Author
    Rancher
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The biggest maintenance issue is when there are database changes and the models aren't being generated automatically, which happens more than I understand the reason for. When using something like Spring JDBC, this is almost trivial; with Hibernate it may lead to a surprising amount of work, depending.

    The SQL issues are generally with legacy databases (the "poorly-modeled" ones in particular). When everything has been designed with Hibernate in mind, and there isn't a lot of hand-tuning necessary, I've been reasonably happy with it.

    But overall, I'm still not convinced I like it as a general-purpose solution; I guess I'm still undecided. It may be I just don't know Hibernate well enough, too, or that I know SQL better, or etc. (I'm actually planning on spending some time this fall getting Very Good at both, so my opinion might change in a month or so--we'll see!)
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic