File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
core/src/main/scala/scalikejdbc/async Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package scalikejdbc.async
1818import scala .concurrent ._
1919import scala .util .{ Failure , Success }
2020import scalikejdbc .async .ShortenedNames ._
21+ import scalikejdbc .async .internal .AsyncConnectionCommonImpl
2122
2223/**
2324 * Basic Database Accessor
@@ -54,14 +55,22 @@ object AsyncDB {
5455 AsyncConnectionPool ().borrow().toNonSharedConnection().map { nonSharedConnection =>
5556 TxAsyncDBSession (nonSharedConnection)
5657 }.flatMap { tx =>
57- tx.begin().flatMap { _ =>
58- op.apply(tx).andThen {
59- case Success (_) => tx.commit()
60- case Failure (e) => tx.rollback()
61- }.andThen {
62- case _ => tx.release()
63- }
58+ val p = Promise [A ]()
59+ val connection = tx.connection.asInstanceOf [AsyncConnectionCommonImpl ].underlying
60+
61+ connection.inTransaction(_ => op.apply(tx)).onComplete {
62+ case Success (result) =>
63+ tx.commit()
64+ tx.release()
65+ p.success(result)
66+ case Failure (e) =>
67+ tx.rollback()
68+ // As documentation recommends - close connection after rollback
69+ connection.disconnect
70+ tx.release()
71+ p.failure(e)
6472 }
73+ p.future
6574 }
6675 }
6776
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ import play.Project._
44
55object ScalikeJDBCAsyncProject extends Build {
66
7- lazy val _version = " 0.4.0-RC "
8- lazy val scalikejdbcVersion = " 2.0.0-RC3 "
7+ lazy val _version = " 0.4.0"
8+ lazy val scalikejdbcVersion = " 2.0.1 "
99 // TODO Scala 2.11 https://github.com/mauricio/postgresql-async/pull/87
1010 lazy val mauricioVersion = " 0.2.13"
11- lazy val defaultPlayVersion = " 2.2.3 "
11+ lazy val defaultPlayVersion = " 2.3.0 "
1212
1313 lazy val core = Project (
1414 id = " core" ,
You can’t perform that action at this time.
0 commit comments