If you are like me and dont want to use the proposed orm anorm in play 2.0, you may want to use circumflex-orm (http://circumflex.ru/projects/orm/index.html) i give you a quick howto on the integration.

First, create a cx.properties in the conf folder of your project:

[codesyntax lang=“scala“]



Also add the dependency to your Build.scala file:

[codesyntax lang=“scala“]

val appDependencies = Seq(
  "ru.circumflex" % "circumflex-orm" % "2.1"


Then create the class and it’s object:

[codesyntax lang=“scala“]

class Task extends Record[Long, Task] with IdentityGenerator[Long, Task] {
  def this(name: String, description: String) = {
    this.name := name
    this.description := description

  val name = "name".VARCHAR(255).NOT_NULL
  val description = "description".TEXT.NOT_NULL

  def PRIMARY_KEY = id
  def relation = Task

object Task extends Task with Table[Long, Task] {
  def apply(name: String, description: String) = new Task(name, description)
  def unapply(t : Task) = Option(t.name(), t.description())


For more info about the fields and the usage of circumflex, look at the docs at their homepage please.

Finally you can retrieve with get for instance, it works without any additions.

[codesyntax lang=“scala“]

val task = Task.get(1).get
println("name" + task.name())


But to save and insert you have to promote a context:

[codesyntax lang=“scala“]

val task = new Task("foo","bar")
  Context.executeInNew {ctx =>


According to a gentle guy from circumflex this should belong into a filter, which must be put somewhere in the lifecycle usage of your app.

Please have a look at the google group discussion for more information about that:


But thats a topic for another day.

Easy, isn’t it? In the end i still could use anorm, or something similar besides it, if i need some complex sql’s to get done, but, as far as i can tell, circumflex should suffice for most of them.


** Well, transaction management was no topic for another day. It turned out that without the Context from circumflex cache management did not work.

It is possible to save and retrieve, but, retrieval happens from the cache, and without the transaction-management the cache does not get updatet.

So, what you have to do is write your own action class like this:

[codesyntax lang=“scala“]

import play.api.mvc.Action
import play.api.mvc.Request
import play.api.mvc.Result
import ru.circumflex.core.Context

case class ScircumflexOrmActionWrapper[A](action: Action[A]) extends Action[A] {

  def apply(request: Request[A]): Result = {
    Context.executeInNew { ctx =>

  lazy val parser = action.parser


And then call it like that:

[codesyntax lang=“scala“]

def index = ScircumflexOrmActionWrapper { Action {

	val taskDbObj = Task AS "taskDb"
	val tasks = SELECT(taskDbObj.*).FROM(taskDbObj).ORDER_BY(taskDbObj.createdAt DESC).list



Now you should have a working solution.