Hibernate Books

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Could not compile the mapping document
PostPosted: Thu May 10, 2007 6:30 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
hi
i am new bie to nhibernate.
I am using vs.net 2005 using VB
I am creating a testing nhibernate example
But i am showing error

Could not compile the mapping document: NHibernateWithAccess.User.hbm.xml

I also set embedded resources property of xml file

Shared Sub Main()
log4net.Config.XmlConfigurator.Configure()
Dim configuration As Configuration = New Configuration()
Console.WriteLine("Loading hibernate.cfg.xml...")
configuration.Configure()
Console.WriteLine("Loading mapping files in this executable...")
configuration.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly())
Dim factory As ISessionFactory = configuration.BuildSessionFactory()
Dim firstId As Integer
Dim session As ISession = factory.OpenSession()
Console.WriteLine("Saving a test User object to the database...")

error line
configuration.AddAssembly


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 6:43 am 
Newbie

Joined: Tue May 08, 2007 4:39 pm
Posts: 5
Location: Leipzig, Germany
Hi,

can you post your mapping document?


Top
 Profile  
 
 Post subject: mapping doc
PostPosted: Thu May 10, 2007 6:55 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernateWithAccess.User, NHibernateWithAccess" table="Users">

<id name="_Id" column="Id" type="int" unsaved-value="0">
<generator class="identity" />
</id>

<property name="_EmailAddress" length="50" />
<property name="_UserName" column="UserName" type="String" length="50"/>
<property name="_Password" column="[Password]" type="String" length="50"/>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: version
PostPosted: Thu May 10, 2007 6:56 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
NHibernate-1.2.0.CR2


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 7:53 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
Loading hibernate.cfg.xml...
Loading mapping files in this executable...
16:49:58,812 ERROR ReflectHelper:0 - Could not load type Nhibernate.User, Nhiber
nate.
System.TypeLoadException: Could not load type 'Nhibernate.User' from assembly 'N
Hibernate, Version=1.2.0.3002, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'
.
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Bool
ean ignoreCase)
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName n
ame, Boolean throwOnError)
16:49:58,875 ERROR Configuration:0 - Could not compile the mapping document: Nhi
bernate.User.hbm.xml
NHibernate.MappingException: Could not compile the mapping document: Nhibernate.
User.hbm.xml ---> NHibernate.MappingException: persistent class Nhibernate.User,
Nhibernate not found ---> System.TypeLoadException: Could not load type 'Nhiber
nate.User' from assembly 'NHibernate, Version=1.2.0.3002, Culture=neutral, Publi
cKeyToken=aa95f207798dfdb4'.
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Bool
ean ignoreCase)
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName n
ame, Boolean throwOnError)
at NHibernate.Util.ReflectHelper.ClassForName(String name)
at NHibernate.Cfg.HbmBinder.ClassForFullNameChecked(String fullName, String e
rrorMessage)
--- End of inner exception stack trace ---
at NHibernate.Cfg.HbmBinder.ClassForFullNameChecked(String fullName, String e
rrorMessage)
at NHibernate.Cfg.HbmBinder.BindClass(XmlNode node, PersistentClass model, Ma
ppings mappings)
at NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mapp
ings mappings)
at NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings)
at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String
name)
--- End of inner exception stack trace ---


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 7:53 am 
Newbie

Joined: Tue May 08, 2007 4:39 pm
Posts: 5
Location: Leipzig, Germany
Maybe it is the missing type-attribute on the MailAddress-property-element...

EDIT: It seems that your assembly in the "AddAssembly" line cannot be found. Try to skip this line and check again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 8:11 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
thnks to reply dear

when i ignoring it then this error

Unknown entity class: Nhibernate.User


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 8:17 am 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
Post your hibernate.cfg.xml

My guess is that, somewhere, maybe in the config, you're telling NHibernate to add assembly 'NHibernate' to load the mappings. You need to change that to NHibernateWithAccess.

Also, just to make sure ahead of time, your assembly that has your .hbm.xml file is called NHibernateWithAccess.dll, right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 9:46 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
my problem is not fixed.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 10:53 am 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
mimranshafiq wrote:
my problem is not fixed.


You need to provide more information if you want your problem fixed...

Reread my requests:

Post your hibernate.cfg.xml

Also, just to make sure ahead of time, your assembly that has your .hbm.xml file is called NHibernateWithAccess.dll, right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 11:30 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
<?xml version="1.0" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >

<!-- For simplicity, the NHibernate configuration is stored in this file.
It must be named hibernate.cfg.xml and marked in Visual Studio to be copied
to the output folder. -->

<session-factory>

<!-- By default NHibernate is aggressive in closing connections between
SQL statments. This unfortunately causes a problem when reading ID
numbers assigned by Access (e.g. in AutoNumber fields). See comments
in the Test 1 section of Program.cs. -->

<property name="hibernate.connection.release_mode">on_close</property>

<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
<property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>

<!-- The Sample.mdb file is located in the folder containing the
solution file. This is three folders upward. Relative paths
are supported in Jet connection strings. -->

<property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Sample.mdb</property>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 11:44 am 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
Is your assembly called NHibernateWithAccess?

The error thrown is:

Could not load type 'Nhibernate.User' from assembly 'N
Hibernate

Which indicates that it's trying to load your mapping and type from the NHibernate assembly and not your own NHibernateWithAccess assembly.

For now, please try this... remove this line:

configuration.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly())

And replace it with this one:

configuration.AddAssembly("NHibernateWithAccess");

How are you executing this project?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 11, 2007 3:00 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
please give me ur email address i want to email u my example.
if u dnt mind.
thnks


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 13, 2007 10:49 pm 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
mimranshafiq wrote:
please give me ur email address i want to email u my example.
if u dnt mind.
thnks


ben@hyrman.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 5:28 am 
Newbie

Joined: Thu May 10, 2007 6:24 am
Posts: 10
benhyrman wrote:
mimranshafiq wrote:
r u checked my email.


ben@hyrman.com


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