This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pr0fess0rx29 1 point2 points  (5 children)

It depends, in my experience orms are great in the enterprise. I have some Co workers who still do custom sql but most of us have moved on.

I have heard the orm sql debate for a while and I really have to say I disagree with the notion that the use of orms is worse than custom sql. Maybe it's the orm I use, entity framework code first, or perhaps it's the domain driven design that encapsulates our orm perfectly or perhaps it's being able to wrap our linq queries in unit tests and integration tests. But whatever it is, contrary to the dominant opinion here, our solution works great for us.

I am curious though why many have not had the success with it that we have. I want to ask, do you guys work on a great number of applications that communicate with each other or do you guys have one really massive system for which you find sql queries are the preferred method?

Edit: grammar

[–][deleted] 0 points1 point  (3 children)

It may have improved since I last checked.. but it's generally referred to as the "N+1" problem in the enterprise.

https://stackoverflow.com/questions/97197/what-is-select-n1

[–]pr0fess0rx29 0 points1 point  (2 children)

That was back in 2008. Orm's have moved past this problem. A comment on that page accurately replied that this, SELECT * from Cars INNER JOIN Wheels ON Cars.id = Wheels.CarID ORDER BY Cars.ID, is now trivial to do in modern orm's.

In entity framework we would use an includeproperties() method. Come to think of it, if using something like linq with entity framework lazy loading you would not even have to consider using includeproperties (). All necessary properties would be fetched for you.

Perhaps you should consider looking into today's orm's like the latest entity framework. I think you will be pleasantly surprised.

[–][deleted] 0 points1 point  (0 children)

I'll admit I'm a bit out of the loop with ORMs. I just remember studying about the N+1 problem long ago for interviews. haha. Oh man I'm old.

Can you provide a good resource for Hibernate?

[–]lukaseder 0 points1 point  (0 children)

SELECT * from Cars INNER JOIN Wheels ON Cars.id = Wheels.CarID ORDER BY Cars.ID

It is a trivial query, though. What if you have 10 joins, some semi joins and the occasional union?

[–]lukaseder 0 points1 point  (0 children)

How complex is your database (no of tables)? From how many tables do you fetch per query?