Skip to content
A Play Plugin for using Cassandra
Branch: develop
Clone or download
Pull request Compare This branch is 3 commits ahead of Shiti:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A Play Plugin for using Cassandra

The Plugin initializes a Cassandra Session on startup and provides access to session and other properties through the Cassandra object.

The Plugin also provides play-evolutions like functionality if it is not disabled.

####Usage In library dependencies, include

"com.tuplejump" %% "play-cassandra" % "1.0.0-SNAPSHOT"

Now, Cassandra host, port, cluster and session can be accessed through the API exposed by the Plugin. In addition to that, a method loadCQLFile is also available. The API is documented at TODO

Some examples,

  • executing a query
val query ="title")
      .from("music", "playlists")
      .where(QueryBuilder.eq("id", playlistId))
    val queryResult = Cassandra.session.execute(query).toIterable
  • executing a batch statement
val insertQuery: String = "INSERT INTO music.playlists (id, song_id, title, artist, album) VALUES (?, ?, ?, ?, ?)"

    val ps = Cassandra.session.prepare(insertQuery)
    var batch = new BatchStatement()

    songs.foreach {
      s =>
        batch.add(ps.bind(playlistId,, s.title, s.artist, s.album))
  • loading a CQL statements from a file

Note:The cluster and session exposed are closed by the Plugin when the application is stopped.


Evolution is enabled by default and the file names are expected to be integers in order, similar to play-evolutions for SQL or SQL-like databases.

The configuration property cassandraPlugin.appName should be set when evolution is enabled. The plugin adds an entry for each appName and the default value is appWithCassandraPlugin

To disable evolution, add the following to conf/application.conf,


Note: The plugin loads before GlobalSettings, so it is accessible in a custom Global object.

####Configuration The default configuration is,

cassandraPlugin {
  //host and port of where Cassandra is running
  host = ""    
  port = 9042           
  evolution {
    enabled = true
    directory = "evolutions/cassandra/" //directory within conf to look for CQL files
  appName = "appWithCassandraPlugin" // appName to be saved in DB when using evolutions
You can’t perform that action at this time.