my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes Regarding Hibernate.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Regarding Hibernate.." Watch "Regarding Hibernate.." New topic
Author

Regarding Hibernate..

Jack Daniel
Ranch Hand

Joined: Jun 15, 2002
Posts: 163
Well, when i look at Hibernate, the API has packages like...
net.sf.hibernate.*.*.*

But I have somebody's code which has API like cirrus.hibernate.*.*.* Is this from the previous version of Hibernate, which is no more used..???

Also, I really do not figure out what is the Advantage of using Hibernate.. Don't you guys think it complicates the code.. which eventually makes maintainence difficult; (a new programmer would scratch his head, when he looks at the code for the first time)

I am presntly in that case; I have some previous code, which inter-Mixed Struts, Log4j, Hibernate and Castor(all together in one small project, STRUTS application has plugged in hibernate, Castor and Log4j) which has made the code look SO DAMN complicated; i do not understand what is the Big advantage of using all these open source stuff;

Please share your views, so that I can understand what the point is, in using these kindof new design patterns...

Also, when it comes to open source, it would be one of the things which would keep on updating the most; so this is another area, where maintainence becomes an issue??
Looks like the package names have changed, when it comes to hibernate..!!

In All, what are the merits of using either hibernate, castor,...

Maybe occassionally you can use , say castor when it comes to java-XML binding... but anyway please share your opinions; That would be great;

Struts inter-mingled with hibernate and castor made the code pretty complicated..!!

Thanks
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Prashant Kakani,

I think you'll find Peter den Haan's summary in this thread useful. I also found the discussion in this rather long thread very useful, though not entirely on-topic for you. It was in serious danger of going over my head at certain points as these guys really know what they're talking about, but I think it may help you see the point of joining together these different technologies, and how best to achieve it.

Personally I think using frameworks like Struts and Hibernate is a great idea, not just because they're open source. They take a lot of the donkey work out of building applications. They tend to use established best practice for the generic things that they do, allowing you to concentrate on the business logic and presentation layers specific to your application. Admittedly there's a learning curve the first time you use these technologies to understand the architecture and APIs, but you could argue that, even with that, you'd get a better app up and running quicker than if you'd had to do it all from scratch yourself. Of course you reap the real benefits on subsequent projects.

Log4J is also a great tool. Having asked the question why use log4J when you could use java.util.logging, the answer seems to be that, most of the time you wouldn't need it. In any case the recommendation is to use Jakarta Commons logging into which you can plug either log4J or Java logging as you require.

Hope you find that interesting.

Jules
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by prashant Kakani:
Also, I really do not figure out what is the Advantage of using Hibernate.. Don't you guys think it complicates the code..
Sometimes it does, when you find you've got to go around evicting objects from sessions or wizardry like that to preserve uniqueness. And you'll have spent an hour or two trying to figure out what is happening before you get to that state.

