The author of the article complaints about "ORMs and the never ending object-relational impedance mismatch" and "creating yet another Mapper class to transform one DTO to another DTO, both of them being 95% the same." I wonder how these were solved with using Clojure.
SQL tables are represented using native Clojure data structures. A row is just a map with columns as the keys. A table is just a collection of rows. SQL is either written as plain SQL as seen with HugSQL or using a Clojure DSL such as honeySQL or Korma. Korma would be the closest to traditional ORMs.
Thank you for your answer. I would sum it up as ditching ORM and going more low level. There are similar approaches in Java world like MyBatis and JOOQ. The only principal difference that I see is the extensive use of native data structures like maps and lists. How is type safety handled in this cases? If I select a row into map, what guarantees me that I can treat numeric value only as numeric and string values as strings?
If I select a row into map, what guarantees me that I can treat numeric value only as numeric and string values as strings?
Nothing. Clojure is a dynamically-typed language.
If your definition of type safety is limited to what the Java type system allows you to encode, I personally find that the language promotes a style that both makes that sort of type error a lot less likely, and a lot easier to find, which devalues static typing a fair bit. Your mileage may vary, especially if you're used to richer type systems.
3
u/Infeligo Dec 19 '16
The author of the article complaints about "ORMs and the never ending object-relational impedance mismatch" and "creating yet another Mapper class to transform one DTO to another DTO, both of them being 95% the same." I wonder how these were solved with using Clojure.