简体   繁体   中英

NHibernate concurrency / cache problem

I have two applications running on a machine, where NHibernate is used as an ORM. One app is managing objects (CRUD operations), while the other is processing the objects (get, process, set status and save).

First I let the processing app process an object and set the status to processed. Then I change a text property manually in the database and reset the status (to make it process it again). The manual DB edit is to simulate the managing app. Then I start to see problems:

  1. The read object still has the old text property, event though I've changed it in the DB. I guess NHibernate caching is the problem here.

  2. When I set the object's status to processed, it uses all properties in the where clause when updating, which means it doesn't get updated in the database. This is because it has the wrong text in a property. I would guess this also has to do with caching.

The consequence of the status not being updated is that the same object (with wrong text) is processed over and over and over...

Anyone out there who can help me with how I should set up NHibernate to make this problem disappear?

更好的在您想要的对象上调用refresh方法,因为冲洗可能会产生有害的副作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM