I am having the following in my .hbm.xml file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Core.Domain.Model"
assembly="Core">
<class name="Category" table="Categories" dynamic-update="true">
<cache usage="read-write"/>
<id name="Id" column="Id" type="Guid">
<generator class="guid"/>
</id>
<property name="Name" length="100">
<column name="Name" unique="true" index="IX_Category"/>
</property>
</class>
</hibernate-mapping>
I am having the following code, however, I can see that no exception is being raised when I am inserting a duplicate value for the Name field. Why is that so?
void IRepository<Category>.Save(Category entity)
{
using (var scope = new TransactionScope(TransactionScopeOption.Required))
{
using (ISession session = NHibernateHelper.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(entity);
transaction.Commit();
}
}
scope.Complete();
}
}