开发者

Database update outside application

am I correct assuming that if a different process updates the DB then my NHibernate powered application will be out-of-sync? I'm almost using non-lazy update.

My target DB is mysql 5.0, if it makes any differ开发者_如何学JAVAence.


There isn't a simple way to answer that without more context.

What type of application are you thinking about (web, desktop, other)?

What do you think would be out of sync exactly?

If you have a desktop application with an open window with an open session that has data loaded and you change the same entities somewhere else, of course the DB will be out of sync, but you can use Refresh to update those entities.

If you use NH second-level caching and you modify the cached entities somewhere else, the cache contents will be out of sync, but you can still use Refresh or cache-controlling methods to update directly from the DB.

In all cases, NH provides support for optimistic concurrency by using Version properties; those prevent modifications to out-of-sync entities.


Yes, the objects in your current session will be out of sync, the same way a DataSet/DataTable would be out of sync if you fetch it and another process updates the same data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