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.  [ 1 post ] 
Author Message
 Post subject: Pls help with NHibernate. Could not compile the mapping doc.
PostPosted: Mon May 18, 2009 3:32 am 
Newbie

Joined: Fri Mar 13, 2009 10:23 am
Posts: 10
Hi all,

I'm doing a program that saves customer details to the database and I'm using NHibernate. I'm very new in it and I'm getting help from the net. I have a problem compiling the mapping file, I get the following error:
"Could not compile the mapping document: Customer.hbm.xml"

I don't have an idea of what I did wrong. Please, if you know what I missed or did wrong, I'd really appreciate your help/advice. Thanks.

hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate_Demo" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="NH">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="connection.driver_class">NHibernate.Driver.MsSql2005Dialect</property>
<property name="connection.connection_string">Server=D9X3KQ3J\SQLEXPRESS; Initial Catalog=NHibernateTest; Integrated Security=SSPI;</property>
<property name="connection.release_mode">on_close</property>
<property name="show_sql">true</property>

<property name="use_outer_join">true</property>
<!-- mapping files -->
<!-- <mapping resource="User.hbm.xml" assembly="MysqlHibernet"/> -->
<!-- <mapping resource="Products.hbm.xml" assembly="MysqlHibernet"/> -->
<mapping assembly="NHibernate" />

</session-factory>
</hibernate-configuration>
</configuration>

Customer.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!--<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> -->

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate" namespace="NHibernate_Demo" >

<class name="NHibernate_Demo.Customer, NHibernate_Demo"
table="Customers" lazy="false">
<id name="CustomerID" type="String" length="5">
<generator class="assigned" />
</id>
<property name="CompanyName" column="CompanyName" type="String" length="40"/>
<property name="ContactName" column="ContactName" type="String" length="30"/>
<property name="ContactTitle" column="ContactTitle" type="String" length="30"/>
<property name="Phone" column="Phone" type="String" length="24"/>

</class>
</hibernate-mapping>

Here is my class:

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

namespace NHibernate_Demo
{

class Program
{
static void Main(string[] args)
{

// Loads the NHibernate Types to prepare for Serialization
Configuration cfg = new Configuration();
cfg.Configure();

//cfg.AddAssembly(typeof(NHibernate_Demo.Customer).Assembly);
//cfg.AddClass(typeof(Customer));
cfg.AddFile("Customer.hbm.xml");

//Opens a session to NHiberbate to allow us to work with objects
ISessionFactory sessionsF = cfg.BuildSessionFactory();

//let ISessiionFactory open connection
ISession sessionS = sessionsF.OpenSession();

ITransaction transaction = sessionS.BeginTransaction();
{
Customer customer = (Customer)
sessionS.Load(typeof(Customer), "ALFKI");

// Show the Contact Name of the Customer
//MessageBox.Show(customer.ContactName);

sessionS.Close();
}


}

}

}


I get an error at this line:

cfg.AddFile("Customer.hbm.xml");

Thanks.


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

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.