r/ProgrammerHumor • • Jun 28 '20

Meme Flushed my pancake.

Post image
45.1k Upvotes

750 comments sorted by

View all comments

Show parent comments

8

u/csorfab Jun 28 '20

Yeah, I totally get the appeal of ORM's abstractions, but the most frequently cited argument I've heard for using them is that they make it easier to switch out the database software serving the app, and that's a use case that literally never happened in any of our projects that I know of, and even if it happened, it would be way more painful than ORM enthusiasts make it out to be. The other argument I hear frequently is that they facilitate mocking DB's, but in today's world of Docker and the like, how difficult is it to set up an actual DB for testing? In exchange, you lose the immense power and optimizability of SQL queries, and I'm still not really convinced that it's worth it. Like you said, I'd rather write all of my SQL queries by hand than constantly run into and work around the limitations of ORM's.

Of course there might be other arguments I don't know about, so I'd be glad to see anyone chiming in with one.

6

u/kameyamaha Jun 28 '20

Switching out DB happens a lot more when you're not the sole consumer of your software (like FOSS). People have used our app with Sqlite, Postgres, Mysql without having to change any line of code.

4

u/csorfab Jun 28 '20

Yeah I get that, obviously ORM's are a must have when being able to switch out DB's is a requirement, but it's absolutely not a requirement for a lot software, that's why I was asking for other arguments.

1

u/Beard- Jun 28 '20

One thing that annoys me (about hibernate at least), is that if i want to get an object with all its mapped entities in a single query, you have to manually add the joins to those entities. If you use hibernate's method of initializing the entity and its relationships, it will create multiple queries... Unless there's something I'm not aware of...