添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Australia (English) Brasil (Português) Česko (Čeština) Danmark (Dansk) Deutschland (Deutsch) España (Español) France (Français) Indonesia (Bahasa) Italia (Italiano) Magyarország (Magyar) Nederland (Nederlands) Polska (Polski) România (Română) Singapore (English) Türkiye (Türkçe) Россия (Русский) ישראל (עברית) المملكة العربية السعودية (العربية) ไทย (ไทย) 대한민국 (한국어) 中国 (中文) 台灣 (中文) 日本 (日本語) 香港特別行政區 (中文)

below method not able to handle concurrency and throwing exception  (NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction)

In hibernate xml i am using <version name="DBVersion" column="DBVersion" type="Int64" generated="never" unsaved-value="0"/>

public void Save(Object o)
// Check to make sure a session has been started, if not open a new session
if (_session == null)
_session = GetSession();
// Connect to the DB if necessary
ReconnectDBConnection();
// Start a transaction
BeginTransaction();
// save
_session.SaveOrUpdate(o);
// commit
CommitTransaction();
catch (NHibernate.StaleStateException e)
string msg = "DB Stale data error.  Reason: " + e.ToString();
//show error message
throw new ExceptionDatabaseStaleData(msg, e);

Hi 000rakesh,

Thank you for posting here.

According to your description, I note that your question is more related to NHibernate.

NHibernate is a third-party product for which we don't provide help, so I suggest you post your question in NHibernate forum for more help.

The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework.

Thank you for your understanding.

Best Regards,

Xingyu Zhao


MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com .