Nhibernate <version> feature not working -
i have started working nhibernate. have found pretty till have hit issue unable solve. appreciated.
i trying use "version" feature implement optmistic locking. below mapping file , portion of code related class. problem no matter how many times modify field, "version" column on database not updated.
my mapping file:
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="mytest" assembly ="mytest"> <class name="project" table="dbo.m_project"> <id name="projectid" type="int32" unsaved-value="null"> <column name="projectid" sql-type="int" not-null="true" unique="true" /> <generator class="native" /> </id> <version name="version" column="version"/> <property name="projectname" type="string"> <column name="projectname" length="100" sql-type="nvarchar" not-null="true"/> </property> <property name="updated" type="bool"> <column name="updated" sql-type="bit" not-null="true"/> </property> <property name="noofitemswithexceptions" type="int"> <column name="noofitemswithexc" sql-type="int" not-null="true"/> </property> <property name="menustate" type="int"> <column name="menustate" sql-type="int" not-null="true"/> </property> <property name="initialized" type="bool"> <column name="initialized" sql-type="bit" not-null="true"/> </property> <property name="inventoryrun" type="bool"> <column name="inventoryrun" sql-type="bit" not-null="true"/> </property> <property name="productionforecastrun" type="bool"> <column name="productionforecastrun" sql-type="bit" not-null="true"/> </property> <property name="monthlyupdate" type="bool"> <column name="monthlyupdate" sql-type="bit" not-null="true"/> </property> <bag name="skulist" table="dbo.p_sku" inverse="true" lazy="true" cascade="save-update"> <key column="projectid" /> <one-to-many class="sku"/> </bag> </class> </hibernate-mapping>
the associated version property:
private int _version; public virtual int version { { return _version; } set { _version = value; } }
thanks!
it might necessay explicity set optimistic-lock
attribute (in theory it's not). instance
<class name="project" table="dbo.m_project" optimistic-lock="dirty">
here have more info it
Comments
Post a Comment