Transactions with Mapper

219 views
Skip to first unread message

ced

unread,
Mar 2, 2010, 6:54:26 AM3/2/10
to Lift
When I use Mapper outside a request, say in an actor, how do I wrap it
in a transaction? I know that I do a S.addAround(DB.buildLoanWrapper)
to have transactions within a request.
Can anyone provide a simple code snippet?

Many thanks,
-Chris

Jeppe Nejsum Madsen

unread,
Mar 2, 2010, 8:37:11 AM3/2/10
to lif...@googlegroups.com
ced <docp...@googlemail.com> writes:

You can use use :-)

DB.use(DefaultConnectionIdenfifier) {connection =>
User.findAll ....
}

/Jeppe

ced

unread,
Mar 2, 2010, 8:55:16 AM3/2/10
to Lift
Ah great! Thanks!
- Chris

On Mar 2, 2:37 pm, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:

ced

unread,
Mar 2, 2010, 10:03:26 AM3/2/10
to Lift
Another question: Is it possible to nest DB.use? I'd like to have the
same behavior as with the @Transaction annotation from Spring.

David Pollak

unread,
Mar 2, 2010, 11:09:09 AM3/2/10
to lif...@googlegroups.com
On Tue, Mar 2, 2010 at 7:03 AM, ced <docp...@googlemail.com> wrote:
Another question: Is it possible to nest DB.use? I'd like to have the
same behavior as with the @Transaction annotation from Spring.

DB.use nests.  Only when the last DB.use is exited does the transaction commit.  I don't know how Spring does stuff.
 


On 2 Mrz., 14:55, ced <docpom...@googlemail.com> wrote:
> Ah great! Thanks!
> - Chris
>
> On Mar 2, 2:37 pm, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
>
>
>
> > ced <docpom...@googlemail.com> writes:
> > > When I use Mapper outside a request, say in an actor, how do I wrap it
> > > in a transaction? I know that I do a S.addAround(DB.buildLoanWrapper)
> > > to have transactions within a request.
> > > Can anyone provide a simple code snippet?
>
> > You can use use :-)
>
> > DB.use(DefaultConnectionIdenfifier) {connection =>
> >   User.findAll ....
>
> > }
>
> > /Jeppe

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

ced

unread,
Mar 2, 2010, 11:25:31 AM3/2/10
to Lift
Great!
The default behavior with Spring's @Transactional annotation is the
propagation of an existing transaction or, if none is active, the
creation. So behavior is equal.

On 2 Mrz., 17:09, David Pollak <feeder.of.the.be...@gmail.com> wrote:


> On Tue, Mar 2, 2010 at 7:03 AM, ced <docpom...@googlemail.com> wrote:
> > Another question: Is it possible to nest DB.use? I'd like to have the
> > same behavior as with the @Transaction annotation from Spring.
>
> DB.use nests.  Only when the last DB.use is exited does the transaction
> commit.  I don't know how Spring does stuff.
>
>
>
>
>
>
>
> > On 2 Mrz., 14:55, ced <docpom...@googlemail.com> wrote:
> > > Ah great! Thanks!
> > > - Chris
>
> > > On Mar 2, 2:37 pm, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
>
> > > > ced <docpom...@googlemail.com> writes:
> > > > > When I use Mapper outside a request, say in an actor, how do I wrap
> > it
> > > > > in a transaction? I know that I do a S.addAround(DB.buildLoanWrapper)
> > > > > to have transactions within a request.
> > > > > Can anyone provide a simple code snippet?
>
> > > > You can use use :-)
>
> > > > DB.use(DefaultConnectionIdenfifier) {connection =>
> > > >   User.findAll ....
>
> > > > }
>
> > > > /Jeppe
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com >


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net

> Beginning Scalahttp://www.apress.com/book/view/1430219890

Timothy Perrett

unread,
Mar 2, 2010, 8:53:49 AM3/2/10
to lif...@googlegroups.com
Probally worth sticking this on the wiki

Cheers, Tim

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com

David Pollak

unread,
Mar 3, 2010, 11:28:00 AM3/3/10
to lif...@googlegroups.com
On Tue, Mar 2, 2010 at 5:53 AM, Timothy Perrett <tim...@getintheloop.eu> wrote:
Probally worth sticking this on the wiki

Cheers, Tim

Sent from my iPhone

Wait... you've got a broken hand and you can still type on your iPhone?!?! :-)
 
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

Indrajit Raychaudhuri

unread,
Mar 3, 2010, 11:31:01 AM3/3/10
to lif...@googlegroups.com

On 03/03/10 9:58 PM, David Pollak wrote:
>
>
> On Tue, Mar 2, 2010 at 5:53 AM, Timothy Perrett <tim...@getintheloop.eu
> <mailto:tim...@getintheloop.eu>> wrote:
>
> Probally worth sticking this on the wiki
>
> Cheers, Tim
>
> Sent from my iPhone
>
>
> Wait... you've got a broken hand and you can still type on your
> iPhone?!?! :-)

Guess Tim types one handed and he is not a lefty :-)

>
>
>
> On 2 Mar 2010, at 14:37, Jeppe Nejsum Madsen <je...@ingolfs.dk

> <mailto:je...@ingolfs.dk>> wrote:
>
> ced <docp...@googlemail.com <mailto:docp...@googlemail.com>>


> writes:
>
> When I use Mapper outside a request, say in an actor, how do
> I wrap it
> in a transaction? I know that I do a
> S.addAround(DB.buildLoanWrapper)
> to have transactions within a request.
> Can anyone provide a simple code snippet?
>
>
> You can use use :-)
>
> DB.use(DefaultConnectionIdenfifier) {connection =>
> User.findAll ....
> }
>
> /Jeppe
>
> --
> You received this message because you are subscribed to the
> Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com

> <mailto:lif...@googlegroups.com>.


> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com

> <mailto:liftweb%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com

> <mailto:lif...@googlegroups.com>.


> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com

> <mailto:liftweb%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>

Reply all
Reply to author
Forward
0 new messages