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.  [ 5 posts ] 
Author Message
 Post subject: Configuration Issue
PostPosted: Thu Oct 22, 2009 6:55 pm 
Newbie

Joined: Thu Oct 22, 2009 6:41 pm
Posts: 3
Location: Philadelphia, US
Hi,

I am new to NHibernate and getting error: "Could not compile the mapping document: Nhibernate.User.hbm.xml". I am sure I have set the Embedded Resource Property to true of xml file.

The mapping file:
<?xml version="1.0" encoding="utf-8" ?>
- <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
- <class name="NhibernateSample1.User,NhibernateSample1" table="Users" lazy="false">
- <id name="Id" column="Id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" />
<property name="Pwd" />
</class>
</hibernate-mapping>

The Config:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernate.Test">
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=VMWIN2003SEBASE;Initial Catalog=NHibernateSimpleDemo;Integrated Security=True;Pooling=False</property>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="use_outer_join">true</property>
<!-- mapping files -->
<mapping assembly="NhibernateSample1" />
</session-factory>
</hibernate-configuration>

The persistent class:
using System;
using System.Collections.Generic;
using System.Text;
namespace NhibernateSample1
{
public class User
{
private int _id;
private string _name;
private string _pwd;

public virtual int Id
{
get { return _id; }
set {_id = value; }
}

public virtual string Name
{
get { return _name; }
set { _name = value;}
}

public virtual string Pwd
{
get { return _pwd;}
set {_pwd = value;}
}
}
}

The NH code:
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
namespace NhibernateSample1
{
public class UserFixture_TL
{
private ISession session;
private ISessionFactory _sessions;
private ITransaction transaction;
public void Configure()
{
_sessions = new Configuration().AddClass(typeof(User)).BuildSessionFactory();
}

public UserFixture_TL()
{

}

public string AddName()
{
try
{
User u = new User();
u.Name = Guid.NewGuid().ToString();
u.Pwd = "124";
//This is the line getting the error
_sessions = new Configuration().AddClass(typeof(User)).BuildSessionFactory();

session = _sessions.OpenSession();
transaction = session.BeginTransaction();
{
session.Save(u);
transaction.Commit();
}
return u.Name;
}
catch (Exception ex)
{
throw ex;
}
finally
{
session.Close();
}
}

}
}


Thnaks in advance!


Top
 Profile  
 
 Post subject: Re: Configuration Issue
PostPosted: Fri Oct 23, 2009 4:45 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Is there an inner exception with more information ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Thanks for your reply, the inner exceptions are:
PostPosted: Fri Oct 23, 2009 8:42 am 
Newbie

Joined: Thu Oct 22, 2009 6:41 pm
Posts: 3
Location: Philadelphia, US
+-InnerException {"Could not instantiate dialect class NHibernate.Dialect.MsSql2005Dialect"}+ InnerException {"Exception has been thrown by the target of an invocation."}
+ InnerException {"The type initializer for 'NHibernate.NHibernateUtil' threw an exception."}
+ InnerException {"Could not load type 'System.DateTimeOffset' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.":"System.DateTimeOffset"}


Top
 Profile  
 
 Post subject: Re: Configuration Issue
PostPosted: Fri Oct 23, 2009 12:42 pm 
Newbie

Joined: Thu Oct 22, 2009 6:41 pm
Posts: 3
Location: Philadelphia, US
Never mind, I solved it. Thanks anyway.

_________________
Tina L.


Top
 Profile  
 
 Post subject: Re: Configuration Issue
PostPosted: Mon Dec 21, 2009 5:14 am 
Newbie

Joined: Mon Dec 21, 2009 4:23 am
Posts: 13
Hello Ms Tina

I got the same error, and developping the same example User.hbm.xml

Could you tell me please how you did solve it Please ?

Thanks you in Advance

My Best Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.