5 ms·
From my experience ORMs are good time savers when you have relatively simple query needs, but fall down when things get really complex.
by api 6y ago
From my experience ORMs are good time savers when you have relatively simple query needs, but fall down when things get really complex.
- Daishiman 6y ago"Really complex" means getting down to 6 or 7 joins for your typical SQLAlchemy or Django ORM query. These sorts of queries comprise 5% of my queries, tops. Seems like a fair tradeoff.
- tarkin2 6y agoI have one of those queries. It's the most important in the database sadly. As django bloats and bloats the table space, over the years, more and more do I need those queries, and slower and slower becomes my app.
- Daishiman 6y agoThe mapping of Django models to tables is trivial. Django's not introducing a difficulty, though the entity modeling may be.
- dopidopHN 6y agoExactly, with hibernate if something is too hairy, I use the native query system. ( and hibernate still map the result for me )
- The_rationalist 6y agoNothing prevents you from using raw SQL queries with Hibernate. HQL is just a convenient superset.
- nimchimpsky 6y agowhats the advantage of that ?
- karmakaze 6y agoActually mixing raw queries with JPQL/Hibernate queries is the worst of all worlds. To get it right, you will end up making explicit calls to let the EntityManager know what you want each side to be doing to play nice.
- The_rationalist 6y agoI've never hit such a bug. Can you expand on what (and when) added complexity would a raw query have versus a raw query without hibernate?
- karmakaze 6y agoIt's not a bug, it's by design.
- dopidopHN 6y agoI've seen that a lot in the past 10 years, and I don't find it particularly problematic. Often the fucked up native query end up in a different type of DAO for performance / concurency reasons anyway. Don't get me wrong, I dislike JPA and Hibernate really much, but that particular aspect has often been one of the less painful to deal with.
- stefan_ 6y agoWhere simple already doesn't include pagination, when all those frameworks generate OFFSET queries that cause the equivalent of a full table scan when someone clicks "last page".
- tarkin2 6y agoAnd time. Let's not forget time. Years of Django's ORMs has given our app over a hundred tables. Complex and /fast/ queries are next to impossible. Django's ORM made app development lightening quick for the first developers. And impossible for the ones fives years later.
- FridgeSeal 6y agoORM’s and other frameworks should come with an “eject” command that once you run it, gives you all the raw SQL/generated config/etc etc.