4 ms·
>ORM solves wrong problem It’s the same as saying that wheel solves the wrong problem, because there are other way to move things. By definition, ORM is the ma
by ivan_gammel 6y ago
>ORM solves wrong problem
It’s the same as saying that wheel solves the wrong problem, because there are other way to move things. By definition, ORM is the mapping between ER and OO models. Working with ER models directly in object-oriented languages is suboptimal, because ER design addresses the problem of storage and OOD is more efficient in solving the problem of data processing. Hence the need in ORMs, which are mainstream now exactly because they enable the efficient transition from the storage to the processing data model and vice versa.
The problems which exist in modern ORMs are usually related to the complexity of their abstraction and imperfection of the programming language: the first problem is easy to notice in JPA with fetching strategies and caching, the second one is what author of this new ORM is trying to eliminate with the code generation - the need to use the ER namespace both in mapping declarations and in queries. JPA does not solve it well, quite often requiring developers to use native queries, because Criteria API is too abstract for many use cases and too heavy for modeling queries in the code. On the other side, JOOQ is not offering a convenient metamodel and operating on too low level.
- shashurup 6y agoInteresting, it looks like you see it in different light. Really, my point was that, first, the problem of automatic mapping doesn't need to be solved - its ok to do it manually IMO, second, I'm even unsure that OO is more efficient in data processing. This is definitely subjective, but in my experience in most cases OO didn't add up much to the clarity of my intentions. To be honest the incentive for me to post this was mostly accumulated irritatation by the fact that a mere side effect of the mapping turned to countless attempts to model SQL in the host language. Really, IMO, all of them are worse than SQL, all of them waste your time spent learning them, with all of them sooner or later you find yourself in a position when you figure how to express the SQL you want with the DSL at hand (again, it is hard to qualify this other than wasting time).
- ivan_gammel 6y agoThe object-relational mapping happens everytime you fetch the data from a relational database in an object-oriented program. The moment when you try to generify your code to avoid repeating lists of columns in queries and parsing of similar result sets is the moment you create an ORM tool. All the efforts to create DSLs are coming from the idea that silver bullet exists and it’s possible to cover all use cases by a single solution. It doesn’t. Trivial ORM is enough to cover 80-90% of use cases, for the rest it doesn’t make sense to try — they are usually so unique that running plain SQL and parsing the result is the best. So I agree with you, it’s probably a waste of time to build all those DSLs when we could try to improve the simple ORM experience (Spring Data is moving in the Right direction here).
- shashurup 6y agoAha, I got it now. Technically you are absolutely correct. The mapping always happens. I was just aiming at cases where original ORM intent was to provide more "smooth" OO expirience, such as having object references instead of foreign keys, 1 to 1 class to entity mapping etc.