Mapping files are not compiling with NHibernate 2.1.2

Aug 27, 2010 at 3:56 PM

Hello,

I am using NHibernate 2.1.2 to connect to an Oracle 10g XE database.  I created a very simple db table (record_id that uses a sequence, name [nvarchar2], city [nvarchar2], year [number]).  I was able to connect to the database, select my table, and generate the mapping and class files.  The only problem is that when I try to use them, I am getting the error that the mapping file cannot be compiled.  Not other info on why, even in a stacktrace.  The mapping file looks like:

<!--l version="1.0" encoding="utf-8-->

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FirstSample" xmlns="urn:nhibernate-mapping-2.2">
  <class name="FirstSample.Domain.Tester, FirstSample" table="TESTER" lazy="true" >
    <id name="recordId" type="Int64" column="RECORD_ID" access="field">
      <generator class="sequence">
        <param name="sequence">TESTER_SEQ</param>
      </generator>
    </id>
    <property name="City" column="CITY" access="field" />
    <property name="Name" column="NAME" access="field" />
    <property name="Year" column="YEAR" access="field" />
  </class>
</hibernate-mapping>   

and the class file looks like:

namespace FirstSample.Domain {
    
    public class Tester {
        private string city;
        private string name;
        private long recordId;
        private long year;
        public Tester() { }
        public virtual string City {
            get { return this.city; }
            set { this.city = value; }
        }
        public virtual string Name {
            get { return this.name; }
            set { this.name = value; }
        }
        public virtual long RecordId {
            get { return this.recordId; }
            set { this.recordId = value; }
        }
        public virtual long Year {
            get { return this.year; }
            set { this.year = value; }
        }
    }
}

  Does anyone have any clues as to why?

Thanks - Peter

 

Developer
Aug 28, 2010 at 5:59 AM
Edited Aug 28, 2010 at 6:00 AM

In your XML mapping, the id property name does not match the property name from your model. The XML mapping is missing a capital r for RecordId.