Handling versioning and concurrency
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.
Getting ready
Complete the Getting ready instructions at the beginning of this chapter.
How to do it…
Add a new folder named
Versioningto theMappingRecipesproject.Add a new class named
VersionedProductto 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"...