Cloud Parts

Full ORMs

Map classes to tables and manage the objects for you: one object per row in a session, change tracking, saving a whole unit of work at once, lazy loading and migrations.

How they work

A full ORM keeps state between your code and the database. A Hibernate session (its persistence context) and an EF Core DbContext (its change tracker) both track every entity loaded through them, and when the session flushes or SaveChanges runs, the ORM works out the INSERT, UPDATE and DELETE statements for whatever changed. SQLAlchemy’s ORM does the same with a unit of work built on its Core layer, and Rails’ Active Record puts load and save methods on each model object instead.

That buys a lot of saved code for applications with rich domain models and many forms, and the price is magic you have to understand: lazy relations that fire extra queries, automatic flushes before queries, and sessions that must not live too long. Prisma sits at the light end of this kind. It generates a typed client from a schema file and handles relations and migrations, but returns plain objects with no session or change tracking.

Technologies

What all object-relational mapping have in common →

Sources

Improve this page on GitHub