title: 22 fields limit in Scala 2.11 + Play Framework 2.3 Case classes and functions
body: <p>Scala 2.11 is out and the 22 fields limit for case classes seems to be fixed (<a href="https://issues.scala-lang.org/browse/SI-7296">Scala Issue</a>, <a href="https://typesafe.com/blog/scala-211-has-arrived">Release Notes</a>).</p>
  
  <p>This has been an issue for me for a while because I use case classes to model database entities that have more than 22 fields in Play + <a href="https://github.com/mauricio/postgresql-async">Postgres Async</a>. My solution in Scala 2.10 was to break the models into multiple case classes, but I find this solution hard to maintain and extend, and I was hoping I could implement something as described below after switching to Play 2.3.0-RC1 + Scala 2.11.0:</p>
  
  <pre><code>package entities
  
  case class MyDbEntity(
    id: String,
    field1: String,
    field2: Boolean,
    field3: String,
    field4: String,
    field5: String,
    field6: String,
    field7: String,
    field8: String,
    field9: String,
    field10: String,
    field11: String,
    field12: String,
    field13: String,
    field14: String,
    field15: String,
    field16: String,
    field17: String,
    field18: String,
    field19: String,
    field20: String,
    field21: String,
    field22: String,
    field23: String,
  ) 
  
  object MyDbEntity {
    import play.api.libs.json.Json
    import play.api.data._
    import play.api.data.Forms._
  
    implicit val entityReads = Json.reads[MyDbEntity]
    implicit val entityWrites = Json.writes[MyDbEntity]
  }
  </code></pre>
  
  <p>The code above fails to compile with the following message for both the "Reads" and the "Writes":</p>
  
  <p><code>No unapply function found</code></p>
  
  <p>Updating the "Reads" and "Writes" to:</p>
  
  <pre><code>  implicit val entityReads: Reads[MyDbEntity] = (
      (__ \ "id").read[Long] and
      (__ \ "field_1").read[String]
      ........
    )(MyDbEntity.apply _)  
  
    implicit val postWrites: Writes[MyDbEntity] = (
      (__ \ "id").write[Long] and
      (__ \ "user").write[String]
      ........
    )(unlift(MyDbEntity.unapply))
  </code></pre>
  
  <p>Also doesn't work:</p>
  
  <pre><code>  implementation restricts functions to 22 parameters
  
    value unapply is not a member of object models.MyDbEntity
  </code></pre>
  
  <p>My understanding is that Scala 2.11 still has some limitations on functions and that something like what I described above is not possible yet. This seems weird to me as I don't see the benefit of lifting the restrictions on case classes if one it's major users cases is still not supported, so I'm wondering if I'm missing something.</p>
  
  <p>Pointers to issues or implementation details are more than welcome! Thanks!</p>