Joachim,
Many moons ago, Lift automatically created a JDBC transaction when it
started handling an HTTP request and committed/released the connection at
the end of the request. I don't know where that code went. :-(
You can use the following code:
/**
* Build a LoanWrapper to pass into S.addAround() to make requests for
* the DefaultConnectionIdentifier transactional for the complete HTTP
request
*/
def buildLoanWrapper(): LoanWrapper =
buildLoanWrapper(List(DB.DefaultConnectionIdentifier))
/**
* Build a LoanWrapper to pass into S.addAround() to make requests for
* the List of ConnectionIdentifiers transactional for the complete HTTP
request
*/
def buildLoanWrapper(in: List[ConnectionIdentifier]): LoanWrapper =
new LoanWrapper {
private def doWith[T](in: List[ConnectionIdentifier], f: => T): T =
in match {
case Nil => f
case x :: xs => DB.use(x)(ignore => doWith(xs, f))
}
def apply[T](f: => T): T = doWith(in, f)
}
And in Boot.scala, include the line:
S.addAround(List(buildLoanWrapper())
Then rollback will work correctly.
Thanks,
David
On Sat, Nov 15, 2008 at 3:53 AM, Joachim A. <[EMAIL PROTECTED]>wrote:
>
> Hi,
> I'm using Lift 0.9 and the mapper featurese provided by Lift - I like
> it!
>
> Now I do need to do some database operations in a transaction and to
> rollback when an error occurs.
>
> I saw DB.rollback and tried DB.rollback(DefaultConnectionIdentifier),
> but that doesn't rollback anything. I also grepped the lift source
> code. No matches for "transaction" or "rollback" except in DB.
>
> How can I open a transaction and how can I rollback?
>
> Thanks a lot for any help!
> Joachim
>
> >
>
--
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---