Sunday, September 20, 2009

ORM sucks. Hibernate sucks even more.

For years, I already have my own opinion about ORM. The opinion is built on a quite a number of various trials, different practices, multiple measures and just a real life. Thus it sounds this way: ORM sucks big time and should not exist. Why? Shortly, because of noise ratio is tremendously high, while good factor is miserably low.

Being with a time, I would expect them get better. But what happens actually? Take a look at one of them: Hibernate — a powerful, high-performance Java persistence mechanism wannabe. I will tell you honestly: it sucks so much that any decent C++ developer would just hate Java as in whole. This thing just emphasizes whole Java "heaviness" and "bulkiness" that normally scares all tech people who are not just "an average Joe".

Hey, just look at all its glory: https://www.hibernate.org/116.html! Especially take a spot at the moment, when it keeps recreating collection. Now, how you gonna apply "Defensive Copy", once you have immutable objects? Think about of it. Or, take a look how even a silly CRUD application would suffer, once you've got "not-very-recent" object from the session! And the workaround for this? — right, get the object again just to make sure it is recent version...

What I am doing? I am using plain JDBC drivers with a little wrapper that does all the hassle and dirty jobs for me behind the scenes, leaving no XML to me at all. Footprint of the thing is very small and I've got it running on an embedded stuff as well as on a GlassFish cluster.

P.S. No, you're not gonna change any corporate RDBMS from one to another, like you would change your socks. But stuff, like JaQu would help a lot, once support all required dialects.

3 comments:

Anonymous said...

The biggest issue with Hibernate is that its documentation is not convincing enough.

It may be pretty easy for a newbie to JAVA to be scared away from Hibernate and its tricks !

How i made it simple for my team was to use a JPA wrapper on top of hibernate. Then it was much more easier to manage the code.

But the performance we are getting with Hibernate is pretty good. So, no issues there.

BM said...

The biggest issue with Hibernate not a documentation, but the fact that it exists. ORM approach sucks big time and 99% of what Hibernate offers no one actually need. Caching is what database supposed to do, not an application layer.

As of performance, you can not go faster than JDBC itself... :-)

P.S. Java™ is not an acronym.

Unknown said...

I got a pretty large web site crashed by Hibernate sucking away all the available file descriptors of the FreeBSD kernel until I can't even get in by ssh anymore. Not many libraries ever do stuff like that.