Other than that, though, it's great, and no, it doesn't complicate the code at all.
  • As Jules says, there's a learning curve. Most of us start out being burned a couple of times because we treat Hibernate (or JDO) as some kind of glorified JDBC. The object lifecycle is totally different.
  • Writing solid JDBC code is both hard and mind-numbingly boring. If you disagree, we should probably talk about what constitutes solid JDBC code
  • In an OO language like Java, an object model is the most natural and effective way to implement non-trivial business processes.
  • Persisting an object model without an O/R mapper is often awkward. With it, it's pretty straightforward. You don't have to worry about all the little tables but can think in terms of object graphs.
  • O/R mappers like Hibernate decouple the Java object model from the database. Queries (HQL, Criteria) are formulated in terms of the object model and not the database. You only need to know about one domain at a time, and on larger projects, you can hire specialists for each.
  • Just some thoughts, by no means an exhaustive list.

    [...] which eventually makes maintainence difficult; (a new programmer would scratch his head, when he looks at the code for the first time)
    And a new programmer does not scratch his head when first confronted with JDBC code? In many places these days, knowledge of O/R mapping is as much a natural prerequisite for senior staff as knowledge of JDBC.

    I'm mystified by your reference to Struts. Do you really mean to say that you would consider writing a webapp without some kind of MVC framework? Yes, it's another learning curve, but without a framework a framework your webapp is going to be either ill-structured or painful to write, and most likely both. Struts is decent enough and by far the most popular, although by no means best of breed IMHO.

    Log4j - does anyone write any code that does not use Log4j (perhaps through the Commons Logging wrapper)?

    Don't think that I don't understand your problem. I do. Your problem is the sheer number of new tools and concepts you're confronted with at once. They are glued together in lots of little bits and are configured and plugged together by lots of little (and not so little) XML files. A million different ingredients go into the handling of a single HTTP requests, and it is hard to keep track of what goes where and which of them does what.

    If that rings true, let me reassure you. All of these tools are worth learning about. None of them are "odd open-source tools"; with the possible exception of Castor, all of them are industry standards and there are plenty of mainstream commercial tools which use the same concepts and implement the same functionality. They are all in the mainstream of Java development, because they decrease development effort and improve the design and maintainability of your code. Give them some time and things will start to "click".

    - Peter
    [ August 17, 2004: Message edited by: Peter den Haan ]
    Jack Daniel
    Ranch Hand

    Joined: Jun 15, 2002
    Posts: 163

    Don't think that I don't understand your problem. I do. Your problem is the sheer number of new tools and concepts you're confronted with at once. They are glued together in lots of little bits and are configured and plugged together by lots of little (and not so little) XML files. A million different ingredients go into the handling of a single HTTP requests, and it is hard to keep track of what goes where and which of them does what.


    This is exactly where I am standing now; but let me start enjoying learning these new tools,..

    Thanks anyway
    Jack Daniel
    Ranch Hand

    Joined: Jun 15, 2002
    Posts: 163
    Also, it would be great if anybody can tell me where i can find the javadoc for packages like cirrus.hibernate.*;

    When I am looking at javadoc API @ http://www.hibernate.org, i see packages like net.sf.* kind ....

    Thanks for your help;
    pascal betz
    Ranch Hand

    Joined: Jun 19, 2001
    Posts: 547
    seems that the cirrus.hibernate is from version 1.
    check out the CVS:
    http://cvs.sourceforge.net/viewcvs.py/hibernate/#dirlist

    pascal
    Sanz Vai
    Ranch Hand

    Joined: May 06, 2004
    Posts: 47
    Peter, your answer is splendid. I just got my small Hibernate app working. One thing is clear to me: it will be dangerous to start using tools like Hibernate in commerical product without knowing the full architecture. You do not know what kind of exception it will throw and it is difficult to find why it is doing so. Secondly, you used it, liked it, but how would you convince your boss or the standards committee that it is a "mature" engouh product? Where is the guarantee that it doesn't have some bug that will break the app in the middle of some critical job? Who certifies the product? Has Sun approved it or certified it?

    Thanks,

    Sanz
    Peter den Haan
    author
    Ranch Hand

    Joined: Apr 20, 2000
    Posts: 3252
    Originally posted by Sanz Vai:
    [...] it will be dangerous to start using tools like Hibernate in commerical product without knowing the full architecture.
    Yes, absolutely true. It goes without saying that this is true for any sophisticated tool or technology - threading, Java Server Faces, EJBs and the rest of the J2EE platform, any other O/R mapping too, RDBMSs...
    Secondly, you used it, liked it, but how would you convince your boss or the standards committee that it is a "mature" engouh product?
    The sheer critical mass that Hibernate has gathered? I would not at all be surprised if it turned out to be the single most popular O/R mapping tool in the Java space. Just look at the number of Hibernate and Hibernate-related books around.
    Where is the guarantee that it doesn't have some bug that will break the app in the middle of some critical job?
    You don't get any such guarantee, for any product, anywhere. Hibernate's widespread use does inspire confidence that the worst bugs have been hammered out. And at least you do get the guarantee that, if a bug breaks the app in the middle of some critical job and all else fails, you can have a go at fixing the bug yourself! No commercial tool can match that.
    Who certifies the product? Has Sun approved it or certified it?
    It doesn't implement any Sun standard, so there's nothing for Sun to certify. The "certification", if you will, is Sun's invitation of Hibernate guru Gavin King to join the JDO 2.0 expert group (this turned out not to be the best of collaborations, but that doesn't invalidate the point), and the fact that the tool has heavily impacted the current EJB 3 and JDO 2.0 efforts. Sun only just fell short of doing dropping JDO 2.0 altogether, removing entity beans from EJB 3, and making Hibernate itself part of J2EE

    You don't get any of the commercial "guarantees" that managers so love but which in my own experience too often aren't worth squat. But there's no question that Hibernate is one of the few truly important open source tools around, and a major player in the O/R mapping scene.

    I spent the last 7 months working with an 8-strong team on a project utilising the "better, faster, lighter" Spring/Hibernate stack, and it's absolutely great technology.

    - Peter
    [ August 21, 2004: Message edited by: Peter den Haan ]
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: Regarding Hibernate..
     
    Similar Threads
    What's the benefit of using those available Java frameworks
    plz help me on this..
    Goal/Purpose of this book ?
    Struts, hibernate,..... opinion
    Your favorite ORM Tool and Why?