Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation

Lift JTA Transaction API

To include this module in your Lift project, update your `libraryDependencies` in `build.sbt` to include:

Lift 2.6.x for Scala 2.9 and 2.10:

    "net.liftmodules" %% "jpa_2.6" % "1.2"

Lift 2.5.x for Scala 2.9 and 2.10:

    "net.liftmodules" %% "jpa_2.5" % "1.2"

Lift 3.0.x for Scala 2.10:

    "net.liftmodules" %% "jpa_3.0" % "1.2-SNAPSHOT"

The semantics are the same as used in the EJB spec. E.g. Required, RequiresNew, Mandatory, Supports, Never. All these are exposed as monadic objects and high-order functions in the TransactionContext object.

The implementation is hooked into the Lift’s JPA implementation.
Check the ScalaDoc (or the source) for the documentation on usage, semantics etc.

There are two versions of the API, one monadic and one using high-order functions.

Note: The module package changed from net.liftweb.transaction to net.liftmodules.transaction in May 2012. Please consider this when referencing documentation written before that date.

Monadic API

 for {
   ctx <- TransactionContext.Required
   entity <- updatedEntities
   if !ctx.isRollbackOnly
 } {
   // transactional stuff
val users = for {
   ctx <- TransactionContext.RequiresNew
   name <- userNames
 } yield {
   // transactional stuff
   val query = ctx.getEntityManager.createNamedQuery("findUserByName")
   query.setParameter("userName", name)

High-order functions API

TransactionContext.withTxRequired {
    ... // REQUIRED semantics

  TransactionContext.withTxRequiresNew {
    ... // REQUIRES_NEW semantics


The configuration is done in the persistence.xml file + the Sample configuration files can be found in the src/main/resources directory.
Here are the essential configuration options in the JPA persistence.xml file:

<persistence xmlns=""
  <persistence-unit name="LiftPersistenceUnit" transaction-type="JTA">


      <property name="hibernate.transaction.manager_lookup_class"
                value="net.modules.transaction.hibernate.LiftTransactionManagerLookup" />


Currently it is hard-coded to use the Atomikos Transaction library and the Hibernate JPA implementation.
This will have to be configurable + some other options as well. See the TODOs in the code.


The Jenkins build is triggered on a push to master. The server is at