This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple monad to deal with multiple database transactions with same connection, their commits and rollbacks | |
// Something similar done in http://advorkovyy.blogspot.com.au/2010/10/transactional-monad-for-scala.html | |
import java.sql.Connection | |
trait DbTransaction[A] { | |
def unit: Connection => A | |
def map[B](f: A => B): DbTransaction[B] = DbTransaction { | |
connection => f(unit(connection)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.specs2.mutable.Specification | |
case class A(id: Int, created: String) | |
case class B(id: Int, aId: Int) | |
case class C(id: Int, created: String) | |
object ACreator { | |
val a = A( | |
id = 1, | |
created = "A" |