Phantom DSL建模案例类

Phantom DSL modeling case classes

我知道 scala and/or JVM 在 case classes 上有 22 个字段的限制,最好的方法是拆分成多个 case class 例如:

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

但是查看 phantom dsl 文档,所有文档和示例都指向一个案例 class。

我能看到的唯一例外是在此测试中使用 JsonTable。

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

问题是...如何使用 phantom-dsl 为大型 table 建模内壳 class?

编辑

需要说明的是,他们反对我试图映射到幻影中。

想象一个具有 30、40 个字段的 cassandra table。我应该如何映射 table 使用 case classes?由于我将通过休息服务 json 接收这些字段,JsonTable 示例是正确的方法吗?

由于 scala 2.11 不再有大小写 类 22 个字段的限制,您可以将所有字段声明为平坦的或使用 jsonTable 示例来抽象结构。