These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: "optimistic-lock" attribute not found exception
PostPosted: Mon Nov 03, 2008 11:05 pm 
Newbie

Joined: Mon Nov 03, 2008 10:38 pm
Posts: 2
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.

DETAILS

NHibernate version: 1.2.1GA

Some Nhibernate configuration properties
Code:
      <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 2005


Debug 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 ---
...


Top
 Profile  
 
 Post subject: Correction
PostPosted: Tue Nov 04, 2008 1:47 am 
Newbie

Joined: Mon Nov 03, 2008 10:38 pm
Posts: 2
I have figured that only <many-to-one> does not support optimistic-lock="false". All other properties seem to be working. Any suggestions?

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.