Hibernate in Action
Well, I am glad to tell you that this is not just a dump of the on-line docs. The book not only gets you up to speed with Hibernate and its features (which the documentation does quite well). It also introduces you to the right way of developing and tuning an industrial-quality Hibernate application. I consider myself a pretty seasoned Hibernate developer, being familiar with the API since its 1.2 version in Q1-2002 (if I remember well the first app when we used Hibernate). However, I was proved wrong by Hibernate in Action, which describes best practices and even API features that were unknown or vaguely known to me. That is, until now.
The first chapter, in the good tradition of all first chapters in the world, is an introduction. It's a very well written introduction about why do we need ORM solutions in OO applications. The chapter explains the O/R impedance mismatch, while declaring quickly that OODB sucks (immature and not widely adopted). Wel'll also find out that EJB also sucks from a persistence point of view (for various reasons). Which can be quite a surprise knowing that Gavin is one of the authors of EJB3.0 specs. Or, on the contrary, this will explain a lot of things in the new EJB specs.
Now that we have cleared the "why Hibernate" issue, let's continue to the second chapter. Which - tradition obliged - is a "Hello, world" and a "Let's get started" chapter. Here you go: almost 50 pages later you should be able to write simple Hibernate-based persistence layers and integrate within an application server, like for instance ... Jboss ! Humm, well, why not ? They are sponsors of the Hibernate project, after all.
In the 3rd chapter, our fresh knowledge will be put to good use by starting the development of an online auction application called CaveatEmptor. This app will follow our reading progression and will grow bigger and smarter chapter by chapter. But for the moment, we are at the inception phase. What gives: a little bit of analysis, a stylish class diagram of the domain model and the resulting mapping file. And if you thought (based on 2nd chapter) that the mapping file is very intuitive and simple, you're in for a big surprise -- it is, indeed, intuitive and simple! Quite bizarre for an open-source project. As a matter of fact, the mapping file is one of the pivotal elements of Hibernate, since it addresses directly the O/R impedance mismatch, a recipe for transparent linking your POJOs and the constrained relational model. No wonder that a big part of this chapter is aimed at explaining why and how the mapping works in Hibernate. You'll see how class associations and inheritance translate at the metadata and mapping level. You'll start to understand the things that you took for granted in the previous chapter and you'll have that pleasant "uuh, I see" chain reaction. Hold on, it's just the beginning.
Because chapter 4 is going to explain once and for all the lifecycle of persistent object in Hibernate, their behavior from a persistence point of view as well as the available fetching strategies. And if you thought you already knew everything by heart from the documentation ... well, maybe you do know everything by heart. Nevertheless, it's very well synthesized in chapter 4 and I'll recommend it anytime to a coworker eager for Hibernate knowledge.
In the next chapter (the 5th) the rollercoaster slows down a bit. That is, if you already know the behavior associated with the four possible isolation modes in transactions, what are the different types of locking, what (the hell) MVCC means and the importance of transaction scopes. Chances are you already know some of this stuff quite well, but everybody needs a refresher from time to time, especially when it's well explained and when it comes with versioning and caching (1st and 2nd level) in Hibernate as a desert. By the way, I thought that OSCache supports clustering, not only SwarmCache and JbossCache, as stated in the book. There's even a thoroughly explained example of using JbossCache as a level 2 clustered cache for Hibernate, but it shouldn't be too hard to convert to other types of caching systems.
Now, if I were the author of the book, I would have placed chapter 6 before chapter 5. But I am not the author, which is quite fortunate for you dear readers since Christian and Gavin are much more competent than me at writing books about Hibernate (and probably at some other unrelated domains). They have decided to go back to mapping in chapter 6, after the short transaction/caching intermezzo. Well, they should know better... it's time for a serious dose of advanced mapping. This chapter is attacking interesting subjects such as custom mapping types (simple or composite) and (finally) the mapping of collections. Special guests stars: the whole gang of "sets, bags, lists and maps", together with explanations about their relational equivalent (associations, associations and associations !). Oh and yes "polymorphic association" (section 6.4.3) - I wasn't even aware that Hibernate is able to do that... guess I'm not that 'seasoned' (as a Hibernate developer) after all.
The 7th chapter is about "Retrieving objects efficiently" : about 45 pages for the 'retrieving' part and 6 pages for the 'efficiently' part. Fair enough ! You'll learn how to master basic HQL queries (parameters, pagination ...). You'll get a grip on the query by criteria API, as well as on advanced stuff such as dynamic queries, filters, subqueries and native SQL (very powerful). At the end of the chapter there's the Hibernate-specific solution for the n+1 selects problem, query caching and result iterators.
Following this wealth of useful knowledge, the 8th chapter starts a bit dry. Nevertheless, after a short introduction about Hibernate in managed environments, you'll find yourself again in the land of advanced programming techniques : application-level transaction implementation ! This is mostly new stuff (at least for me) - a great collection of best practices for transactional behavior management in industrial-quality apps. Somewhat unrelated but still interesting, the chapter ends with legacy schemas integration and a smart implementation example for audit logging.
The 9th (and last) chapter is about the round-trip development in Hibernate using the classical toolset : Middlegen and/or hbm2java and/or XDoclet. All the available techniques are presented in a very detailed, step-by-step manner.
Wait : don't close the book, there's more ! Ignore Appendix A (a short and rather uninteresting document about SQL fundamentals - that is, if you know SQL). Appendix B contains mildly un-fascinating ORM implementation strategies pour les connoisseurs (come on guys, I'm just a dumb user). But - Appendix C is a great collection of real-world stories and by all means read them all ! Especially the last one, a treasure of hard to find knowledge (no spoilers, please...).
In the end, I have to confess that there is something truly interesting about Hibernate In Action : albeit very technical, it reads astonishingly easy - and this kind of books is unfortunately very rare nowadays. My congratulations to the authors for this excellent piece of work - it was worth the wait.
As for you dear potential reader, if you already know all the information detailed in the book, I bow before you, great Hibernate wizard.
You can purchase Hibernate in Action from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
well, I overslept Sunday morning, does that count?
CBV*()$#
free ipod and free gmail!
What is Hibernate and what does it do ? I think the article failed to mention that can anyone please tell me what it means.
Johnny English
Jeez, with a manual that big it should be named coma.
Weaselmancer
rediculous.
Perhaps if you told us the purpose of the program/project in the first few lines, we might continue reading.
Would it be too much to tell us what Hibernate acutally is/does?
However, for my Java consulting business, Prevalyer is definitely my new "secret weapon". With a little care, it is easy to set up your POJO classes so that you can add class attributes without breaking your persistent Prevayler object store. Using Prevayler reduces development time. Good stuff.
I'm so sick of "click my referrer link" lameness.
It always drives me nuts when I see a story about a given software package that talks about it's greatness... but that does not simply say what it is. This is made worse when the it's homepage which I'm sure describes the given package is /.ed.
Help Brendan pay off his student loans
I really wish the story submitter would have taken a moment and put a one or two sentence explanation of what Hibernate is. It's not exactly a descriptive name, which I'll concede is common in our industry.
Hibernate is an API for Java that uses Java Beans (get() and set() methods for all properties) to create, read, update and delete rows from a database. It's really cool. It's sometimes called JDO (Java Data Objects) but it's a dangerous association because of the Sun Reference Implementation of JDO, which is its own specification. Hibernate is different.
Attention deficit disorder is a complicated issue, spanning several major... HEY LET'S GO RIDE BIKES!
I hope that the book is better than the review. The reviewer starts off with the most basic assumption that ANYBODY with a CLUE knows EXACTLY what Hibernate is. Perhaps that's why hibernate.org isn't responding right now, because everybody read the top story, found no description of Hibernate, and clicked on the hibernate.org URL as the most likely place to find a description of Hibernate.
-russ
Don't piss off The Angry Economist
This article just seems like a bunch of open source NewSpeak, I swear to god every time I try to read and understand what this is about my brain shuts down... quack quack RTFM quack quack OODB quack LGPL...
Yet no mention of what Hibernate actually is. Great.
It's a very well written introduction about why do we need ORM solutions in OO applications. The chapter explains the O/R impedance mismatch, while declaring quickly that OODB suck (immature and not widely adopted). Wel'll also find out that EJB also suck from a persistence point of view (for various reasons). Which can be quite a surprise knowing that Gavin is one of the authors of EJB3.0 specs. Or, on the contrary, this will explain a lot of things in the new EJB specs.
Now that we have cleared the "why Hibernate" issue,
Yeah... Cleared that right up. ORM? O/R Impedence? OODB? EJB? Little help here?
Give me Classic Slashdot or give me death!
Rather than sharing my theories about a top-secret-yet-LGPLd government project to develop object-oriented Java-based SQL/graphics library that will allow us to train secret UFO pilots to defeat an invasion of alien accountants, would someone care to fill me in? I would be forever in your debt.
Carousel is a lie!
a coma is what their webserver just lapsed into... thank god for the cache...
I mean mispellings in the comments is one thing, but if you are submitting an article for posting, spell check it! Jeez...I stopped reading once i hit "recipy"
Moo.
I think it's interesting there's not more really exceptional documentation for F/OSS projects.
OSS Coders tend to have the fantastic attitude of always improving whats been written before, of making it better & better, revising, patching, rewriting, until an application becomes so damned useful there doesn't seem to be any other realistic choice.
All well and good when it comes to coding - but where are all the documentation geeks to do likewise?
I actually recognize Christian Bauer as the guy who developed the old 68k Mac emulator Basilisk II (..and I, I guess...).
Nice review, but it doesn't actually mention what hibernate is.
I'm hibernating now (zzzzzzzzzzz)
doesn't explain what hibernate is, and the server's already /.ed. Damn. I guess I'll have to die without ever knowing.
Maybe if you take a long nap the site will be back.
Except, of course, any explanation OF WHAT HIBERNATE ACTUALLY IS.
(Jeeze people, is it too much to ask to give a one sentence summary of what a program does?)
I still prefer directly writing the SQL code myself. It doesn't take that long, and for many things it seems to be more efficient. I only pull the fields that I need.
I have seen many applications where a developer will pull a list of objects out of a database and only use a small percentage of what was pulled. This was caused by a heavy persistence layer abstracting what was happening, and a developer that didn't care to find out.
I seem to be in the minority with this view though. Automated persistence is quite trendy.
Usually I am able to BS my way through an article by making a guess based on the title. This article. however, posed a problem to me... I couldn't figure it out, or rather the decision I made wasn't that logical.
Based on the info in the title, I concluded that the project did nothing (after all, a successul implementation of hibernation just sits there.) This caused me much confusion, resulting in me mistaking salt for sugar, and baking soda for non-dairy creamer....
...Remember kids, think before you post...
The real litigious bastards...
Comment removed based on user account deletion
No kidding, this is the kind of crap that makes me wonder why i read /., because surely the editors don't read it. If they aren't interested in /., why should I be interested? This story is exactly where an editor should step in and offer a 2 line descrption of what the package is.
At this point it's mostly the entertaining trolls that keep me comming back. The other stuff I can find elsewhere.
"The R Project for Statistical Computing"
http://www.r-project.org/
This is an amazing stat program that is open source with a lot of documentation backing it up.
Some of the documentation you can download:
An Introduction to R (approx. 100 pages, 650kB)
The R Reference Index (approx. 2300 pages, 12MB)
Also, under their contributed documentation section, they have the documents sepearted by "Documents with more than 100 pages" and "Documents with less than 100 pages".
Its not what it is, its something else.
...
*ducks*
The difference between spam and poop is that you don't have to dig through septic tanks looking for real food. -- Me
Why does Slashdot consistently post these kinds of stories with no context? Give us a little info on what it does, then we can decide quickly if it's a story we want to read.
I swear to God...I swear to God! That is NOT how you treat your human!
(Ok, maybe it's not ironic. After all the flaming from irony-obessed pedants, I have no idea anymore. But it's at least as ironic a rain on your wedding day.)
What I'm listening to now on Pandora...
When people release source under L/GPL, you'd think they'd want people to use it, and contribute back. It's really hard to do that when the code is inaccessible for lack of documentation. Even reading code that is commented (a rarity) is no substitute for an overview - relying on "grep" is no way to trace codepaths or marshal APIs. At least CVS requires a note on checkin, even if it's usually a vague "fixed bugs". If you're not going to write your code starting with a first pass of all comments, with clear, consistent variable names, at least include a description of each code file's function in the grand scheme in its header, and usable README and INSTALL files for the whole project. Most important, have someone not on the design/code team read the docs for usability by a stranger. Beta testing the docs isn't hard, and you get to gloat about your brilliant achievements in words that don't have to compile.
--
make install -not war
So many initial posts asking what Hibernate is when it is probably the poster child of Java Open Source (OK JBoss might be better known but unlike JBoss Hibernate is universally well regarded). Disappointing really.
Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
What truth?
There is no dupe
It's really deceptive. It's like the computer is totally powered off! I can hardly believe it! But it starts right up where I left off. These guys should be commended for their efforts. I barely ever reboot thanks to them.
The program is GPLed, and shows that excellent documentation is possible, if enough people.
See what I've been reading.
However, for my Java consulting business, Prevalyer is definitely my new "secret weapon". With a little care, it is easy to set up your POJO classes so that you can add class attributes without breaking your persistent Prevayler object store. Using Prevayler reduces development time. Good stuff.
Good Lord.
This post, while informative, just makes me want to go to sleep. Or quit my job. Or both.
Maybe I chose the wrong career.
Are Java class mappings to databases really all that exciting?
In the course of every project, it will become necessary to shoot the scientists and begin production.
nonsense, no human mind is capable of dealing with the immense complexity of SQL. Why, databases were just huge excel spreadsheets until smart OO developers figured out how to store... i'm sorry, of course i meant "Persist" objects in them. And don't forget the rallying cry of the modern developer: "the database is the bottleneck".
/twisted & bitter
#!/usr/bin/english
For the comments.
I sometimes do the same thing myself (i.e., just write a little code using the JDBC APIs to grab what I need).
Also: with Hibernate, you do have control over how much of a row of data you actually retrieve since you specify the mapping that you want in an XML configuration file.
Do try Prevayler however: for some applications it really is a great tool. I especially like it for web applications where most data access is read only: caching objects in memory really speeds things up.
I have used Hibernate on the last two J2EE projects I've worked on and can attest to its simplicity and power. Although it'll take you a few weeks to really get the hang of how things work under the hood, it's well worth the learning curve. And it's ridiculously simple compared with EJB - that's for sure. My latest project even involved storing CLOBs to an Oracle Rack cluser - it took a bit of tweaking and research, but we saved ourselves hundreds of lines of codes and it performs without a glitch. ;-) :-)
Okay, I haven't RTFA, but the poster should also have made mention of Spring, which works hand in hand with Hibernate. Spring basically is an Inversion Of Control (IOC) framework, that allows you to define Hibernate transaction and session contexts. Spring also offers a great MVC layer, but one does not have to use that. If one chooses to just use Spring as an addition to Hibernate, one can look at Spring's additional functionalities as needed. Spring also offers Oracle BLOB/CLOB support by offering a customized OracleClobHandler - Oracle ONLY supports its propietary CLOB objects and won't accept java.sql.Clob objects via Hibernate.
Generally, Hibernate is very non-intrusive and gives you the opportunity to write JDBC code alongside with your Hibernate code (which is super-elegant and abstracted the way it should have been done a long time ago). So, it can be slowly folced into an existing project without having to refactor any legacy code.
The Hibernate user group is a bit rude to be quite frank - I've tried to post some questions in the dev group and got pretty angry replies. The 'beginner' group was not very helpful, so I had to google for answers. Of course there's the book, and I would strongly recommend to get it, since it is one of the major revenue sources for those Hibernate contributors. We want open source, but we can't expect to get everything for free, right?
My first exposure to Hibernate was through the Appfuse framework, which is an excellent J2EE kickstart project, complete with ant built, Xdoclet, Hibernate, Spring, the works. I was even able to use XDoclet tags inside my Java beans, relieving me of having to write my Hibernate definition files by hand! It really doesn't get much easier than that. For anyone wanting to give Hibernate/Spring a try, I recommend to download the latest version of appfuse and give it a try - it's a liberating experience. The biggest kick I got was being able to seamlessly switch my project from Oracle over to MySQL by simply changing a few environment variables - I mean, how cooler can it get?
Hmmm, *looks on hard drive*...
... the list goes on, of course ...
a 7000-word document on configuring ALSA drivers
a 400,000-word document on using MySQL
a 700,000-word documentation set for Perl (just the core, not counting add-on modules)
6.5MB of Kernel docs
27MB of Gnome help
Nope, that's not a particularly outstanding trait. If he had talked about this documentation being well integrated with other, related documentation-sets, then I'd find that interesting (rarely is this the case in open source software), but it doesn't sound like it is.
Re-read the article, paying close attention to the words printed in blue. Those are what internet gurus call "links". If you put your mouse pointer on top of a blue word and click the left button, the "link" will take you to another website that will tell you more about the blue words than you could ever fit in a slashdot post.
I prefer writing it myself in small scale projects. For large scale projects, maintaining a bunch of different SELECT statements is just too time consuming.
Hibernate is what their server is doing right now after the vicious slashdotting that it just received.
Some related links, including links to reactions of people coming from Java to Rails:
http://www.loudthinking.com/arc/000297.html
http://www.loudthinking.com/arc/000291.html
I'm with you on that one. There's a lot of sloppy coding going on in the industry, and much of that is thanks to abstraction layers that let the programmer get away with not knowing stuff they really should know. The real irony is that these layers are not contributing to higher quality code (Since the programmers tend not to have the knowledge or experience that makes a good programmer) nor time to market (Because the team spends more and more time working around performance issues related to the abstraction layer, because they don't know enough about the underlying workings of the system to write efficient code.)
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
If you've used a few different ones, you should know it's Persistence, right?
:) English is a very difficult language in the spelling x pronunciation issue, and native speakers seem to have more problems with spelling (since they usually first hear, and only later read the words) than non-native ones.
I don't do this to be a jerk, I just want to help people to write better
They got Osama bin Laden!
No, they're not that exciting. But until recently, they've been a ginormous pain in the ass.
pooptruck
Another lame /. article; what supposedly is an "overview" tells us nothing and is so full of TLA and such that you have to know what they are talking about to even make any sense of it. Clue for timothy: If you're introducing something new in a lead page /. article, it would be nice to actually tell people what it is, cutting through three letter acronyms and other buzzwords that can only be understood in context , which is missing when the reader has no reasonable expecation of knowing what the hell you are talking about!!!
I'm an American. I love this country and the freedoms that we used to have.
Don't even try; your irony is lost on most of the O-O crowd. Many are doubtless reading your comments and nodding their heads sagely in agreement.
Summary: zzzzzzzz
It's 10 PM. Do you know if you're un-American?
Hibernate is as bloated and dumb as Java itself.
Perl's Class::DBI is much sweeter!
Actually, this entire article is proof of how...
- ...program names are getting more pointless by the day (Hibernate?), and...
- ...how most programs are mostly hype (more buzzwords than a Dilbert book).
I'm sorry, but there's no excuse for the utter disregard to using common sense that was exhibited in the "hibernate" developers' group. People wonder why Microsoft can sell shoddy products. Well, I'll tell you why: they give them meaningful names (Word processing: WORD, Development studio: STUDIO).To the people at hibernate.org: you should be ashamed.
I'm working with Hibernate now and I desperately need to read the documentation to find out how to do something and you lot have gone and bloody /.ed the site.
The doco is very good but I think some of it needs updating. A lot of it still refers to the hibernate.properties which I believe is deprecated in favour of xml configuration. For example I still haven't been able to get the SqlExport ant task to work with the xml conf even following the documentation - however I only tried for about 10 mins. I will RTFM when the site is alive again.
----
Notice this quote by one of the Hibernate developers in an interview earlier this year:
"I went into this knowing very little about ORM, and even very little about databases. One of my first tasks was to go out and buy a book to learn SQL properly. All my understanding of the problem comes from what our users have taught us over the last two years."
Sigh... basing a product on secondhand experience from users who probably have never even learned what the relational model is really about.
...or it's in hibernation...
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
Are Java class mappings to databases really all that exciting?
Well, evidently not -- since the author was excited about Prevlayer, which isn't a mapping to a database.
-Billy
The summary was co-authored by those gorrila chimps in an earlier story.
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
I program in both Java and .Net. For those people who wants to use hibernate with .net has a port of hibernate called Nhibernate.
You earn your living on slashdot?
(Seriously, i'm seeing a lot of 'friendly' advice lately, are people getting paid for this?)
With an all expenses paid server meltdown. That will teach them to have hundreds of pages of quality documentation on line.
If Hibernate is your poster child, you need a new child. Or poster. Or analogy. OR maybe its like a child poster on a milk carton. Have you seen this technology? It was last sighted in 2001 shortly after its birth.
Well.. maybe. Or Maybe not. But Definitely not sort of.
I think you oversimplified hibernate. Its an ORM. Its built to read xmls of files that map object fields to database columns (including complex relationships, such as one-to-many and many-to-many). Once that is done, persisting data to the database is quite simple with hibernate.
Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
Anyway, the point is the site doesn't do anything to elucidate the limitations on ACID compliance, querying capabilities, etc. that you would expect from an object database system. Hell, they don't even seem to recognize that Prevayler is just a limited subset of an object database system (i.e. a memory-resident one). I'm glad somebody has written a reusable chunk of code to do this and all, but I wish the people doing it were more aware of the theory behind databases, and what trade-off decisions they were actually making so they could better document and explain them to their users.
Anyway, if you are just comparing it to MySQL (hehe) I'm sure there are lots of great use cases for Prevayler, but when you compare it to a real RDBMS and look at real enterprise application usage scenarios, it's a bit of a different situation.
Hahahaha. Good one ;)
Don't forget, many modern developers haven't yet figured out that abstraction and performance are in an inverse relationship.
Ok... I'm going to argue that the extra data doesn't matter. I know that doesn't make sense on the surface. For code that sits on the server to return data (Hibernate's market), it doesn't matter how much data gets returned. The pipe to the user is always smaller than the pipe to the database server. The biggest bottleneck is still the disk. Since the head is going to pass over the data anyhow, why not read it to put it in the cache? There's a decent enough chance to save a disk seek in the future if you happen to need that data.
Karma Clown
Wow, after reading what I consider an excellent review ... I was aghast that 90% of the posters were asking "Duh -- whaz Hibernate?" It was actually quite amusing.
If a review helps me answer the question "Is this book worth the money?" then this review rates a 10.
I didn't actually see anyone say this, so I'll say it.
Thanks.
Since the website is slashdoted I can't read the FAQ. Does anybody know what's the difference between Hypernate and OJB? Is Hypernate better then OJB?
Seriously, really thick documentation is a warning sign. Have you known any product or program with excessively large documentation not to be problematic? E.g. sendmail, any Microsoft product, emacs, etc...
I wish more people contributed with their POV on this discussion: do we really need Object-Relational mapping tools? What's wrong with having Object-Oriented applications work on a Relational-Data model? Why this modern insistence in that our business models have to be "fully OO"?
You will hear many times that "OO has been proved to be better suited to build large applications". I sort of agree, but then there is even more evidence to support that the relational model is the best methodology for modeling data.
IMO, when building large enterprise apps one can have the best of both worlds by applying each methodology where it really makes sense: model your data following the relational model; build your app following OO patterns and techniques.
Again, in the context of Java: what's wrong with plain old JDBC? What's wrong with not having all my database entities objectified in the language? What's wrong about working with data and not objects?
I have used Hibernate and Spring on a number of projects. Hibernate, of course, provides the abiltity to build POJO Data Transfer objects similar to JDO and others. Spring provides everything else. Really Spring just facilitates AOP, IOC (like most containers) and the ability to swap out all common implementations for another easily (for testing, change in philosophy, etc.). Spring also provides a better MVC layer than Struts (arguably) but allows you to use Struts or any other MVC framework you like.
MiddleKit for Webware. Supports mapping to MySQL or Postgres.
It's ironic that the reviewer acknowledges that introductions are a "good tradition" but then fails to write an good introduction himself . . . I like many had no idea what Hibernate is until I read some of the posts by gracious /.'ers that took the time to post a description of Hibernate. Additonally isn't it good writing style to define your jargon acronyms before using them like this: Object Oriented (OO) or Customer Relations Management (CRM)? The author completely fails to do this.
Why didn't the reviewer do that? I can only suppose that his box is so small that he didn't know that many regular /.'ers have no idea what he is talking about. And I can only guess that the /. editor that posted this and failed to give a description of Hibernate is living in the same box. . .
Hibernate is probably not the type of thing that you would know about unless you are doing larger enterprise development in Java. You can use it for simple apps, but it probably just adds a bunch of unecessary bulk and complexity. If you're working on a large system, it can do a lot of the boring, tedious work for you.
I was fortunate enough to work with a client that dedicated one of our developers to researching Hibernate. He gave us a little presentation with his findings.
Basically, if you find yourself writing object wrappers around your database objects, then Hibernate will potentially save you some time. You don't have to think about the mundane details of mapping fields. Hibernate lets you define everything in configuration files and then it takes care of the data access functions. You can tell it about your primary keys, foreign keys, constraints, etc. It will enforce everything. If you do it right, you don't have to write SQL code to interact with the database. It's all done under the hood.
In keeping with the name hibernate, it also persists objects in memory and grab them from the database "automagically" as needed. So, that gives you some level of caching without your having to think about it. When you get a new instance of, say, customer object #1, Hibernate may populate it from the database. Or, it may grab it from memory. You don't need to know. It is smart enough to deal with transactions as well, although I haven't looked very deeply in to that aspect. It handles just about every other annoying situation you can imagine having to do with the plumbing.
Like a lot of developers, I'm protective about handing off important control over my app to a third party component (or set of components). If you are not comfortable, Hibernate is probably not for you.
The verdict of our team is that we will be implementing Hibernate in our next major development effort. So, I will be deep in it soon!
TODO: come up with a clever sig
But with all this new hardware and great software running on it, we don't have to worry about silly things like memory usage and performance tuning anymore! The magic box does it for us!
:(
I just made me sick
Slashdot is proof that Sturgeon's Law applies to mankind.
Anyway, I think we just sent their site into hibernation...
"Nine times out of ten, starting a fire is not the best way to solve the problem." - my wife
Information is presented in bite-sized chunks matching the 'fits your brain' philosophy that is one of the reasons that make python attractive.
Tip top job Guido, Fred Drake et al.
Hibernate is a superb product, but has some disadvantages: Firstly, it's a non-standard API. This may, or may not, influence a developer's decision to use it, but anyone looking at using an object-relational mapper might also look at JDO (Java Data Objects), which is a standard, and has many competing versions, both commercial and free. A new specification for JDO, version 2.0, is about to be published, which has most, if not all, the features of Hibernate, including many additional aspects which are unique to JDO. Most JDO suppliers already provide these features.
Another consideration is that JDO tends to be more scalable for very high volume database work - for example, single transactions involving thousands of records. Although this kind of work can be done with Hibernate, its not recommended, whereas JDO (especially version 2.0) has functions for highly sophisticated cache management, object state control and 'fetch group' settings that allows such high volume work to be done without excessive memory use.
Can anyone give an explaination of BPM and the Agila BPM engine and lend some insight into the significance of this?
l ue code_1.html
http://www.infoworld.com/article/04/10/04/40NNb
You're right, there is no information in the article. It doesn't even tell us what Hibernate is. The blather is also peppered with undefined acronyms - ORM, POJO, HQL.
And some idiot moderator modded parent down as a troll. Sigh. It's not a troll, it's a valid and accurate criticism of a really crap article. Crap is, unfortunately, becoming the Slashdot-article standard.
Couldn't you have read a few lines further, you insensitive clod? He explains all that: it's "a recipe for transparent linking your POJOs" and generating "basic HQL queries". What could be clearer?
I hope that helped.
C'mon! "Hibernate in Action" is an oxymoron of biblical proportion.
"Flyin' in just a sweet place,
Never been known to fail..."
I'm sorry to hear that it is so throughly documented, as it will now join the ranks of FreeBSD and slowly die (if you believe the netcraft trolls).
But seriously if a project is to be weighed by the volume or quality of its documentation, I'll refer you to the FreeBSD Handbook, man pages, USENET groups, mailing lists, and Greg Lehey's excellent books.
Besides buzzwords, I mean.
I'm tired of all these endless wrappers and frameworks that just keep stacking up. The lower level stuff is usually easier to learn (and more reusable) than all these wrappers that change by the week.
Here's how to set up the class for a Customer:Yup, that's it. It reads the definition from the database and creates the appropriate accessors dynamically. How long does that take with Hibernate?
Now let's add an Order object, and tie it to the customer.Pretty cool huh? Unless you get paid for the hour, why wouldn't want this in your own projects?
Come in from the cold, try Ruby!
Bingo!!! What do I win?
It's official. Most of you are morons.
Check out Tapestry (part of Jakarta) for a much better web framework than Struts. Integrating these 3 frameworks results in a very nice architecture that allows you to write J2EE applications that can be very container-independent.
Spring allows you to put together your UI code, your persistence code, and your business logic together, without the need to tie any layer to the other ones.
Go hug some trees.
I have some experience with EOF (Enterprise Object[1] Framework) and was looking at Hibernate. Now i'm using Cayenne[2]. There is not so much difference between the two latter, taking simplicity and elegance into account. But here is why we choose Cayenne for our situation:
- a friendly open userbase
- a project which got its priorities right
- it resembles, and, can import the model files of EOF
- it reverse engineers existing databases with ease.
- I get a *great* cross platform modeling/mapping GUI tool which saves me lots of work.
- I could write my own database adaptor by subclassing the work already done.
- inheritance is used to separate business logic from persistence and mapping logic. You never need to touch the latter.
etcetera...
From the Cayenne website:
Bill Dudney posted a Cayenne vs. Hibernate[3] entry in his blog. This ended up as a pretty long thread discussing the merits of GUI tools for ORM among other things.
It is interesting because Bill fooled around quiet a bit with the frameworks, and you get a quick idea of what your code will look like in both. Also it gave me the right strategic insight.
The main maintainers of Cayenne got there first with
a good introduction to their creation[4].
Another quote: Unfortunately popular feature-for-feature comparisons[5] of such frameworks provide as much information about the substance as nutrition labels about the food taste. So this is a bit like choosing a dish in a restaurant - its all about the flavor.
Evolution will tell. But this is my bell.
--------
* Sigh *
let's spend 2 years rewriting all business logic in assembler...
while (!asleep()) sheep++
Take a pojo that has a set or a list. Load the object with the load command. Make sure the list gets loaded through the relationship mapping. Take the returned object and copy it to a new pojo with BeanUtils.copyProperties. It doesn't work. It craps out on the list or set. Why? because your hibernate object is not really a pojo. Its a proxy to a pojo. Same issue with at least on xml writer. Pass the hibernate object to it and it craps out.
Try and figure out what flush, update and saveorupdate actually do from reading the documentation. Try and understand the cats, Cats, kitten, cat, Cat mess from the examples. The documentation is aweful.
Hibernate isn't super horrible. But I am sick of fanboys of api's expressing how great something is when there are clearly some ruff turds.
The Perl equivalent is Class::DBI. This is quite a good module for working with databases, as it can save you from writing a lot of code. This article discusses the power of Class::DBI combined with the Template Toolkit, the best pure-MVC templating system there is. Maypole is a system built around these two modules that lets you create a complete Web-based database interface in as little as ten lines of code! Another Maypole article is here.
bp
Say... what are you insinuating he was doing with those beads?
I've fallen off your lawn, and I can't get up.
If ten thousand dollars in hardware saves me 200 hours, between development time and maintenance, then the abstraction is more than worth it.
On the other hand, that might not be the correct tradeoff in a desktop application.
The biggest bottleneck is still the disk. Since the head is going to pass over the data anyhow, why not read it to put it in the cache?
Most RDBMS do some caching already, I would note.
Table-ized A.I.
I prefer writing it myself in small scale projects. For large scale projects, maintaining a bunch of different SELECT statements is just too time consuming.
Why? SQL is a relatively compact language (if you use it right). Putting wrappers around it only makes more layers, red tape, and interfaces to have to dig around change.
(I agree that SQL is not the ideal relational language, but it may be decades before a replacement standard is accepted.)
Table-ized A.I.
However, for my Java consulting business, Prevalyer is definitely my new "secret weapon".
Prevalyer will lock you tightly to Java. Sun might like this, but data tends to outlive languages in the longer run I would note. I don't see how getting locked to Java is an improvement over getting locked to say Oracle. Plus, the Prevalyer tends to assume the relational model is bunk, which triggers a nice holy-war between OO heads and relational heads.
Table-ized A.I.
http://www.swcp.com/info/essays/acrncon.htm
It depends on the popularity... if a library becomes very widely used, its documentation will improve by itself. GTK documentation had been almost nonexistent during the 1.x days (just a tutorial), but now it is mostly acceptable, albeit still not very complete, thanks to so many people needing it.
So many ORMs it's not even funny. I was so frustrated that I just wrote my own. As a result I found out it's just a bunch of bs. A simple ORM is simple. It only take a few hours in Java to create and understand a ConnectionPool. Yea I know I could have saved a little time coding less and using really cool database modeling GUIs, but I like writting code and knowing what is going on behind the scenes.
Leave pre-packaged ORMs to large corporations and begineers so they can confer with their minions.
Just a few comments from a Java developer that has used an old version of hibernate, and hence actually understands what this article is about:
1) Please don't flame the reviewer so much, he's actually done a good job. I personally will buy the book now that he's given the review.
2) Hibernate is a Java based object relational mapping(ORM) tool. ORM deals with the transition on the persistence layer between a database and using the object classes within your program. Where this saves u time is in dealing with type conversions (for instance), but also because with good ORM utilities (like JDO - java data objects) u don't need to write any SQL or stored procs.
but wait, u say, I don't mind writing these! well, when you are dealing with larger projects, it's much easier for a tool to generate the tables or classes for u and just called object.persist() rather than writing lines and lines of code that do essentially the same thing.
3) JDO is an alternative to Hibernate for ORM. unlike Hibernate, JDO is a standard api laid out by Sun, with different providers like kodo. I think the original story goes Gavin King thought JDO sucked so he wrote his own ORM tool.
4) What about performance? Hibernate insist that their product is fast - no objections to the contrary here. Using JDO, most providers optimize their sql to match the database type. On the whole, performance is not bad, but the strengths of these products lie in point (2).
there u go. hth.
Maybe the /. users should be allowed to moderate stories as well as comments.
Eg, we could see
-5 Story
-2 Intro explains nothing about the topic
-3 Duplicate
-1 KDE/Gnome flamewar contained within[1]
+1 It's about some interesting new software that you might like to know about.
and set our thresholds accordingly (by story category if necessary), complementing the user homepage story category preferences.
No, I'm not going to code it myself, not itchy enough for me to scratch.
[1] Insert chosen flame/complaint etc that we've all read a thousand times.
What advantages Hibernate offers over ibatis sql maps?
When they say "the database is the bottleneck" they mean disk seek. That's write. Reading/Writing to disk. That fundamental archaism that so many have forgotted. The DB is (suprise!) an abstracted data persistence mechanism for reading and writing to disk with things like caching and mapping between records.
Unless the xml configuration file looks something like this:
<?xml version="1.0"?>
<!DOCTYPE QUERY [
<!ELEMENT QUERY (#PCDATA)>
]>
<SQL>
<!-- your query here -->
</SQL>
It isn't going to match the power (or simplicity) of SQL. As a matter of fact, this is a pretty good sample if you throw a QUERYID attribute and maybe some other metadata and let the database handle what it does.
I thought it was a fairly good book review. But I know what Hibernate is. Anyone who would read the book should, though it should probably have mentioned JAVA in the summary paragraph. A good rule of thumb is, if you seem more than 4 acronyms in a book review that you don't understand, it's probably not something you're likely to be interested in.
I have worked for a place where the database was the application and for another place where the OO model is the application.
Developing, refactoring and testing changes to an OO model is much easier than one with a relational database back end.
The OO model is also much easier to conceptualise - especially once the logic and data get's beyond a certain level of complexity.
It's generally easier to get better performance in the OO system for a lower hardware/development cost if the model fully fits in memory - especially if business requirements change rapidly.
Example:
In OO you can ask a house object how many people are in the livingroom and if you can't you can neatly add a method the house object for other people to use in the future.
In SQL you need to join the house to the livingroom and then to the people via the location table and then it takes too long so you need to use a query planner only to discover that maybe you are going to need to store a cached denormalised people-location table because you have already created the best indexes. Then next week there is a schema change and it breaks half the queries in the system. It takes on average about 10 mins to understand each query written by someone else and rewrite it.
My point?
You get some stuff free from a good database - persistance, transactions, roll-back, generic querying, etc, So if I have to put a small system togethor quickly a database is ok, but for bigger systems with fast changing requirements they aren't so great.
Matt.
When you ask this house object about the number of people inside it, it asks all its own rooms (livingroom, etc) how many people are in them, and then adds all those numbers together and returns the result to you - in other words it jumps through many of the same hoops you ascribe to the SQL solution. You, the developer, jumped through those hoops (usually one at a time) when you were designing the house object and the abstract room type and so forth, but now you can just say house.getNumberofPeople and it magically works. If you never reused queries, then sure your critique is valid, but since you can always write a stored procedure called GetNumberofPeople(houseid IN INTEGER, numberofpeople OUT INTEGER) (with no procedural code in that proc either) the difference is not that large.
Before we go any furthur, i'm not trying to be one of those grouchy old men who roam the corridors of corporate IT and tell everybody that COBOL was the be all and end all of languages and that everything since has been just useless masturbation. I completely agree that objects are a useful way to more freely and accurately model concepts in the real world than the tables and relations of RDBMS's. I'm just reacting to the kids roaming those same aforementioned corridors claiming that if it ain't (insert language, pattern, or other technology du jour here) then it's obviousely "not the right way to do things".
BTW: whoever moderated my origial post Insightful is either on crack or is engaging in some truly brilliant meta-trolling.
#!/usr/bin/english
Hibernate - persisting something to a data store is like hibernating it. It makes sense.
... but there's no excuse for the utter disregard to using common sense
program names are getting more pointless by the day
You're quite right - and your post in nonsensical.
In this world nothing is certain but death, taxes and flawed car analogies.
The difference is not large setting the thing up in the first place but it's a world of difference when it comes to modifying the house functionality later. Sometimes you modify a room or a person or the interface to house, but it's rare that you will ever need to modify and understand how the whole system works, seperate parts can be considered a black box. Whereas, any changes or new queries required in SQL will require re-understanding the relationships between all those tables.
SQL fitted better with procedural languages where you weren't losing much anyway as all the code was horribly inter-related and refactoring was a nightmare, these days refactoring OO code particularly with unit tests in place can be relatively easy - unless there is an OO-SQL-DB layer that needs to be kept up-to-date.
Using stored procedures may have performance advantages but it also breaks the OO encapsulation/cohesion even more so than you've already done introducing the relational database in the first place. Taking stored procedures and relational databases to the extreme and you have most business logic in complex queries that only a few people understand and you have lost most of the benefit of OO.
Good object databases / object caching solutions that are ACID compliant are rare and often have migration/scalability issues, but one day i hope they will replace the relational database altogethor. Or perhaps it will work the other way round and databases like postgres or Oracle will enter from the J2EE side to better support objects.
Matt.
When you have to quickly write apps with 20 or more database tables, writing SQL code to create/update/retreive/delete/list each and every one of them is a real PITA, not to mention error prone. That's 100 (count them) queries or stored procs for your 20 tables. Tools like Hibernate can be a real godsend in this situation.
In this world nothing is certain but death, taxes and flawed car analogies.
So can sybase power designer, SQL detective, PL/SQL developer, and god knows how many other db-aware ides out there.
Tools are not talent.
I still prefer directly writing the SQL code myself. It doesn't take that long, and for many things it seems to be more efficient. I only pull the fields that I need.
And what happens when you go from your mysql SQL to MS SQL to Oracle SQL? They're just different enough to cause a lot of headaches. How do you get the ID if a newly entered row?
Have you had to go back and maintain your code? Or given it to someone else to maintain? How easy is it for them to add functionality to it, without going through the dozen places where you have the same SQL statement?
The problem I have with SQL is that its forcing me to twist my mind around to fit into a relational model. My mind's got too many things to worry about, let the computer figure it all out.
Jboss ! Humm, well, why not ? They are sponsors of the Hibernate project, after all.
JBoss is mentioned once in the book and that's almost in passing. I was surprised as JBoss is now funding Hibernate.
Well, I've seen "modern" applications that were a nightmare to modify (chasing changes thru different levels of abstraction) and SQL (read two tier database backed - "classical") apps which were a snap to maintain (add a field to the database, modify the insert and update procs in a package named after the table, done in five minutes). The key factors in whether an application will age well are the quality of the design and devlopment that went in to it, not the technology that it is based on or uses (within reason, of course... but both hibernate and "classic SQL based" are well within that reason). This whole fashion for endless discussions about why a given technology is "better" than another or why using certain techniques will invariably doom your software project to the ninth and deepest circle of hell are a waste of time in an industry that already "enjoys" a spectaculat project failure rate. Good developers and designers produce good applications, bad developers and designers produce a mess. End of.
#!/usr/bin/english
Whilst it's obviously true that good developers produce better applications I think that development methodology/tools and team style makes a massive difference.
Having worked in the same agile team for several years it's a world of difference using modern development tools like eclipse, focusing on OO design, automated unit testing, automated deployment and functional testing. The guarantee that the baseline never contains compile time errors, tests always pass in HEAD and there is automated functional testing togethor means development and refactoring can be done in chunks of a few hours and that the commercial team can see the changes live within a couple of days. In the other company i worked for it took two days just to get hold of the main database person and discuss the required schema changes and then discover breakages in code other people looked after.
Of course if your project is using release cycles in months then you can hide up the cost of maintaining a relational database. But in commercial terms it's increasingly hard to be competitive if you are working with release cycles of months or years - atleast for a lot industries.
Having said that a lot can be done to automate schema migration, database recreation and functional testing - but's even with this it still feels like you are fighting the system to get a good development system in place rather than the database helping. It feels more like a required hinderance than an aid to development.
I'm sure other peoples experiences differ.
Matt.
Who said anything about talent? I'm talking about getting the job in most efficient way. You don't have to be a ignorant of SQL to use hibernate.
In this world nothing is certain but death, taxes and flawed car analogies.
document.write("Hello World!")