New Posts New Posts RSS Feed: Subactions rollback during saving
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Subactions rollback during saving

 Post Reply Post Reply
Author
dak56 View Drop Down
Newbie
Newbie


Joined: 19-Jun-2008
Posts: 2
Post Options Post Options   Quote dak56 Quote  Post ReplyReply Direct Link To This Post Topic: Subactions rollback during saving
    Posted: 19-Jun-2008 at 1:06am
According to documentation just before saving entity to datasource an instance of NumericIdGenerator is called to retrieve the real Id for this entity. Saving entity is a transaction, so if something goes wrong I would like to rollback not only this transaction, but also to rollback the id, which I retrieved from datasource using NumericIdGenerator. The problem is that I can't rollback id retrieval because NumericIdGenerator gets a new connection to datasource and commits its transaction independently of parent entity saving transaction.
The same issues become important also during handling Saving event. If something goes wrong after handling Saving event I will have no possibilities to rollback handling code.
Is there any way to get over this difficulty?
 
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 19-Jun-2008 at 9:55am
Your statement is correct, but somewhat misleading.  The conversion from temporary ids to permanent ids occurs before the save to the database, but after the transaction has started.  Therefore, if the save transaction is rolled back, your ids should get restored.
Back to Top
dak56 View Drop Down
Newbie
Newbie


Joined: 19-Jun-2008
Posts: 2
Post Options Post Options   Quote dak56 Quote  Post ReplyReply Direct Link To This Post Posted: 20-Jun-2008 at 1:06am
Originally posted by davidklitzke

Therefore, if the save transaction is rolled back, your ids should get restored.
When I ask NumericIdGenerator to generate next id, it allocates ids using AdoHelper's new connection: it selects next id and then UPDATES nextid counter to the NEW value. If save transaction is rolled back after updating - id counter value won't be rolled back to the OLD value because NEW value of id counter is already comitted to the datasource.
What I want is to rollback id counter value (or something else in "Saving: handler for example) - the nested transaction - in case of parent transaction rollback
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 20-Jun-2008 at 11:36am

What I said earlier was incorrect.  I should have checked our source before I replied. and I did not.  The conversion from temp ids to real ids takes place in PrepareToSave and then the transaction scope is set and the save is attempted.  There is an existing enhancement request to enlarge the transaction scope, but I know of no plans currently to address this in the near term.

Back to Top
GeoffAtDatagaard View Drop Down
Newbie
Newbie
Avatar

Joined: 23-Jun-2008
Location: South Australia
Posts: 2
Post Options Post Options   Quote GeoffAtDatagaard Quote  Post ReplyReply Direct Link To This Post Posted: 25-Jun-2008 at 12:44am
> There is an existing enhancement request to enlarge the transaction scope
 
I hope that would be optional/configurable.
 
Many of our applications use an 'odometer' class which my initial inquiries show will map well to your Id generators (with a few mods in the classes implementing IIdGenerator).
 
But our applications rely on the behaviour currently exhibited as discussed above.
When a transaction fails in our applications, most of the time(read always), we do not want to rollback the odometer as another user or process may already have taken the next id.
 
The alternative would be to hold up process B until process A's transaction was completed (either way).
 
Perhaps I'll change my mind after playing more with client side caching ???
 
 
 
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down