Muhammed Senussi
Muhammed Senussi
  • Muhammed Senussi
Coming Back to SQL After Years of HibernateJava

I am not against Hibernate. I am against not knowing what it emits.

The failure mode is always the same

Something is slow. Someone adds a fetch join. Something else becomes slow. Six months later the mapping is a knot of hints and nobody wants to touch it, because the mapping now encodes performance decisions rather than the shape of the domain.

What we changed

  • Reads that feed a screen go through explicit SQL and map to a record. The screen is the contract, not the entity.
  • Writes stay with the ORM, where identity and dirty checking earn their keep.
  • Every non-trivial query has its plan captured in a test that fails if it changes shape.

The codebase got longer and considerably easier to reason about. That is usually a good trade.

1 Comments

  • Yara Mansour

    October 2, 2024

    The "screen is the contract, not the entity" line is going straight into our team wiki.

Leave a comment