[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: in memory rollback

Gordon Yorke wrote:
I don't see how SQL would solve your problem. You have user requested changes to Entity instances that are not valid. You will need to develop some mechanism in your application to notify the user and refresh the user's view. EM.refresh() can rollback the changes to the Entities within the Persistence Context if that is all you need.
--Gordon



Not quite. I have user made changes and system made changes (based on the user changes), I only need to rollback the latter. By using SQL for the system changes, I can use the database rollback to roll that back, while keeping the user made changes in memory.

Say there is a "transfer" entity moving 10 dollars from account A to account B. That is the instruction: "this must happen". Now the system starts actually implemeting that order, resulting in an "substraction" entity on account A and "addition" entity on account B. The addition may fail and both have to be rolled back, but the transfer entity should remain in memory. I cannot have a "transfer" entity in my system, without corresponding sub and add.

An approach would be to mark a transfer as "unbooked", store it, commit, and only then start creating the sub/add entities. Upon success the transfer is marked "booked" and all is committed, or on fail you can indeed clear all entities. That may work.


Tom