Reputation: 213
I've been doing an evaluation of the Play framework and learning Scala which has been fun. Coming from java, the move to the Scala took a fair bit mental gymnastics, however I am now a fan.
I have a sizeable database already mapped using JPA and I was just going to continue to use this code (with hibernate) however this is not the best or recommended approach with Scala. So I started mapping some tables using SLICK but before going too far I realised that I would run into issues with Scala's restrictions on case classes and function parameters (no more than 22).
I find this completely baffling that a modern ORM would have this restriction. I don't have a problem with Scala having this restriction - after all who wants to pass 22 parameters to a function. So my question is : why design a library with this limit? Surely it should have been engineered to map to regular classes? I don't care if it even used reflection to get the job done.
I have seen the workarounds for this which require splitting case classes and recombining using an implicit conversion. But this is just a hack.
I guess if I want to continue to use Play then I should switch to Java and use JPA.
Upvotes: 4
Views: 1099
Reputation: 12206
This strangely numbered limitation is most likely because the Scala programming language limits the max size of a tuples to 22, and tuples are a nice way to represent table rows. See Why are scala functions limited to 22 parameters? for more info. There has been some talk of removing this restriction in Scala 2.11 (and presumably in Slick), and there is an open issue to track it, but this has not happened as of recent 2.11 releases.
I am not a Slick developer, and I'm sure they could have created an ORM based on something without a limit like a List instead of Tuples. Here's my hypothesis for why it turned out that way.
Upvotes: 4