| in memory rollback [message #384249] |
Fri, 12 December 2008 08:54  |
Tom Eugelink Messages: 801 Registered: July 2009 |
Senior Member |
|
|
Ok, I know these are complex questions, but I just throw them in the group to see if anyone has a bright idea.
Again this is about the entities that are created/modified/remove based on changes made in other entities (read: stock modifications).
The scenario I'm trying to solve is this:
- An "transfer" entity has two changes; two amounts were altered, that belong to each other (like a transfer between bank accounts).
- Based on amount 1 a stock change "A" is made
- Based on amount 2 another stock change "B" is attempted, however the validation throws an exception because the change is illegal (would cause a negative stock).
The exception correctly is shown and change "B" is not made, however change "A" still exists in memory.
If the user navigates away from the screen, he is notified that change "A" is still pending and is asked to persist it: only a partial transaction is performed!
Now, I can solved this from within a closed situation (with just the two related amounts as described above) by holding off on applying the change until the second one also turns out ok. But this also can happen in multiple amount-pairs. E.g. pair 1,2,3 are ok and pair 4 fails. Basically what I need is in-memory transactions. I need to be able to snapshot a memory state and all changes on entities after that must be rollbacked if an exception occurs.
Now, my business model is fully property-change-event supporting, that means that every property, even collections, fire PCE's. I could record all the PCE's and try to roll them back... But it seems like quite a thing to build.
Any suggestions?
Tom
|
|
|