Hey,
I'm reworking UnitOfWork and EntityStore to use events, and it is going
quite well (as expected). But one operation becomes weird: refresh().
If you have a UoW, have done a number of changes which results in an
event list being recorded, and then do refresh on either the entire UoW
or just one entity, what should happen?
The most logical result I can think of is to refresh the underlying
EntityState and then *replay* the events that related specifically to
that Entity. Example:
Load Entity 123 with x=1,y="Foo"
Change x->3
Refresh 123. x had been changed to 5 and y to "Bar"
Replay events for 123
Entity 123 now has state x=3 and y="Bar", i.e. the merge between the new
state and the updated local state.
User is happy and completes() UoW
In store that data is now: 123: x=3, y="Bar"
This seems reasonably logical to me. It also gives us a very powerful
refresh-and-automatically-merge possibility for when versions have
changed on complete(). In other words, you can have a complete()
strategy that does complete() and if there's a ConcurrentModification it
automatically does refresh on those Entities and try to complete()
again, until it works. For quite a lot of usecases that should be quite ok.
Whaddyathink?
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev