A transaction management library for
Scala
users, migrated fromSpring Framework
.
// Core library
libraryDependencies += "com.lingcreative" %% "dbx-core" % "2.1.0"
// for Anorm users
libraryDependencies += "com.lingcreative" %% "dbx-anorm" % "2.1.0"
import dbx.api._
object PersistenceSupport extends DatabaseComponents {
// replace `DataSource` with the really implementation you use
override lazy val dataSource = new DataSource(username, passwd, url)
}
class UsersDAO(transactional: Transactional[Connection]) {
def findAll() = transactional() { connection =>
val resultSet = connection.createStatement().executeQuery("SELECT * FROM users")
extractUsers(resultSet)
}
}
See SQLFactorySpecs, PackageSpecs
dbx {
resources = [ default ]
default {
resource = default
readOnly = false
isolation = DEFAULT
propagation = REQUIRED
timeout = -1
noRollbackFor = []
rollbackFor += java.lang.RuntimeException
rollbackFor += java.lang.Error
}
}