Best practice for object relation mapping to execute delete/update

by Fernando Tan   Last Updated May 28, 2018 10:05 AM

In doctrine (or any ORM in general), the easiest way to execute a delete/update operation is to select such entity, then remove entity or update single attribute in the code, ended by persist the changes to database.

This is the native way to execute delete/update operation in most of the ORM frameworks. It is very handy since it get rids of the SQL statement. However, by comparing to QueryBuilder/SQL language, it would mean two SQL statements here, first is a SELECT sql, then following by a DELETE/UPDATE sql.

My question here this, for the purpose of convenience and ease of maintenance, is it worth to follow ORM pattern and ignore the performance trade off?

Tags : sql orm

Related Questions