Thread:
 HybernetTestApp.User.hbm.xml(2,2): XML validation ... 
 gunwantw   29 Aug 2007, 03:34 
 Re: HybernetTestApp.User.hbm.xml(2,2): XML vali... 
 Nandem   22 Jan 2008, 17:05 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: gunwantw (29 Aug 2007, 03:34) Replies: 1, Views: 5079
Subject: HybernetTestApp.User.hbm.xml(2,2): XML validation error...
POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE PAGE!

Hi all,

I am new to Nhybernet .

i am working on an assignment using NHibernet.
i am using a windows project for that.

here is my code component by component.

Persistence class  called User.cs.
I am having currosponding database schema for this.

using System;
using System.Collections.Generic;
using System.Text;
using NHibernate.Cfg;


namespace HybernetTestApp
{
    class User
    {
        private string id;
        private string userName;
        private string password;
        private string emailAddress;
        private DateTime lastLogon;

        public User()
        {
            //
            // TODO: Add constructor logic here
            //
                
        }




        public string Id
        {
            get { return id; }
            set { id = value; }
        }

        public string UserName
        {
            get { return userName; }
            set { userName = value; }
        }

        public string Password
        {
            get { return password; }
            set { password = value; }
        }

        public string EmailAddress
        {
            get { return emailAddress; }
            set { emailAddress = value; }
        }

        public DateTime LastLogon
        {
            get { return lastLogon; }
            set { lastLogon = value; }
        }


    }
}

Mapping file for POCO class.

User.hbm.xml , build action for this is Embeded resource.
<?xml version="1.0" encoding="utf-8"?>
<hibernet-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="HybernetTestApp.User,HybernetTestApp" table="users">
    <id name="Id" column="LogonId" type="String" length="20">
      <generator class="assigned"/>
    </id>
    <property name="UserName" column="name" type="String" length="40"/>
    <property name="password" column="Password" type="String" 
ength="40"/>
    <property name="emailAddress" column="EmailAddress" tyoe="String" 
length="40"/>
    <property name="lastLogon" column="LastLogon" type="dateTime"/>

  </class>

</hibernet-mapping>


NHybernet Configuration file  nhibernet.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <!-- an ISessionFactory instance -->
  <session-factory>
    <!-- properties -->
    <property 
name="connection.provider">NHibernate.Connection.DriverConnectionProvide
r</property>
    <property 
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</proper
ty>
    <property name="connection.connection_string">
      Data Source=manik;Initial Catalog=HYBERNET;Persist Security 
Info=True;User ID=sa;Password=
    </property>
      <property name="show_sql">false</property>
      <property 
name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
      <property name="use_outer_join">true</property>
      <!-- mapping files -->
      <mapping resource="HybernetTestApp.User.hbm.xml" 
assembly="HybernetTestApp" />
    
    </session-factory>
</hibernate-configuration>


thats all,

now this is the SessionFactory object instantian code in from1.cs class.
ISessionFactory SessionFactory = new Configuration().Configure
( (at) "D:\DevEnv\HybernetTestApp\HybernetTestApp\hibernate (dot) cfg.xml").BuildSe
ssionFactory();


while running the project i am getting following exception :

HybernetTestApp.User.hbm.xml(3,2): XML validation error: 
The 'urn:nhibernate-mapping-2.2:hibernet-mapping' element is not 
declared.

please put a light on it 

thanks in advance
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]