Slick事务已提交,但未保存在表[Mysql]中

时间:2019-05-18 10:55:35

标签: mysql scala playframework slick scalaquery

我正在尝试在同一会话中执行多个数据库操作。 DEBUG日志显示事务Commit,但是数据在DB上不持久。我在Scala Play framework 2.6中使用了光滑的3.2.3。我该如何解决这个问题。

 val d = (for {
           dir: Int <- new UploadFileDao().createDocument1(document.documentId, patientId, Some(285),
              hospitalId, clinicId, patientType, categoryType, admissionAppointmentNo, documentName,
              remarks, description).transactionally



            files: Option[Int] <- new UploadFileDao().createFiles1(document.fileList.zipWithIndex.map(l => {

              (l._1.hash,
                document.documentId,
                l._1.fileName, l._1.hash.split("\\.").last,
                l._2, true)



            }).toSeq)

          } yield (dir,files)).transactionally



          val errorHandleAction = d.asTry.flatMap {
            case Failure(e: Throwable) =>
              e.printStackTrace
              DBIO.successful(print(e.getMessage))
            case Success(s) =>

              DBIO.successful(print(s"never reached $s"))
          }


          val m = db.run( errorHandleAction.transactionally)

This is the debug log->
2019-05-18 16:08:49 +0530 [DEBUG] from slick.basic.BasicBackend.action in application-akka.actor.default-dispatcher-24 - #6: success Some(2)
2019-05-18 16:08:49 +0530 [DEBUG] from slick.basic.BasicBackend.action in application-akka.actor.default-dispatcher-24 - #7: success (1,Some(2))
2019-05-18 16:08:49 +0530 [DEBUG] from slick.basic.BasicBackend.action in application-akka.actor.default-dispatcher-24 - #8: Commit
2019-05-18 16:08:49 +0530 [DEBUG] from slick.basic.BasicBackend.action in application-akka.actor.default-dispatcher-24 - #9: success ()
2019-05-18 16:08:49 +0530 [DEBUG] from slick.basic.BasicBackend.action in application-akka.actor.default-dispatcher-24 - #10: Commit

0 个答案:

没有答案