org.bowlerframework.squeryl.SquerylController.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of squeryl-mapper_2.9.0 Show documentation
Show all versions of squeryl-mapper_2.9.0 Show documentation
Bowler Framework Project POM
The newest version!
package org.bowlerframework.squeryl
import org.bowlerframework.controller.InterceptingController
import org.bowlerframework.{Request, Response}
import org.squeryl.SessionFactory
import org.squeryl.PrimitiveTypeMode._
/**
* Created by IntelliJ IDEA.
* User: wfaler
* Date: 30/01/2011
* Time: 02:59
* To change this template use File | Settings | File Templates.
*/
class SquerylController extends InterceptingController {
def around(request: Request, response: Response)(controller: (Request, Response) => Unit) = {
val session = SessionFactory.newSession
session.bindToCurrentThread
try{
transaction{
controller(request, response)
}
}finally{
session.close
session.unbindFromCurrentThread
}
}
}