标签: lift-mapper

如何强制在 Lift Mapper 中创建新事务?

我们在项目中使用 Lift + Mapper(版本 2.4)。我们也使用每个请求的事务模式S.addAround(DB.buildLoanWrapper())

\n\n

在我们的一个请求中,我们需要嵌套事务,我们发现这是有问题的。我们发现可能的“黑客”之一是在单独的线程中启动事务(如下例所示),因为DB对象用于ThreadLocal管理当前连接和事务状态信息。

\n\n

是否有任何实现比下面的更好(更安全并且没有多线程)?

\n\n
  import net.liftweb.db.{DefaultConnectionIdentifier, DB}\n  import akka.dispatch.Future\n\n  /**\n   * Will create a new transaction if none is in progress and commit it upon completion or rollback on exceptions.\n   * If a transaction already exists, it has no effect, the block will execute in the context\n   * of the existing transaction. The commit/rollback is handled in this case by the parent transaction block.\n   */\n  def inTransaction[T](f: \xe2\x87\x92 …
Run Code Online (Sandbox Code Playgroud)

scala transactions lift lift-mapper

5
推荐指数
1
解决办法
369
查看次数

标签 统计

lift ×1

lift-mapper ×1

scala ×1

transactions ×1