When you define a phantom table, a very common practice is to enter a session with a simple attribute. That is why we created connectors so that they can automatically provide a session using the mixin / inheritance method.
import com.websudos.phantom.connectors.SimpleCassandraConnector trait MyConnector extends SimpleCassandraConnector { override val keySpace = "whatever" }
Now that you define the class MyTable , you must define:
object MyTable extends MyTable with MyConnector { def getById(id: String): Future[Option[..]] { } }
You should also use the newer version of Phantom, respectively 1.5.0. Scala 2.11 support was relatively new in 1.2.7, so strange problems may occur because of this, but they are all fixed now.
You also do not need to worry about creating multiple objects. When using connectors, the Cassandra base connection is actually global, with all the corresponding locks in place. What you do is the same exercise for all your tables, even if it may not be displayed.
source share