Saturday, 15 January 2011

c# - NHibernate - Check if entitiy is out of date/sync -


I am using (nicely) in my project (fluent). Let's say I have a transient unit, A is stored. Then at some point, part of the data store related to that unit is updated.

Is entity A going out of time / sink so that I can go ahead and refresh?

Usually the version column is used to determine , And it can be a number, where this number updates with each, or it is stored on the date time where the last time is turned on.

When an entity updates, the version of the column is updated, then the unit A,

  class A {int ID {receive; Set; } {Get Inter Version}; Set; } String name {get; Set; }} Class AMAP: Classmap & lt; A & gt; {PUBLIC AMAP () {ID (x => x.Id). GeneratedBy.Native (); Version (x = & gt; x.version); Map (x = & x; x.Name); }}  

When unit A is updated like a generated SQL, then

  update one set .... id =? And version =?  

Therefore, if any other transaction has already been updated, then it will fail to make exceptions and updates. On the exception you should be able to reload and retry.

Be sure to use a new session while retrying.


No comments:

Post a Comment