Re: Nesting Transactions
Klaus Wuestefeld <[email protected]>
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <[email protected]> |
You can make that increaseNutPurchases(...) method into an anonymous transaction with the same amount of code or less. :) On Tue, Jun 30, 2009 at 10:11 PM, Justin T. Sampson<[email protected]> wrote: > That's kind of the opposite of Prevayler's design. :) > > Prevayler's whole architecture is based on the fact that transactions are > encapsulated into objects. This allows transactions to be journaled, > replicated, and executed in a streamlined concurrent pipeline. > > Could you say more about why you don't want to write a "composite > transaction"? There may be other things people have done to address similar > concerns. > > Cheers, > Justin > > > On Tue, Jun 30, 2009 at 2:40 PM, Ross Rick <[email protected]> wrote: >> >> Hi all, >> I wonder if anyone has tried nesting transactions with prevayler before. >> >> To be specific, lets imagine two calls to the same transaction done >> sequentially. >> >> LocalList.add( prevayler.execute ( new GetNutsTransaction( "Walnuts") ; >> >> LocalList.add( prevayler.execute ( new GetNutsTransaction ("Pecans") ; >> >> What I would like to do is make those two calls within the same >> transaction without being forced to code a sort of composite transaction. >> Of course, what I am really getting at is the ability to arbitrarily start a >> transaction and then have that bundle all of the smaller transactions until >> I explicitly commit. As a more realistic example, I would want to do >> something like this : >> >> public void increaseNutPurchases(String[] nutTypes, int pctIncrease) { >> >> Transaction txn = startLongishTransaction(); >> >> try { >> for (String nutType : nutTypes) { >> >> List growers = prevayler.execute(new GetGrowerQuery(nutType)); >> for (Grower grower : growers) { >> >> prevayler.execute(new UpdateBuyQuantityTransaction(grower, >> pctIncrease)); >> >> } >> } >> } >> >> catch (Exception e) { >> txn.rollback(); >> } >> txn.commit(): >> >> } >> >> Has anyone tried this ?? Known issues? Any red flags pop up for you >> looking at this? >> Thx, >> Rick >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> To unsubscribe go to the end of this page: >> http://lists.sourceforge.net/lists/listinfo/prevayler-discussion >> _______________________________________________ >> "Databases in Memoriam" -- http://www.prevayler.org >> > > > ------------------------------------------------------------------------------ > > _______________________________________________ > To unsubscribe go to the end of this page: > http://lists.sourceforge.net/lists/listinfo/prevayler-discussion > _______________________________________________ > "Databases in Memoriam" -- http://www.prevayler.org > > ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org