ORM: Yes or no?

You might want to look at this earlier question which discusses the benefit of ORMs: What are the advantages of using an ORM?

The most relevant part (taken from the accepted answer):

If you have complex, hand-tuned SQL, there's not much point in using an ORM.

If you are constantly reaching past the ORM and writing your own SQL, the ORM might just end up getting in the way.


Since Im not allowed to comment your post Ill comment like this(lack of points).

Would be good for the discussion WHY you dont like ORM.

Imo, I would go for it. And if you for some reason find a query that is slow by the ORM, then I would make it myself. Just because you use an ORM most of your tasks does not mean you have to use it for all. But yes, it would be preferred.


I personally have found them (well, Hibernate) to be an incredible time sink. Far from saving time, I have spent way too much time trying to figure out what the hell it's actually doing under the covers. As others have mentioned, if your data model grows beyond a certain complexity, having another layer between you and the DB just creates more friction. If your data model isn't that complex, well, then you don't really need ORM anyway.

I do recommend having some sort of abstraction to keep SQL out of your Java code, but that can be done simply with a DAO layer and property files or whatever. Also tools like IBATIS or Spring JDBC can be helpful, since you can still write your own queries, and just use the framework to help with all of the boilerplate code for shuffling data between JDBC and your Model objects.

PS: amusing side note. In my office we actually have a framed picture of Gavin King that we all curse in effigy. "Hey, it's your turn to deal with today's Hibernate issue, so here's Gavin." :-)

Tags:

Java

Orm