File tree 2 files changed +19
-10
lines changed
core/src/main/scala/scalikejdbc/async
2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package scalikejdbc.async
18
18
import scala .concurrent ._
19
19
import scala .util .{ Failure , Success }
20
20
import scalikejdbc .async .ShortenedNames ._
21
+ import scalikejdbc .async .internal .AsyncConnectionCommonImpl
21
22
22
23
/**
23
24
* Basic Database Accessor
@@ -54,14 +55,22 @@ object AsyncDB {
54
55
AsyncConnectionPool ().borrow().toNonSharedConnection().map { nonSharedConnection =>
55
56
TxAsyncDBSession (nonSharedConnection)
56
57
}.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)
64
72
}
73
+ p.future
65
74
}
66
75
}
67
76
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ import play.Project._
4
4
5
5
object ScalikeJDBCAsyncProject extends Build {
6
6
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 "
9
9
// TODO Scala 2.11 https://github.com/mauricio/postgresql-async/pull/87
10
10
lazy val mauricioVersion = " 0.2.13"
11
- lazy val defaultPlayVersion = " 2.2.3 "
11
+ lazy val defaultPlayVersion = " 2.3.0 "
12
12
13
13
lazy val core = Project (
14
14
id = " core" ,
You can’t perform that action at this time.
0 commit comments