Should you use an ORM?
Introduction
I previously worked for a company that was lacking in terms of modern technologies. As usual, when working on a project, I like to introduce more modern technical solutions and I decided to help by developing an API framework that was based on an Object Relational Mapper (ORM).
Surprisingly, the first reaction was unexpected as the idea of using an ORM was immediately rejected. Through this article, I want to shed some light to demonstrate that an ORM may not be the perfect solution but is certainly a better solution than hand-coding (or crafting should I say) every single database request.
What is an ORM?
An ORM is a technical solution that allows abstracting the database from the code. Relational databases are queried using the SQL language which is different from the programming language. The ORM provides 2 main features:
- Mapping: database tables are translated into an equivalent class in the target programming language (also called Plain Old Java Object “POJO” for Java or Plain Old CLR Object “POCO” for .NET);
- Query generation: instead of writing the SQL query yourself, you use the ORM…