Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Jun 4, 2014
2 parents 3926ab6 + 402f216 commit 175b419
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
23 changes: 16 additions & 7 deletions core/src/main/scala/scalikejdbc/async/AsyncDB.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package scalikejdbc.async
import scala.concurrent._
import scala.util.{ Failure, Success }
import scalikejdbc.async.ShortenedNames._
import scalikejdbc.async.internal.AsyncConnectionCommonImpl

/**
* Basic Database Accessor
Expand Down Expand Up @@ -54,14 +55,22 @@ object AsyncDB {
AsyncConnectionPool().borrow().toNonSharedConnection().map { nonSharedConnection =>
TxAsyncDBSession(nonSharedConnection)
}.flatMap { tx =>
tx.begin().flatMap { _ =>
op.apply(tx).andThen {
case Success(_) => tx.commit()
case Failure(e) => tx.rollback()
}.andThen {
case _ => tx.release()
}
val p = Promise[A]()
val connection = tx.connection.asInstanceOf[AsyncConnectionCommonImpl].underlying

connection.inTransaction(_ => op.apply(tx)).onComplete {
case Success(result) =>
tx.commit()
tx.release()
p.success(result)
case Failure(e) =>
tx.rollback()
// As documentation recommends - close connection after rollback
connection.disconnect
tx.release()
p.failure(e)
}
p.future
}
}

Expand Down
6 changes: 3 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import play.Project._

object ScalikeJDBCAsyncProject extends Build {

lazy val _version = "0.4.0-RC"
lazy val scalikejdbcVersion = "2.0.0-RC3"
lazy val _version = "0.4.0"
lazy val scalikejdbcVersion = "2.0.1"
// TODO Scala 2.11 https://github.com/mauricio/postgresql-async/pull/87
lazy val mauricioVersion = "0.2.13"
lazy val defaultPlayVersion = "2.2.3"
lazy val defaultPlayVersion = "2.3.0"

lazy val core = Project(
id = "core",
Expand Down

0 comments on commit 175b419

Please sign in to comment.