For any multiuser transactional system, you must decide how to handle concurrent updates and possible versioning issues. In this recipe, we will show you how to set up versioning and optimistic concurrency with NHibernate.
Add a new folder named
Versioning
to theMappingRecipes
project.Add a new class named
VersionedProduct
to the folder:public class VersionedProduct { public virtual int Id { get; protected set; } public virtual int Version { get; protected set; } public virtual string Name { get; set; }public virtual string Description { get; set; }}
Add an embedded mapping named
VersionProduct.hbm.xml
:<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MappingRecipes" namespace="MappingRecipes.Versioning"> <class name="VersionedProduct"> <id name="Id"...