3 ms·
That sounds extremely complicated because you have to do the vast majority of work yourself. >So there's no impedance mismatch, and no need for the vastly more
by imtringued 8y ago
That sounds extremely complicated because you have to do the vast majority of work yourself.
>So there's no impedance mismatch, and no need for the vastly more complicated code that is needed to bridge it.
Serializing arbitrary data structures is far from trivial, especially because JSON doesn't support references natively and therefore things like cycles are impossible without adding IDs yourself which is incompatible across JSON parsers. The naive way to serialize objects to JSON also tends to cause duplicated objects for every reference.
Or you can just use any SQL Database and use an ORM, write your damn Domain Classes [0], call .save() when you want to save and then query the damn thing [1] and if you want eager loading you can configure that too. Honestly it's so frictionless I don't see why I should bother with whatever your preferred workflow is.
[0] http://gorm.grails.org/latest/hibernate/manual/index.html#domainClasses http://gorm.grails.org/latest/hibernate/manual/index.html#do...
[1] http://gorm.grails.org/latest/hibernate/manual/index.html#criteria http://gorm.grails.org/latest/hibernate/manual/index.html#cr...
I'm sure most complaints against ORMs happen because newcomers, who don't have sufficient knowledge of relational databases, try to model arbitrarily complex objects that cannot be mapped to a relational database (and not to JSON without extra support by the parser either) or because they think they don't have to write queries at all. In other words: they are fundamentally trying to swim against the stream and then blame the tool. If you know of the limitations of relational databases then ORMs are just a tool that saves you time and lets you avoid boring work.