News for hackers. Stuff that matters.
Re:To ORM or Not to ORM by karmakaze on Tuesday May 07, 2019 @07:45PM (#19854542)
I've come to the same conclusion from using a number of query and relation mapping frameworks (e.g. Rails, Spring). I've finally decided to write one that solves the problems that I have with them. It comes down to just a few things:

  1. Embrace SQL
  2. Handle the ON clauses for JOINs
  3. Fetch relations of sets of records (eager or lazy at the call site)
     in batches without making N+1 queries
  4. (bonus) async composability
I decided to make it in Java so it works with any language in the ecosystem and having a simple type system will make it easy to port to any others. Don't mind all the various typed expressions, you can just pass in an SQL string with locally resolved bindings then use that element in larger queries then finally execute the resulting tree that maps to the result type. I just started last week and I'd love any feedback like if you think it's a good idea or any specifics. I'm using JDBI underneath which is a good level of abstraction to complement it.

Edit (you might want the link): https://github.com/karmakaze/safeql

Re:To ORM or Not to ORM by rhlsthrm on Tuesday May 07, 2019 @11:34PM (#19855656)
This is great, this is exactly something I've been looking for. I'll definitely look into using this for my next project.
Re:To ORM or Not to ORM by karmakaze on Wednesday May 08, 2019 @02:35PM (#19861641)
Thanks for the validation. I was beginning to wonder why this hasn't been done already and maybe I'm the exception rather than part of a group who need/want it.
Re:To ORM or Not to ORM by ksec on Wednesday May 08, 2019 @08:39AM (#19858228)
Have you consider posting this as Show HN?
Re:To ORM or Not to ORM by karmakaze on Wednesday May 08, 2019 @02:37PM (#19861665)
Yes that's my intention soon. I'm still dogfooding for a while to shake out its design warts. This post was so fitting I had to mention it.