|
|
|
|
|
by tdons
2063 days ago
|
|
So much this. ORMs? That way lies madness. For example if you use Hibernate in Java you can end up writing stuff like this: interface MyRepository {
Page<SomeObject> findEntitiesByIdAndCreatedAtAfterOrderByCreatedAtDesc(int id, Instant after, Pageable page);
}
This abstracts away executing a query along the lines of:
select * from entities where id = $1 and created_at >= $2 order by created_at descI'll take the latter any day. |
|
When app starts up, Java compiles these declarations and will abort if the declared function actually does not match the entities. This is a huge safety net, which you would not have when you write SQL. And also when you write SQL you have to take care and unpack the "select *" into your fields etc etc. I suspect this is much more important downside than you might realize.