2
votes

I know scala and/or JVM have a limitation with 22 more fields on case classes and the best way is to split into more than one case class eg:

case class User(id: Long, username: String, password: String, address: Address)
case class Address(id: Long, street: String, city: String)

But looking at phantom dsl documentation, all docs and examples points to a single case class.

The only exception I can see, is using JsonTable showing in this test.

https://github.com/websudos/phantom/blob/develop/phantom-dsl/src/test/scala/com/websudos/phantom/tables/JsonTable.scala

The question is... how can I model inner case class using phantom-dsl for large tables?

EDIT

Just to be clear they object I'm trying to mapping into phantom.

Imagine a cassandra table with 30, 40 fields. How should I map table using case classes? Since I will receive those fields by json through a rest service, is the JsonTable example the correct approach?

1
JVM has not such low limitation, as per JVM specification 1.7 : The number of fields that may be declared by a class or interface is limited to 65535 by the size of the fields_count item of the ClassFile structure (ยง4.1). - Brice
What do you mean by inner case classes? You can either use JSON, Thrift, or other serialisation tools. The only other option would be UDTs, which aren't available in phantom yet. JSON is the simple choice for inner case classes, and phantom can works with any JSON framework. - flavian
@flavian I've just edited my question, but I believe you just gave me the answer saying about the json table. So instead of mapping the common way, I should map the "inner" case classes extending json tables. If you want to post it as an answer, I will be glad to accept that. - Thiago Pereira
The 22 field limit is no longer applicable to Scala 2.11. See - issues.scala-lang.org/browse/SI-7296 - Soumya Simanta
that is great! thank you @SoumyaSimanta - Thiago Pereira

1 Answers

0
votes

Since scala 2.11 does not have anymore case classes 22 fields limitation, you can declare all of your fields flat or use the jsonTable examples to abstract the structure.