Hello all,
I'm new to Nhibernate and new to this forum, so please, be generous.
The problem is that when I'm using the "optimistic-lock" attribute with <many-to-one> or <property> or <set> any other association or a property of a class, then I'm getting the "attribute not declared" (see below the details). I have found that a similar problem was asked for hibernate users
here. Is there a similar solution for Nhibernate users? In the provided mapping file the property that causes the exception is the <many-to-one> relationship, that has
Code:
optimistic-lock="false"
Thanks in advance.
DETAILSNHibernate version: 1.2.1GA Some Nhibernate configuration propertiesCode:
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="show_sql">true</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="hibernate.cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<property name="expiration">120</property>
Mapping document:Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping default-cascade="save-update"
namespace="QestPredictionModule"
assembly="QestPredictionModule" xmlns="urn:nhibernate-mapping-2.2">
<class
name="QestPredictionModule.Core.ModelVersion"
optimistic-lock="version"
table="ModelVersions">
<id
name="Id"
column="ModelVersionID"
type="Int64"
unsaved-value="0">
<generator
class="native" />
</id>
<version
column="V"
name="V"
type="Int64"
unsaved-value="0"
/>
<many-to-one
optimistic-lock="false"
cascade="save-update"
name="Model"
class="QestPredictionModule.Core.Model"
column="ModelID" />
<property
name="QestCreatedDate"
type="date" />
</class>
</hibernate-mapping>
Full stack trace of the exception that occurs:
Quote:
NHibernate.MappingException: QestPredictionModule.ModelVersion.hbm.xml(26,4): XML validation error: The 'optimistic-lock' attribute is not declared. ---> System.Xml.Schema.XmlSchemaException: The 'optimistic-lock' attribute is not declared.
at System.Xml.Schema.SchemaInfo.GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, Boolean& skip)
at System.Xml.Schema.XsdValidator.ValidateStartElement()
...
Name and version of the database you are using: MS SQL 2005Debug level Hibernate log excerpt:Quote:
NHibernate.Cfg.Configuration [(null)] <(null)> (:0) - QestPredictionModule.ModelVersion.hbm.xml(26,4): XML validation error: The 'optimistic-lock' attribute is not declared.
NHibernate.MappingException: QestPredictionModule.ModelVersion.hbm.xml(26,4): XML validation error: The 'optimistic-lock' attribute is not declared. ---> System.Xml.Schema.XmlSchemaException: The 'optimistic-lock' attribute is not declared.
at System.Xml.Schema.SchemaInfo.GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, Boolean& skip)
at System.Xml.Schema.XsdValidator.ValidateStartElement()
--- End of inner exception stack trace ---
...