All Insights
essays

I Stopped Using ORMs (Mostly)

Hibernate broke me at TD. I've barely used an ORM since.

August 28, 20247 min read

ORMs feel productive in the early days and become a tax later. Here's when I still reach for one and when I write SQL directly.

I spent five years writing Hibernate at TD and DBS. I've barely touched an ORM in the year since. Here's why.

The honeymoon

ORMs are great when you're starting out. User.findById(123) reads naturally. The boilerplate of writing SQL feels reduced. Code looks clean.

The regret

For complex queries, ORM-generated SQL is opaque, often inefficient, and sometimes wrong. I've spent days hunting Hibernate-generated N+1 queries, lazy-loading bugs, and weird transactional edge cases.

The mental cost of "what SQL is this actually running?" is higher than the cost of just writing the SQL.

What I use instead

For Java: jOOQ. Type-safe SQL building, no magic. The query I see is the query that runs.

For Node/TS: Drizzle. Same philosophy. The SQL is visible.

For Postgres specifically: I'm increasingly fine with raw SQL in template literals (using a library like Slonik or postgres.js for safety).

Where I still use ORMs

  • Simple CRUD on a small number of tables. The boilerplate savings matter.
  • Teams without strong SQL skills. The learning curve to safe SQL is steeper than to a high-level ORM.
  • Quick prototypes where I'll throw the code away.

What I tell teams

If you're using Hibernate or Sequelize or Mongoose:

  • Make sure every query is logged (so you can see what's actually running)
  • Set up integration tests that catch N+1 patterns early
  • Be willing to drop into raw SQL when the ORM fights you

The argument isn't ORM vs no-ORM. It's: do you understand what your data layer is doing? If yes, the choice is taste. If no, the choice is scaling debt.

The deeper point

The best engineers I work with are SQL-fluent. They read EXPLAIN ANALYZE. They reach for window functions. They write CTEs by reflex.

The ORM-only engineers are productive on the easy stuff and stuck on the hard stuff. Don't be that engineer. Spend a weekend with Use The Index, Luke. Best return on a weekend you'll have this year.

References

databaseormsqlhibernate

Want to discuss this topic?

I'm always happy to dive deeper. Reach out if you have questions or want to collaborate.

Get in Touch

Command Palette

Search for a command to run...