The seductions of hibernate specific features and annotations

I recently did a bit of exploration, experimenting with different JPA (Java Persistence API) implements to see which one would work best for me. Initially this was triggered by some frustrating behavior on the part of Toplink Essentials’ JPA implementation. Next, I tried OpenJPA, because I read a blog post by someone who seemed to find OpenJPA a refreshing change. OpenJPA had somewhat better error messages much of the time, and did some helpful validation, which was nice. However, I found that OpenJPA was missing some features that I was using, and for whatever reason (maybe my own cluelessness) I eventually ended up in confusing error message hell anyway. Then I tried hibernate, but I soon found myself unhappy with Hibernate as well and switched back to Toplink.

Now, however, I’ve switched back to hibernate again. Why?

  • ejb3unit uses hibernate internally, and using a different JPA provider from my unit tests makes the tests less valuable.
  • Hibernate Annotations: I want to be able to “remove” an object without removing its row from the database; this allows me to keep old objects around for “undo” and history/auditing purposes. I was afraid that I would have to replace all my collections with queries in order to achieve this effect, in which case the whole point of using ORM seems to be negated. Hibernate provides a @Where annotation on a collection which achieves this effect really nicely. Once I used that feature once, I found a ton of other places where I can use it.
  • Hibernate Search: Hibernate comes with a really nice search system; the only alternative I’ve seen is Compass, which also looks nice but I seem to the find the hibernate documentation a bit easier to get started with. Hibernate Search only works with hiberate as the persistence provider, so that’s another reason to use hibernate.

Hibernate does have it’s disadvantages; the largest in my mind is the unfortunate support situation. It seems like hibernate has become “too popular” for its maintainers to handle, and the conversion rate from user to maintainer isn’t very good. As a result their forums and issue tracker are littered with agressive push-back against the users, trying to get them to read all kinds of documentation and forum posts before posting any issues, and they want every issue posted to be carefully constructed and including a test case. A bit much to ask, in my opinion. If the product were simply easier to use, and helped the users more, they’d have a lot less issues.

I think if hibernate were to provide better validation and error messages that guide users to the problem more rapidly, there’d be much less traffic on the hibernate forums and issue tracker.

Anyway, that’s where I am in my JPA & Java EE adventures.

Advertisements

Comments are closed.

%d bloggers like this: