开发者

how to implement object merge

开发者 https://www.devze.com 2023-03-25 03:03 出处:网络
I 开发者_如何学Pythonhave composite objects, that compound of other objects. Two clients changed the objects internals in two separate copies, and I want to merge those changes, what is the best appro

I 开发者_如何学Pythonhave composite objects, that compound of other objects. Two clients changed the objects internals in two separate copies, and I want to merge those changes, what is the best approach to do so, and is there a framework to support such operation?

Thanks, Ohad.


If your objects are plain old java beans, then you could use reflection to compare all properties between 2 objects. Commons BeanUtils can help with that.

But you'll have to implement some conflict resolution strategy. If the same property has been changed by both clients. The easiest would be "the-latest-change-wins" strategy - a change with latest "lastUpdateTime" overwrites any other change.

0

精彩评论

暂无评论...
验证码 换一张
取 消