Hi All,
I know this may be controversial, but I'd like to make a call for better documentation. Everytime I mention something like this everybody goes "their documention is excellent" and refuse to listen any further. Don't get me wrong - the documentation is good. I'd just like to know if it could be made better.
My problems are really to do with:
a) Good examples
b) Recommended approaches
Good examples
The documentation covers an awful lot, but leaves a few huge holes. As a result, I imagine thousands of users are scratching their heads, hundreds are leaving Hibernate after scratching, and thousands are scratching around other people's code. This is all a huge waste of time (yes I know, we all have important things to do).
What do I mean by good examples? Here are some:
Hibernate has one-to-one one-to-many many-to-many etc. and examples of these are given in terms of hibernate's configuration. All of these with bi-directionality and without. However, examples are not given in Java - leading to huge tracts of people making implementation mistakes (not updating both sides of a many-to-many etc.)
These are common, repeatable, things. Almost everybody who uses Hibernate needs to do these things. If there were clear examples that people could use, far fewer mistakes would be made, and the threshold required for uptake would be lowered. Most people use Hibernate with xdoclet - how about a list along these and these lines, but together with Java code and xdoclet annotated code for each combination (one-to-many, one-to-many-with-inverse, one-to-many-with-bidrection) etc.
Assuming all readers can piece together these kinds of things easily is a mistake. Assuming readers can find it in the sample applications you point to is a mistake. For example, I (and others) spent hours looking at freeroller's code (why? Because media-coverage is extensive that freeroller is a hibernate app), which seems to be a bird's nest of castor and hibernate. I spent hours looking at struts-resume, which is not at all definitive and whcih has things like classes representing the link table in a many-to-many.
Another example is things like the "inverse=true" option. What this means, I have no idea. The documentation defines it in terms of itself (mark this collection as the "inverse" end of a bidirectional association), and tells you where to use it in a few places. Fine, you dutifully use it in a few places. But that is not understanding, and again prone to error without good examples. Which side of a many-to-many bidirectional do I mark as inverse. An arbitrary side? What if there is no obvious parent-child? Why must I mark an arbitrary side as the inverse, why can't hibernate do it. What are the implications on the Java code that I have to write. What are the implications, if any, of doing it. etc.
Hibernate can do complex amazing cascading of assigned identifiers. No good examples are given of this (that I could find). It's an awesome feature, lost to the masses.
Again, hours of scratching scratching.
Recommended approaches
By recommended approaches I am talking about a step up, architecturally. For example, what is the recommended approach in a tiered-system for updating adding a link between two objects in a many-to-many relationship. Apparently one should find the one object, find the other, and the add to each side of the collection. This may sound obvious, but to people coming from an SQL background you keep thinking "but, isn't finding the objects expensive. In SQL I can do one simple UPDATE given the UID's, I don't need to locate both ends". But of course in an O/R setting you typically do.
People are writing web apps - a lot. I imagine this is one of Hibernate's big markets. But there is no recommended methodology.
And again, we have to all scratch around tons of (sometimes badly written) code trying to find "the approach".
I've got a headache, I'll stop now :)
Well done to all involved with Hibernate. Contrary to what you may think, I think it's awesome. I want it to be more accessible, that's all.
Jeff