Re: Nesting Transactions
Ross Rick <[email protected]>
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <[email protected]> |
I actually just want to do real nesting of the transactions, I don't want to violate the ideas, I want to extend them by starting a serialization ( I get that the transaction is itself serialized to the journal), lumping them all in until done and then writing it out. Almost like how serialization recurses through containers. In general, I want to tie together multiple smaller transactions for rollback or commit en masse and I could hide all of the complexity with start and end transactions. I am exposing a public API that has both simple CRUD operations and larger operations (like various mass importers). I would like to compose the larger actions out of smaller ones but roll back on any fail. I would also like my consumers to be able delineate those transactions themselves, but don't really want to have to explain the pattern to them. Sure.. as Klaus points out, I can construct an anonymous transaction. I figured that would make it possible to simply set a "start" point .. do a bunch of transactions and then commit them. I can live without it but it would have been nice for 3rd party consumers of my API to build transactions in a way they are used to. R On Jun 30, 2009, at 6:11 PM, Justin T. Sampson 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