Advertisement
thoredge

Handling ScalaQuery sessions - ScalaQuerySession impl

Sep 3rd, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.41 KB | None | 0 0
  1. trait ThreadMountedScalaQuerySession extends ScalaQuerySession {
  2.   private val sessionDynamicVariable = new DynamicVariable[Option[Session]](None)
  3.   override def session = sessionDynamicVariable.value.get
  4.   override def intent = {
  5.     case req =>
  6.       ProductDb.database withSession {
  7.         session => sessionDynamicVariable.withValue(Some(session)) {
  8.           super.intent(req)
  9.         }
  10.       }
  11.   }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement